|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.snmp4j.smi.AbstractVariable
org.snmp4j.smi.OID
public class OID
The Object Identifier Class.
The Object Identifier (OID) class is the encapsulation of an
SMI object identifier. The SMI object is a data identifier for a
data element found in a Management Information Base (MIB), as
defined by a MIB definition. The OID class allows definition and
manipulation of object identifiers.
| Field Summary | |
|---|---|
static int |
MAX_OID_LEN
|
static int |
MAX_SUBID_VALUE
|
| Fields inherited from class org.snmp4j.smi.AbstractVariable |
|---|
SMISYNTAXES_PROPERTIES |
| Constructor Summary | |
|---|---|
OID()
Constructs a zero length OID. |
|
OID(int[] rawOID)
Constructs an OID from an array of integer values. |
|
OID(int[] prefixOID,
int[] suffixOID)
Constructs an OID from two arrays of integer values where
the first represents the OID prefix (i.e., the object class ID) and
the second one represents the OID suffix (i.e., the instance identifier). |
|
OID(int[] rawOID,
int offset,
int length)
Constructs an OID from an array of integer values. |
|
OID(OID other)
Copy constructor. |
|
OID(java.lang.String oid)
Constructs an OID from a dotted string. |
|
| Method Summary | |
|---|---|
void |
append(int subID)
Appends a sub-identifier to this OID. |
void |
append(OID oid)
Appends an OID to this OID. |
void |
append(java.lang.String oid)
Appends a dotted String OID to this OID. |
void |
appendUnsigned(long subID)
Appends an unsigned long sub-identifier value to this OID. |
java.lang.Object |
clone()
Clones this variable. |
int |
compareTo(java.lang.Object o)
|
void |
decodeBER(BERInputStream inputStream)
Decodes a Variable from an InputStream. |
void |
encodeBER(java.io.OutputStream outputStream)
Encodes a Variable to an OutputStream. |
boolean |
equals(java.lang.Object o)
|
void |
fromSubIndex(OID subIndex,
boolean impliedLength)
Sets the value of this Variable from the supplied (sub-)index. |
int |
get(int index)
Gets the sub-identifier value at the specified position. |
int |
getBERLength()
Returns the length of this Variable in bytes when encoded
according to the Basic Encoding Rules (BER). |
int |
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable. |
long |
getUnsigned(int index)
Gets the unsigned sub-identifier value at the specified position. |
int[] |
getValue()
Gets all sub-identifiers as an int array. |
int |
hashCode()
|
boolean |
isValid()
Checks whether this OID can be BER encoded. |
int |
last()
Returns the last sub-identifier as an integer value. |
long |
lastUnsigned()
Returns the last sub-identifier as an unsigned long value. |
int |
leftMostCompare(int n,
OID other)
Compares the n leftmost sub-identifiers with the given OID
in left-to-right direction. |
OID |
mask(OctetString mask)
Returns a copy of this OID where sub-identifiers have been set to zero for all n-th sub-identifier where the n-th bit of mask is zero. |
static OID |
max(OID a,
OID b)
Returns the greater of the two OID values. |
static OID |
min(OID a,
OID b)
Returns the lesser of the two OID values. |
OID |
nextPeer()
Returns the next following OID with the same or lesser size (length). |
OID |
predecessor()
Returns the predecessor OID for this OID. |
int |
removeLast()
Removes the last sub-identifier (if available) from this OID
and returns it. |
int |
rightMostCompare(int n,
OID other)
Compares the n rightmost sub-identifiers in direction right-to-left with those of the given OID. |
void |
set(int index,
int value)
Sets the sub-identifier at the specified position. |
void |
setValue(int[] value)
Sets the value from an array of integer values. |
void |
setValue(java.lang.String value)
|
int |
size()
Returns the number of sub-identifiers in this OID. |
boolean |
startsWith(OID other)
Check if the OID starts with the given OID. |
OID |
successor()
Returns the successor OID for this OID. |
byte[] |
toByteArray()
Returns the content of the as a byte array. |
int |
toInt()
Returns an integer representation of this variable if such a representation exists. |
int[] |
toIntArray()
Returns the value of this object as an int array. |
long |
toLong()
Returns a long representation of this variable if such a representation exists. |
java.lang.String |
toString()
Gets a string representation of the variable. |
OID |
toSubIndex(boolean impliedLength)
Converts the value of this Variable to a (sub-)index
value. |
void |
trim(int n)
Remove the n rightmost subidentifiers from this OID. |
| Methods inherited from class org.snmp4j.smi.AbstractVariable |
|---|
createFromBER, createFromSyntax, getBERPayloadLength, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_OID_LEN
public static final int MAX_SUBID_VALUE
| Constructor Detail |
|---|
public OID()
public OID(java.lang.String oid)
OID from a dotted string. The string can contain
embedded strings enclosed by a single quote (') that are converted to
the corresponding OIO value. For example the following OID pairs are equal:
OID a = new OID("1.3.6.2.1.5.'hallo'.1");
OID b = new OID("1.3.6.2.1.5.104.97.108.108.111.1");
assertEquals(a, b);
a = new OID("1.3.6.2.1.5.'hal.lo'.1");
b = new OID("1.3.6.2.1.5.104.97.108.46.108.111.1");
assertEquals(a, b);
a = new OID("1.3.6.2.1.5.'hal.'.'''.'lo'.1");
b = new OID("1.3.6.2.1.5.104.97.108.46.39.108.111.1");
oid - a dotted OID String, for example "1.3.6.1.2.2.1.0"public OID(int[] rawOID)
OID from an array of integer values.
rawOID - an array of int values. The array
is copied. Later changes to rawOID will therefore not
affect the OID's value.
public OID(int[] prefixOID,
int[] suffixOID)
OID from two arrays of integer values where
the first represents the OID prefix (i.e., the object class ID) and
the second one represents the OID suffix (i.e., the instance identifier).
prefixOID - an array of int values. The array
is copied. Later changes to prefixOID will therefore not
affect the OID's value.suffixOID - an array of int values which will be appended to the
prefixOID OID. The array is copied. Later changes to
suffixOID will therefore not affect the OID's value.
public OID(int[] rawOID,
int offset,
int length)
OID from an array of integer values.
rawOID - an array of int values. The array
is copied. Later changes to rawOID will therefore not
affect the OID's value.offset - the zero based offset into the rawOID that points to the
first sub-identifier of the new OID.length - the length of the new OID, where offset + length must be
less or equal the length of rawOID. Otherwise an
IndexOutOfBoundsException is thrown.public OID(OID other)
other - OID| Method Detail |
|---|
public final int getSyntax()
AbstractVariable
getSyntax in interface VariablegetSyntax in class AbstractVariablepublic int hashCode()
hashCode in interface VariablehashCode in class AbstractVariablepublic final boolean equals(java.lang.Object o)
equals in interface Variableequals in class AbstractVariablepublic OID mask(OctetString mask)
mask - a mask where the n-th bit corresponds to the n-th sub-identifier.
public final int compareTo(java.lang.Object o)
compareTo in interface java.lang.ComparablecompareTo in interface VariablecompareTo in class AbstractVariablepublic java.lang.String toString()
AbstractVariable
toString in interface VariabletoString in class AbstractVariablepublic byte[] toByteArray()
OctetString or
IpAddress instance.
OID as a byte array. Each
sub-identifier value is masked with 0xFF to form a byte value.
public void encodeBER(java.io.OutputStream outputStream)
throws java.io.IOException
AbstractVariableVariable to an OutputStream.
encodeBER in interface BERSerializableencodeBER in class AbstractVariableoutputStream - an OutputStream.
java.io.IOException - if an error occurs while writing to the stream.public int getBERLength()
AbstractVariableVariable in bytes when encoded
according to the Basic Encoding Rules (BER).
getBERLength in interface BERSerializablegetBERLength in class AbstractVariable
public void decodeBER(BERInputStream inputStream)
throws java.io.IOException
AbstractVariableVariable from an InputStream.
decodeBER in interface BERSerializabledecodeBER in class AbstractVariableinputStream - an InputStream containing a BER encoded byte stream.
java.io.IOException - if the stream could not be decoded by using BER rules.public void setValue(java.lang.String value)
setValue in interface AssignableFromStringpublic final void setValue(int[] value)
setValue in interface AssignableFromIntArrayvalue - The new value
java.lang.IllegalArgumentException - if value == null.public final int[] getValue()
public final int get(int index)
index - a zero-based index into the OID.
index. NOTE: The returned
value may be negative if the sub-identifier value is greater than
2^31.
java.lang.ArrayIndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).public final long getUnsigned(int index)
index - int
index as an unsigned long
value.
public final void set(int index,
int value)
index - a zero-based index into the OID.value - a 32bit unsigned integer value.
java.lang.ArrayIndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).public final void append(java.lang.String oid)
OID.
oid - a dotted String with numerical sub-identifiers.public final void append(OID oid)
OID to this OID.
oid - an OID instance.public final void append(int subID)
subID - an integer value.public final void appendUnsigned(long subID)
subID - an unsigned long value less or equal to 2^32-1.public boolean isValid()
OID can be BER encoded.
true if size() >= 2 and size() <= 128 and if the first
two sub-identifiers are less than 3 and 40 respectively.public final int size()
OID.
public int leftMostCompare(int n,
OID other)
OID
in left-to-right direction.
n - the number of sub-identifiers to compare.other - an OID to compare with this OID.
n sub-identifiers are the same.
n sub-identifiers of this
OID are lexicographic less than those of the comparand.
n sub-identifiers of this
OID are lexicographic greater than those of the comparand.
public int rightMostCompare(int n,
OID other)
OID.
n - the number of sub-identifiers to compare.other - an OID to compare with this OID.
n sub-identifiers are the same.
n sub-identifiers of this
OID are lexicographic less than those of the comparand.
n sub-identifiers of this
OID are lexicographic greater than those of the comparand.
public boolean startsWith(OID other)
other - the OID to compare to
public java.lang.Object clone()
Variable
clone in interface Variableclone in class AbstractVariableVariable with the same value.public final int last()
NoSuchElementException is thrown
public final long lastUnsigned()
NoSuchElementException is thrown
public int removeLast()
OID
and returns it.
OID.public void trim(int n)
n - the number of subidentifiers to remove. If n is zero or
negative then this OID will not be changed. If n is greater
than size() all subidentifiers will be removed from this OID.public int toInt()
AbstractVariable
toInt in interface VariabletoInt in class AbstractVariablepublic long toLong()
AbstractVariable
toLong in interface VariabletoLong in class AbstractVariablepublic final OID toSubIndex(boolean impliedLength)
AbstractVariableVariable to a (sub-)index
value.
toSubIndex in interface VariabletoSubIndex in class AbstractVariableimpliedLength - specifies if the sub-index has an implied length. This parameter applies
to variable length variables only (e.g. OctetString and
OID). For other variables it has no effect.
public final void fromSubIndex(OID subIndex,
boolean impliedLength)
AbstractVariableVariable from the supplied (sub-)index.
fromSubIndex in interface VariablefromSubIndex in class AbstractVariablesubIndex - the sub-index OID.impliedLength - specifies if the sub-index has an implied length. This parameter applies
to variable length variables only (e.g. OctetString and
OID). For other variables it has no effect.public final OID successor()
public final OID predecessor()
MAX_OID_LEN
sub-identifier OID is returned where each sub-ID for index greater
or equal to size() is set to MAX_SUBID_VALUE.public final OID nextPeer()
public static final OID max(OID a,
OID b)
a - an OID.b - an OID.
a if a >= b, b otherwise.
public static final OID min(OID a,
OID b)
a - an OID.b - an OID.
a if a <= b, b otherwise.public int[] toIntArray()
AssignableFromIntArray
toIntArray in interface AssignableFromIntArray
|
Copyright 2003-2009 Frank Fock and Jochen Katz (SNMP4J.org) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||