com.sun.management.snmp
Class SnmpOid

java.lang.Object
  extended by com.sun.management.snmp.SnmpValue
      extended by com.sun.management.snmp.SnmpOid
All Implemented Interfaces:
SnmpDataTypeEnums, Serializable, Cloneable
Direct Known Subclasses:
SnmpIpAddress

public class SnmpOid
extends SnmpValue

Represents an SNMP Object Identifier (OID).

Since:
Java DMK 5.1
See Also:
Serialized Form

Field Summary
protected  int componentCount
          The length of the components' array.
protected  long[] components
          The components' array.
 
Fields inherited from interface com.sun.management.snmp.SnmpDataTypeEnums
ApplFlag, BitStringTag, BooleanTag, Counter64Tag, CounterTag, CtxtFlag, errEndOfMibViewTag, errNoSuchInstanceTag, errNoSuchObjectTag, GaugeTag, IntegerTag, IpAddressTag, NsapTag, NullTag, ObjectIdentiferTag, ObjectIdentifierTag, OctetStringTag, OpaqueTag, SequenceTag, TableTag, TimeticksTag, UintegerTag, UnknownSyntaxTag
 
Constructor Summary
SnmpOid()
          Constructs a new SnmpOid with no components.
SnmpOid(long id)
          Constructs a new SnmpOid containing one component with the specified value.
SnmpOid(long[] oidComponents)
          Constructs a new SnmpOid from the specified component array.
SnmpOid(long id1, long id2, long id3, long id4)
          Constructs a new SnmpOid containing four components with the specified values.
SnmpOid(String s)
          Constructs a new SnmpOid from a dot-formatted String or a MIB variable name.
 
Method Summary
 void addToOid(long[] oid)
          Adds the specified array of longs to the end of this SnmpOid.
 void addToOid(String s)
          Adds the specified dot-formatted OID String to the end of this SnmpOid.
 void append(long id)
          Appends the specified long to the end of this SnmpOid.
 void append(SnmpOid oid)
          Appends the specified SnmpOid to the end of this SnmpOid.
static void appendToOid(SnmpOid source, SnmpOid dest)
          Appends an SnmpOid representing an SnmpOid to another OID.
 Object clone()
          Clones the SnmpOid object, making a copy of its data.
 int compareTo(SnmpOid other)
          Compares two OIDs lexicographically.
 SnmpValue duplicate()
          Performs a clone action.
 boolean equals(Object o)
          Checks whether the specified Object is equal to this SnmpOid.
 int getLength()
          Gets the number of components in this OID.
 long getOidArc(int pos)
          Returns the value of the OID arc found at the requested position in the components array.
static SnmpOidTable getSnmpOidTable()
          Returns the MIB table used for resolving MIB variable names.
 String getTypeName()
          Returns a textual description of the type object.
 int hashCode()
          The hashCode is computed from the OID components.
 void insert(int id)
          Inserts a subidentifier at the beginning of this SnmpOid.
 void insert(long id)
          Inserts a subidentifier at the beginning of this SnmpOid.
 boolean isValid()
          Checks the validity of the OID.
 long[] longValue()
          Returns a copy of the components array of this SnmpOid.
 long[] longValue(boolean duplicate)
          Returns the components array of this SnmpOid.
static int nextOid(long[] index, int start)
          Scans an index OID, skips the OID value and returns the position of the next value.
 String resolveVarName(String s)
          Resolves a MIB variable String with the MIB database.
static void setSnmpOidTable(SnmpOidTable db)
          Sets the MIB table to use for resolving MIB variable names.
 Boolean toBoolean()
          Converts the OID value to its Boolean form.
 Byte[] toByte()
          Converts the OID value to its array of Bytes form.
 Integer toInteger()
          Converts the OID value to its Integer form.
 Long toLong()
          Converts the OID value to its Long form.
 String toOctetString()
          Converts an OID index converted string back to a DisplayString
 SnmpOid toOid()
          Converts the OID value to its SnmpOid form.
static SnmpOid toOid(long[] index, int start)
          Extracts the OID from an index OID and returns its value converted as an SnmpOid.
 String toString()
          Converts the OID value to its String form.
 UnsignedLong toUnsignedLong()
           
 
