| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | 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 SnmpOID. 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:
 
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.  | 
 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 OIDs.| Method Detail | 
public java.lang.Object toValue()
toValue in class SnmpVarpublic 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] = 2147483647
 
 
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()
toBytes in class SnmpVarpublic java.lang.Object getVarObject()
getVarObject in class SnmpVarpublic java.lang.String toString()
toString in class SnmpVarpublic java.lang.String toTagString()
toTagString in class SnmpVarpublic int hashCode()
hashCode in class java.lang.Objectpublic 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.ObjectanObject - the object to compare this SnmpOID
 against.true if the SnmpOIDs are equal;
 false otherwise.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||