net.percederberg.mibble.value

## Class ObjectIdentifierValue

- java.lang.Object
- - net.percederberg.mibble.MibValue
  - - net.percederberg.mibble.value.ObjectIdentifierValue

- All Implemented Interfaces:
    java.lang.Comparable<java.lang.Object>

      public class ObjectIdentifierValue
      extends MibValue

  An object identifier value. This class stores the component identifier values in a tree hierarchy.
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ObjectIdentifierValue(MibFileRef fileRef, ObjectIdentifierValue parent, java.lang.String name, int value)` Creates a new object identifier value.
    `ObjectIdentifierValue(MibFileRef fileRef, ValueReference parent, java.lang.String name, int value)` Creates a new object identifier value.
    `ObjectIdentifierValue(java.lang.String name, int value)` Creates a new root object identifier value.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `clear()` Clears and prepares this value for garbage collection.
    `int` | `compareTo(java.lang.Object obj)` Compares this object with the specified object for order.
    `MibValue` | `createReference()` Creates a value reference to this value.
    `boolean` | `equals(java.lang.Object obj)` Checks if this object equals another object.
    `ObjectIdentifierValue` | `find(java.lang.String oid)` Searches the OID tree for the best match.
    `ObjectIdentifierValue` | `findAncestor(java.lang.String oid)` Searches the OID tree for the best matching ancestor.
    `ObjectIdentifierValue` | `findDescendant(java.lang.String oid)` Searches the OID tree for the best matching descendant.
    `ObjectIdentifierValue[]` | `getAllChildren()` Returns an array of all child object identifier values.
    `ObjectIdentifierValue` | `getChild(int index)` Returns a child object identifier value.
    `ObjectIdentifierValue` | `getChildByName(java.lang.String name)` Returns a child object identifier value.
    `ObjectIdentifierValue` | `getChildByValue(int value)` Returns a child object identifier value.
    `int` | `getChildCount()` Returns the number of child object identifier values.
    `Mib` | `getMib()` Returns the MIB that this object identifier is connected to.
    `java.lang.String` | `getName()` Returns this object identifier component name.
    `ObjectIdentifierValue` | `getParent()` Returns the parent object identifier value.
    `int[]` | `getParentValues()` Returns an array of all the numeric values the OID chain.
    `MibValueSymbol` | `getSymbol()` Returns the symbol connected to this object identifier.
    `int` | `getValue()` Returns this object identifier component value.
    `int` | `hashCode()` Returns a hash code for this object.
    `MibValue` | `initialize(MibLoaderLog log, MibType type)` Initializes the MIB value.
    `void` | `setSymbol(MibValueSymbol symbol)` Sets the symbol connected to this object identifier.
    `java.lang.String` | `toAsn1String()` Returns an ASN.1 representation of this value.
    `java.lang.String` | `toDetailString()` Returns a detailed string representation of this value.
    `java.lang.Object` | `toObject()` Returns a string representation of this value.
    `java.lang.String` | `toString()` Returns a string representation of this value.

    - ### Methods inherited from class net.percederberg.mibble.MibValue

      `getReferenceSymbol, isReferenceTo, isReferenceTo, setReferenceSymbol`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ObjectIdentifierValue

          public ObjectIdentifierValue(java.lang.String name,
                               int value)

      Creates a new root object identifier value.
      Parameters:
        `name` - the component name, or null
        `value` - the component value

    - #### ObjectIdentifierValue

          public ObjectIdentifierValue(MibFileRef fileRef,
                               ObjectIdentifierValue parent,
                               java.lang.String name,
                               int value)
                                throws MibException

      Creates a new object identifier value.
      Parameters:
        `fileRef` - the definition MIB file reference
        `parent` - the component parent
        `name` - the component name, or null
        `value` - the component value
      Throws:
        `MibException` - if the object identifier parent already had a child with the specified value

    - #### ObjectIdentifierValue

          public ObjectIdentifierValue(MibFileRef fileRef,
                               ValueReference parent,
                               java.lang.String name,
                               int value)

      Creates a new object identifier value.
      Parameters:
        `fileRef` - the definition MIB file reference
        `parent` - the component parent
        `name` - the component name, or null
        `value` - the component value

  - ### Method Detail

    - #### initialize

          public MibValue initialize(MibLoaderLog log,
                            MibType type)
                              throws MibException

      Initializes the MIB value. This will remove all levels of indirection present, such as references to other values. No value information is lost by this operation. This method may modify this object as a side-effect, and will return the basic value.

      NOTE: This is an internal method that should only be called by the MIB loader.

      Specified by:
        `initialize` in class `MibValue`
      Parameters:
        `log` - the MIB loader log
        `type` - the value type
      Returns:
        the basic MIB value
      Throws:
        `MibException` - if an error was encountered during the initialization

    - #### createReference

          public MibValue createReference()

      Creates a value reference to this value. The value reference is normally an identical value. Only certain values support being referenced, and the default implementation of this method throws an exception.

      NOTE: This is an internal method that should only be called by the MIB loader.

      Overrides:
        `createReference` in class `MibValue`
      Returns:
        the MIB value reference
      Since:
        2.2

    - #### clear

          protected void clear()

      Clears and prepares this value for garbage collection. This method will recursively clear any associated types or values, making sure that no data structures references this object.

      NOTE: This is an internal method that should only be called by the MIB loader.

      Overrides:
        `clear` in class `MibValue`

    - #### compareTo

          public int compareTo(java.lang.Object obj)

      Compares this object with the specified object for order. This method will only attempt to compare each numerical OID part with the other value, but may fall back to comparing the string representations.
      Parameters:
        `obj` - the object to compare to
      Returns:
        less than zero if this object is less than the specified, zero if the objects are equal, or greater than zero otherwise
      Since:
        2.6

    - #### equals

          public boolean equals(java.lang.Object obj)

      Checks if this object equals another object. This method will compare the string representations for equality.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `obj` - the object to compare with
      Returns:
        true if the objects are equal, or false otherwise

    - #### hashCode

          public int hashCode()

      Returns a hash code for this object.
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        a hash code for this object

    - #### getParent

          public ObjectIdentifierValue getParent()

      Returns the parent object identifier value.
      Returns:
        the parent object identifier value, or null if no parent exists

    - #### getParentValues

          public int[] getParentValues()

      Returns an array of all the numeric values the OID chain. The root ancestor value is placed at index zero.
      Returns:
        an array of the numeric OID values
      Since:
        2.10

    - #### getName

          public java.lang.String getName()

      Returns this object identifier component name.
      Overrides:
        `getName` in class `MibValue`
      Returns:
        the object identifier component name, or null if the component has no name

    - #### getValue

          public int getValue()

      Returns this object identifier component value.
      Returns:
        the object identifier component value

    - #### getSymbol

          public MibValueSymbol getSymbol()

      Returns the symbol connected to this object identifier.
      Returns:
        the symbol connected to this object identifier, or null if no value symbol is connected

    - #### setSymbol

          public void setSymbol(MibValueSymbol symbol)

      Sets the symbol connected to this object identifier.

      NOTE: This is an internal method that should only be called by the MIB loader.

      Parameters:
        `symbol` - the value symbol

    - #### getMib

          public Mib getMib()

      Returns the MIB that this object identifier is connected to. This method simply returns the symbol MIB.
      Returns:
        the symbol MIB, or null if no symbol has been set
      Since:
        2.10

    - #### getChildCount

          public int getChildCount()

      Returns the number of child object identifier values.
      Returns:
        the number of child object identifier values

    - #### getChild

          public ObjectIdentifierValue getChild(int index)

      Returns a child object identifier value. The children are ordered by their value, not necessarily in the order in which they appear in the original MIB file.
      Parameters:
        `index` - the child position, starting from 0
      Returns:
        the child object identifier value, or null if not found

    - #### getChildByName

          public ObjectIdentifierValue getChildByName(java.lang.String name)

      Returns a child object identifier value. The children are searched by their component names. This method uses linear search and therefore has time complexity O(n). Note that most OID:s don't have a component name, but only an associated symbol.
      Parameters:
        `name` - the child name
      Returns:
        the child object identifier value, or null if not found
      Since:
        2.5

    - #### getChildByValue

          public ObjectIdentifierValue getChildByValue(int value)

      Returns a child object identifier value. The children are searched by their numerical value. This method uses binary search and therefore has time complexity O(log(n)) for the worst case. Special handling of the common case (a child array without numeric gaps), allow for O(1) performance most of the time.
      Parameters:
        `value` - the child value
      Returns:
        the child object identifier value, or null if not found
      Since:
        2.5

    - #### getAllChildren

          public ObjectIdentifierValue[] getAllChildren()

      Returns an array of all child object identifier values. The children are ordered by their value, not necessarily in the order in which they appear in the original MIB file.
      Returns:
        the child object identifier values
      Since:
        2.3

    - #### find

          public ObjectIdentifierValue find(java.lang.String oid)

      Searches the OID tree for the best match. The returned OID value may be either an ancestor or a descendant node (or this node itself). The search requires the full numeric OID value (from the root).
      Parameters:
        `oid` - the numeric OID string to search for
      Returns:
        the best matching OID value, or null if no partial match was found
      Since:
        2.10

    - #### findAncestor

          public ObjectIdentifierValue findAncestor(java.lang.String oid)

      Searches the OID tree for the best matching ancestor. The returned OID will be an exact match of this node or one of its parents. The search requires the full numeric OID value (from the root).
      Parameters:
        `oid` - the numeric OID string to search for
      Returns:
        the matching ancestor OID value, or null if no match was found
      Since:
        2.10

    - #### findDescendant

          public ObjectIdentifierValue findDescendant(java.lang.String oid)

      Searches the OID tree for the best matching descendant. The returned OID value will be the longest matching child node (or this node itself), but doesn't have to be an exact match. The search requires the full numeric OID value (from the root).
      Parameters:
        `oid` - the numeric OID string to search for
      Returns:
        the best matching descendant OID value, or null if no match was found
      Since:
        2.10

    - #### toObject

          public java.lang.Object toObject()

      Returns a string representation of this value. The string will contain the full numeric object identifier value with each component separated with a dot ('.').
      Specified by:
        `toObject` in class `MibValue`
      Returns:
        a string representation of this value

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this value. The string will contain the full numeric object identifier value with each component separated with a dot ('.').
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of this value

    - #### toDetailString

          public java.lang.String toDetailString()

      Returns a detailed string representation of this value. The string will contain the full numeric object identifier value with optional names for each component.
      Returns:
        a detailed string representation of this value

    - #### toAsn1String

          public java.lang.String toAsn1String()

      Returns an ASN.1 representation of this value. The string will contain references to any parent OID value that can be found.
      Returns:
        an ASN.1 representation of this value
      Since:
        2.6