Methods inherited from class com.sun.management.snmp.SnmpValue
isEndOfMibViewValue, isNoSuchInstanceValue, isNoSuchObjectValue, toAsn1String
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

components

protected long[] components
The components' array.


componentCount

protected int componentCount
The length of the components' array.

Constructor Detail

SnmpOid

public SnmpOid()
Constructs a new SnmpOid with no components.


SnmpOid

public SnmpOid(long[] oidComponents)
Constructs a new SnmpOid from the specified component array.

Parameters:
oidComponents - The initialization component array.

SnmpOid

public SnmpOid(long id)
Constructs a new SnmpOid containing one component with the specified value.

Parameters:
id - The initialization component value.

SnmpOid

public SnmpOid(long id1,
               long id2,
               long id3,
               long id4)
Constructs a new SnmpOid containing four components with the specified values.

Parameters:
id1 - The first component values.
id2 - The second component values.
id3 - The third component values.
id4 - The fourth component values.

SnmpOid

public SnmpOid(String s)
        throws IllegalArgumentException
Constructs a new SnmpOid from a dot-formatted String or a MIB variable name. It generates an exception if the variable name cannot be resolved, or if the dot-formatted String has an invalid subidentifier. This constructor helps build an OID object with a String like .1.2.3.4 or 1.2.3.4 or ifInOctets or ifInOctets.0.

Parameters:
s - String or MIB variable of the form .1.2.3 or 1.2.3 or ifInOctets.
Throws:
IllegalArgumentException - The subidentifier is neither a numeric String nor a String of the MIB database.
Method Detail

getLength

public int getLength()
Gets the number of components in this OID.

Returns:
The number of components.

longValue

public long[] longValue()
Returns a copy of the components array of this SnmpOid.

Returns:
The copy of the components array.

longValue

public final long[] longValue(boolean duplicate)
Returns the components array of this SnmpOid. If duplicate is true, a copy is returned. Otherwise, a reference to the internal array is returned, in which case the caller shall not modify this array. This method is provided to optimize processing in those cases where the caller needs only to read the components array.

