package a.c.b.z.g;

import a.c.b.k;
import a.c.b.z.b;
import a.c.b.z.f;
import java.io.IOException;

public abstract class c implements f {
    private static final String f = "NetChannel";
    public static final String g = "127.0.0.1";

    /* renamed from: a  reason: collision with root package name */
    private final b f89a;
    private final boolean b;
    public int c;
    private String d;
    private String e;

    public c(b bVar) {
        this(bVar, false);
    }

    public c(b bVar, boolean z) {
        this.c = 0;
        this.d = "127.0.0.1";
        this.f89a = bVar;
        this.b = z;
        this.e = bVar.name();
    }

    @Override // a.c.b.z.f
    public String a() {
        return this.e;
    }

    public String a(String str) {
        int f2;
        StringBuilder sb = new StringBuilder();
        String a2 = a();
        if (a().equals(b.CUSTOM.name()) && (f2 = f()) != 0) {
            a2 = Integer.toString(f2);
        }
        return sb.append(this.b ? "S-" : "C-").append(str).append("-").append(a2).append("-").append(Thread.currentThread().getId()).toString();
    }

    public void a(int i) {
        if (this.f89a != b.CUSTOM) {
            throw new IllegalArgumentException("Can not set " + a() + " channel port to " + this.d);
        } else if (i != 0 || d()) {
            this.c = i;
        } else {
            throw new IllegalArgumentException("Can not set " + a() + " channel port to 0.");
        }
    }

    public void b(String str) {
        if (str != null) {
            this.e = str;
        }
    }

    @Override // a.c.b.z.f
    public String c() {
        return this.d;
    }

    public void c(String str) {
        if (str != null) {
            this.d = str;
        }
    }

    @Override // a.c.b.z.f
    public boolean d() {
        return this.b;
    }

    @Override // a.c.b.z.f
    public int f() {
        return this.c;
    }

    @Override // a.c.b.z.f
    public b g() {
        return this.f89a;
    }

    @Override // a.c.b.z.f
    public void i() {
        try {
            close();
        } catch (IOException e2) {
            k.a().a(f, "Close error: " + e2.getMessage(), e2);
        }
    }

    public abstract void j();

    public abstract void k();
}
