package org.snmp4j.agent.io;

import java.io.IOException;
import java.io.ObjectInputStream;
import org.snmp4j.log.LogAdapter;
import org.snmp4j.log.LogFactory;
import org.snmp4j.smi.Variable;

/* JADX INFO: loaded from: classes.dex */
public class DefaultMOInput implements MOInput {
    private static final LogAdapter logger = LogFactory.getLogger(DefaultMOInput.class);
    private int importMode;
    private ObjectInputStream ois;

    public DefaultMOInput(ObjectInputStream objectInputStream) {
        this.ois = objectInputStream;
    }

    @Override // org.snmp4j.agent.io.MOInput
    public void close() throws IOException {
        this.ois.close();
    }

    @Override // org.snmp4j.agent.io.MOInput
    public int getImportMode() {
        return this.importMode;
    }

    @Override // org.snmp4j.agent.io.MOInput
    public Context readContext() throws IOException {
        try {
            return (Context) this.ois.readObject();
        } catch (ClassNotFoundException e2) {
            logger.error("Failed to load Context: " + e2.getMessage());
            return null;
        }
    }

    @Override // org.snmp4j.agent.io.MOInput
    public IndexedVariables readIndexedVariables() throws IOException {
        try {
            return (IndexedVariables) this.ois.readObject();
        } catch (ClassNotFoundException e2) {
            logger.error("Failed to load IndexedVariables: " + e2.getMessage());
            return null;
        }
    }

    @Override // org.snmp4j.agent.io.MOInput
    public MOInfo readManagedObject() throws IOException {
        try {
            return (MOInfo) this.ois.readObject();
        } catch (ClassNotFoundException e2) {
            logger.error("Failed to load MOInfo: " + e2.getMessage());
            return null;
        }
    }

    @Override // org.snmp4j.agent.io.MOInput
    public Sequence readSequence() throws IOException {
        try {
            return (Sequence) this.ois.readObject();
        } catch (ClassNotFoundException e2) {
            logger.error("Failed to load Sequence: " + e2.getMessage());
            return null;
        }
    }

    @Override // org.snmp4j.agent.io.MOInput
    public Variable readVariable() throws IOException {
        try {
            return (Variable) this.ois.readObject();
        } catch (ClassNotFoundException e2) {
            logger.error("Failed to load Variable: " + e2.getMessage());
            return null;
        }
    }

    public void setOverwriteMode(int i2) {
        this.importMode = i2;
    }

    @Override // org.snmp4j.agent.io.MOInput
    public void skipContext(Context context) throws IOException {
        Object object;
        try {
            object = this.ois.readObject();
        } catch (ClassNotFoundException e2) {
            logger.error("Failed to skip Context: " + e2.getMessage());
            object = null;
        }
        while (true) {
            if ((object instanceof Context) && ((Context) object).equals(context)) {
                return;
            }
            try {
                object = this.ois.readObject();
            } catch (ClassNotFoundException e3) {
                logger.error("Failed to skip Context: " + e3.getMessage());
            }
        }
    }

    @Override // org.snmp4j.agent.io.MOInput
    public void skipManagedObject(MOInfo mOInfo) throws IOException {
        Object object;
        try {
            object = this.ois.readObject();
        } catch (ClassNotFoundException e2) {
            logger.error("Failed to skip Context: " + e2.getMessage());
            object = null;
        }
        while (true) {
            if ((object instanceof MOInfo) && ((MOInfo) object).equals(mOInfo)) {
                return;
            }
            try {
                object = this.ois.readObject();
            } catch (ClassNotFoundException e3) {
                logger.error("Failed to skip Context: " + e3.getMessage());
            }
        }
    }
}
