Package com.activequant.utils.snmp

Source Code of com.activequant.utils.snmp.MOScalarFactory

package com.activequant.utils.snmp;

import org.snmp4j.agent.mo.MOAccessImpl;
import org.snmp4j.agent.mo.MOScalar;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;

class MOScalarFactory {

    static MOScalar createReadOnly(OID oid, Object value) {
        return new MOScalar(oid, MOAccessImpl.ACCESS_READ_ONLY, getVariable(value));
    }

    private static Variable getVariable(Object value) {
        if (value instanceof String) {
            return new OctetString((String) value);
        }
        throw new IllegalArgumentException("Unmanaged Type: " + value.getClass());
    }
}
TOP

Related Classes of com.activequant.utils.snmp.MOScalarFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.