Parameters:
duplicate - Indicates whether a copy or a reference must be returned:
  • true if a copy must be returned,
  • false if a reference on the internal data can be returned.
  • Returns:
    A copy of (or a reference on) the components array.

    getOidArc

    public final long getOidArc(int pos)
                         throws SnmpStatusException
    Returns the value of the OID arc found at the requested position in the components array. The first element is at position 0.

    Parameters:
    pos - The position at which the OID arc should be peeked.
    Returns:
    The OID arc found at the requested position.
    Throws:
    SnmpStatusException - No OID arc was found at the requested position.

    toUnsignedLong

    public UnsignedLong toUnsignedLong()

    toLong

    public Long toLong()
    Converts the OID value to its Long form.

    Returns:
    The Long representation of the value.

    toInteger

    public Integer toInteger()
    Converts the OID value to its Integer form.

    Returns:
    The Integer representation of the value.

    toString

    public String toString()
    Converts the OID value to its String form.

    Overrides:
    toString in class Object
    Returns:
    The String representation of the value.

    toBoolean

    public Boolean toBoolean()
    Converts the OID value to its Boolean form.

    Returns:
    The Boolean representation of the value.

    toByte

    public Byte[] toByte()
    Converts the OID value to its array of Bytes form.

    Returns:
    The array of Bytes representation of the value.

    toOid

    public SnmpOid toOid()
    Converts the OID value to its SnmpOid form.

    Specified by:
    toOid in class SnmpValue
    Returns:
    The OID representation of the value.

    toOid

    public static SnmpOid toOid(long[] index,
                                int start)
                         throws SnmpStatusException
    Extracts the OID from an index OID and returns its value converted as an SnmpOid.

    Parameters:
    index - The index array.
    start - The position in the index array.
    Returns:
    The OID representing the OID value.
    Throws:
    SnmpStatusException - There is no OID value available at the start position.

    nextOid

    public static int nextOid(long[] index,
                              int start)
                       throws SnmpStatusException
    Scans an index OID, skips the OID value and returns the position of the next value.

    Parameters:
    index - The index array.
    start - The position in the index array.
    Returns:
    The position of the next value.
    Throws:
    SnmpStatusException - There is no OID value available at the start position.

    appendToOid

    public static void appendToOid(SnmpOid source,
                                   SnmpOid dest)
    Appends an SnmpOid representing an SnmpOid to another OID.

    Parameters:
    source - An OID representing an SnmpOid value.
    dest - Where source should be appended.

    duplicate

    public final SnmpValue duplicate()
    Performs a clone action. This provides a workaround for the SnmpValue interface.

    Specified by:
    duplicate in class SnmpValue
    Returns:
    The SnmpValue clone.

    clone

    public Object clone()
    Clones the SnmpOid object, making a copy of its data.

    Overrides:
    clone in class Object
    Returns:
    The object clone.

    insert

    public void insert(long id)
    Inserts a subidentifier at the beginning of this SnmpOid.

    Parameters:
    id - The long subidentifier to insert.

    insert

    public void insert(int id)
    Inserts a subidentifier at the beginning of this SnmpOid.

    Parameters:
    id - The integer subidentifier to insert.

    append

    public void append(SnmpOid oid)
    Appends the specified SnmpOid to the end of this SnmpOid.

    Parameters:
    oid - The OID to append.

    append

    public void append(long id)
    Appends the specified long to the end of this SnmpOid.

    Parameters:
    id - The long to append.

    addToOid

    public void addToOid(String s)
                  throws SnmpStatusException
    Adds the specified dot-formatted OID String to the end of this SnmpOid. The subidentifiers can be expressed as a dot-formatted String or a MIB variable name.

    Parameters:
    s - Variable name of the form .1.2.3 or 1.2.3 or ifInOctets.
    Throws:
    SnmpStatusException - An error occurred while accessing a MIB node.

    addToOid

    public void addToOid(long[] oid)
                  throws SnmpStatusException
    Adds the specified array of longs to the end of this SnmpOid.

    Parameters:
    oid - An array of longs.
    Throws:
    SnmpStatusException - An error occurred while accessing a MIB node.

    isValid

    public boolean isValid()
    Checks the validity of the OID.

    Returns:
    true if the OID is valid, false otherwise.

    equals

    public boolean equals(Object o)
    Checks whether the specified Object is equal to this SnmpOid.

    Overrides:
    equals in class Object
    Parameters:
    o - The Object to be compared.
    Returns:
    true if o is an SnmpOid instance and equal to this, false otherwise.

    hashCode

    public int hashCode()
    The hashCode is computed from the OID components.

    Overrides:
    hashCode in class Object
    Returns:
    a hashCode for this SnmpOid.

    compareTo

    public int compareTo(SnmpOid other)
    Compares two OIDs lexicographically.

    Parameters:
    other - The OID to be compared.
    Returns:
    The value 0 if the parameter other is equal to this SnmpOid. A value smaller than 0 if this SnmpOid is lexicographically smaller than other. A value larger than 0 if this SnmpOid is lexicographically larger than other.

    resolveVarName

    public String resolveVarName(String s)
                          throws SnmpStatusException
    Resolves a MIB variable String with the MIB database.

    Parameters:
    s - The variable name to resolve.
    Throws:
    SnmpStatusException - If the variable is not found in the MIB database.

    getTypeName

    public String getTypeName()
    Returns a textual description of the type object.

    Specified by:
    getTypeName in class SnmpValue
    Returns:
    ASN.1 textual description.

    getSnmpOidTable

    public static SnmpOidTable getSnmpOidTable()
    Returns the MIB table used for resolving MIB variable names.

    Returns:
    The MIB table.

    setSnmpOidTable

    public static void setSnmpOidTable(SnmpOidTable db)
    Sets the MIB table to use for resolving MIB variable names. If no mib table is available, the class will not be able to resolve names contained in the Object Identifier.

    Parameters:
    db - The MIB table to use.

    toOctetString

    public String toOctetString()
    Converts an OID index converted string back to a DisplayString


    Open Source build 02
    opendmk-1.0-b02 2007.10.01_19:17:46_MEST

    Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.