package com.epson.lib.escani2;

public class ScanI2PropertyTaker {
    private int mEscanI2LibError = 0;

    public I2LibScannerInfoAndCapability getScannerInfoAndCapability(String str) {
        if (str == null || str.isEmpty()) {
            throw new IllegalArgumentException("ipAddress error");
        }
        I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability = new I2LibScannerInfoAndCapability();
        EscanI2Lib instance = EscanI2Lib.getInstance();
        int initializeLibrary = instance.initializeLibrary();
        if (initializeLibrary != 0) {
            mEscanI2LibError = initializeLibrary;
            return null;
        }
        try {
            int scanner = instance.setScanner(str);
            if (scanner != 0) {
                mEscanI2LibError = scanner;
                return null;
            }
            int scannerInfo = instance.getScannerInfo(i2LibScannerInfoAndCapability.scannerI2Info);
            if (scannerInfo != 0) {
                mEscanI2LibError = scannerInfo;
                instance.releaseLibrary();
                return null;
            }
            int capability = instance.getCapability(i2LibScannerInfoAndCapability.scannerI2Capability);
            if (capability != 0) {
                mEscanI2LibError = capability;
                instance.releaseLibrary();
                return null;
            }
            instance.releaseLibrary();
            return i2LibScannerInfoAndCapability;
        } finally {
            instance.releaseLibrary();
        }
    }

    public int getEscanI2LibError() {
        return mEscanI2LibError;
    }
}
