|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.snmp.snmp2.SnmpVar | +--com.adventnet.snmp.snmp2.SnmpOID
Class of SNMP Object ID - Sub-class of SnmpVar This class can be used to create an SnmpVar object of type OBJECT IDENTIFIER. It also has methods to retrieve the value in different forms(eg. String, byte array, int array, long array).
Some examples for valid OID are:
SnmpOID oid1 = new SnmpOID("1.1.0");
SnmpOID oid2 = new SnmpOID(".1.3.6.1.2.1.1.1.0");
An Invalid oid will be
SnmpOID oid3 = new SnmpOID(".iso.org.dod.internet.mgmt.mib-2.system.sysDescr");
as the argument will not accept names in the OID.
Note:
Since the constructor does not report about the invalidity of the
arguments, a better way to identify whether an SnmpOID is constructed
succesfully or not is:
SnmpOID oid4 = new SnmpOID("1.1.0");
if(oid4.toValue() != null)
{
System.out.println("SnmpOID successfully created");
}
else
{
System.out.println("There is some problem in
creating SnmpOID");
}
Constructor Summary | |
SnmpOID(int[] oid)
Constructs a new SnmpOID by taking an array of ints as an argument. |
|
SnmpOID(java.lang.String s)
Constructs a new SnmpOID which requires the argument to be a String OID of the form .N.N.N, or N.N.N. |
Method Summary | |
boolean |
equals(java.lang.Object anObject)
Compares this SnmpOID to the specified object. |
static SnmpOID |
getLexicographicallyFirstOID(SnmpOID[] oids)
The method finds the lexicographically first oid in the list of two oids given. |
static SnmpOID |
getLexicographicallyFirstOID(SnmpOID oid1,
SnmpOID oid2)
The method finds the lexicographically first oid in the list of two oids given. |
java.lang.String |
getNumericValueAsString()
This method will throw UnsupportedOperationException since this is not a numeric data type. |
java.lang.Object |
getVarObject()
Returns the value of this SnmpOID as a printable string. |
int |
hashCode()
Returns a hash code value for this SnmpOID. |
byte[] |
toBytes()
Returns the value of this SnmpOID as raw bytes. |
int[] |
toIntArray()
Returns the value of this SnmpOID value as an array of integers. |
long[] |
toLongArray()
Returns the value of this SnmpOID as an array of long. |
java.lang.String |
toString()
Converts the value of this SnmpOID object to a printable string used in printing. |
java.lang.String |
toTagString()
Converts the value of this SnmpOID object to a printable string where the type is tagged before the value with a tag "Object ID: ". |
java.lang.Object |
toValue()
Returns the value of this SnmpOID object as an array of ints. |
Methods inherited from class com.adventnet.snmp.snmp2.SnmpVar |
createVariable, getError, getType, getTypeString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SnmpOID(java.lang.String s)
s
- A String OID of the form .N.N.N, or N.N.N where N is a number and
not a name.public SnmpOID(int[] oid)
oid
- The array of int values representing the OID's
sub-identifiers.Method Detail |
public java.lang.Object toValue()
toValue
in class SnmpVar
public int[] toIntArray()
Returns the value of this SnmpOID value as an array of integers.
The number of subOIDs in the OID is limited to a maximum of 128. The
value of an OID component also ranges from 0 to 2**32 -1. That is,
it ranges from 0 to 4294967295. All the sub-identifiers that are
greater than 2147483647 will wrap around to the negative side of
the `int'.
example 1:
SnmpOID oid1 = new SnmpOID(".1.0");
int[] first_arr = oid1.toIntArray();
now this array will contain the following
first_arr[0] = 1
first_arr[1] = 0
example 2:
SnmpOID oid2 = new SnmpOID(".1.2147483647");
int[] second_arr = oid2.toIntArray();
now this array will contain the following
second_arr[0] = 1
second_arr[1] = 2147483647
example 3:
SnmpOID oid3 = new SnmpOID(".1.2147483648");
int[] third_arr = oid3.toIntArray();
now this array will contain the following
third_arr[0] = 1
third_arr[1] = -2147483648
If the sub-identifiers are greater than 2147483647 than "toLongArray"
can be used.
public long[] toLongArray()
public byte[] toBytes()
For example, if the oid is ".1.3.6", then the raw bytes will be rawBytes[0] = 0; rawBytes[1] = 0; rawBytes[2] = 0; rawBytes[3] = 1; rawBytes[4] = 0; rawBytes[5] = 0; rawBytes[6] = 0; rawBytes[7] = 3; rawBytes[8] = 0; rawBytes[9] = 0; rawBytes[10] = 0; rawBytes[11] = 6;
toBytes
in class SnmpVar
public static SnmpOID getLexicographicallyFirstOID(SnmpOID oid1, SnmpOID oid2)
oid1
- The SnmpOID for which the lexicographic order should be
foundoid2
- The SnmpOID for which the lexicographic order should be
found
public static SnmpOID getLexicographicallyFirstOID(SnmpOID[] oids)
oids
- The SnmpOID list in which the lexicographically first oid
should be found.
public java.lang.Object getVarObject()
getVarObject
in class SnmpVar
public java.lang.String toString()
toString
in class SnmpVar
public java.lang.String toTagString()
toTagString
in class SnmpVar
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object anObject)
true
only if the argument is not
null
and is an SnmpOID
object that represents
the same value as this object.
equals
in class java.lang.Object
anObject
- the object to compare this SnmpOID
against.
true
if the SnmpOIDs
are equal;
false
otherwise.public java.lang.String getNumericValueAsString()
getNumericValueAsString
in class SnmpVar
java.lang.UnsupportedOperationException
- Since this
is not a numeric data type.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |