package org.snmp4j.util;

import java.util.Arrays;
import java.util.EventListener;
import java.util.EventObject;
import org.snmp4j.PDU;
import org.snmp4j.event.ResponseListener;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.util.TreeUtils;

/* JADX INFO: loaded from: classes.dex */
public abstract class RetrievalEvent extends EventObject {
    public static final int STATUS_EXCEPTION = -4;
    public static final int STATUS_OK = 0;
    public static final int STATUS_REPORT = -3;
    public static final int STATUS_TIMEOUT = -1;
    public static final int STATUS_WRONG_ORDER = -2;
    protected Exception exception;
    protected PDU reportPDU;
    protected int status;
    protected Object userObject;
    protected VariableBinding[] vbs;

    protected RetrievalEvent(EventListener eventListener, Object obj) {
        super(eventListener);
        this.status = 0;
        this.userObject = obj;
    }

    public String getErrorMessage() {
        int i2 = this.status;
        if (i2 == -4) {
            return this.exception.getMessage();
        }
        if (i2 != -3) {
            return i2 != -2 ? i2 != -1 ? PDU.toErrorStatusText(i2) : "Request timed out." : "Agent did not return variable bindings in lexicographic order.";
        }
        return "Report: " + this.reportPDU.get(0);
    }

    public Exception getException() {
        return this.exception;
    }

    public PDU getReportPDU() {
        return this.reportPDU;
    }

    public int getStatus() {
        return this.status;
    }

    public Object getUserObject() {
        return this.userObject;
    }

    public boolean isError() {
        return this.status != 0;
    }

    @Override // java.util.EventObject
    public String toString() {
        String str;
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getName());
        sb.append("[vbs=");
        if (this.vbs == null) {
            str = "null";
        } else {
            str = "" + Arrays.asList(this.vbs);
        }
        sb.append(str);
        sb.append(",status=");
        sb.append(this.status);
        sb.append(",exception=");
        sb.append(this.exception);
        sb.append(",report=");
        sb.append(this.reportPDU);
        sb.append("]");
        return sb.toString();
    }

    public RetrievalEvent(TreeUtils.TreeRequest treeRequest, Object obj, int i2) {
        this(treeRequest, obj);
        this.status = i2;
    }

    public RetrievalEvent(TreeUtils.TreeRequest treeRequest, Object obj, Exception exc) {
        this(treeRequest, obj);
        this.exception = exc;
        this.status = -4;
    }

    public RetrievalEvent(TreeUtils.TreeRequest treeRequest, Object obj, PDU pdu) {
        this(treeRequest, obj);
        this.reportPDU = pdu;
        this.status = -3;
    }

    public RetrievalEvent(ResponseListener responseListener, Object obj, VariableBinding[] variableBindingArr) {
        this(responseListener, obj);
        this.vbs = variableBindingArr;
    }
}
