NumberValue (Mibble 2.9.4 Documentation)
Date: 2016-09-27

net.percederberg.mibble.value

## Class NumberValue

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

- All Implemented Interfaces:
    java.lang.Comparable
  Direct Known Subclasses:
    BinaryNumberValue, HexNumberValue

      public class NumberValue
      extends MibValue

  A numeric MIB value.
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NumberValue(java.lang.Number value)` Creates a new number value.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `protected int` | `getByteSize(MibType type, int initialBytes)` Returns the number of bytes required by the specified type and initial value size.
    `int` | `hashCode()` Returns a hash code for this object.
    `MibValue` | `initialize(MibLoaderLog log, MibType type)` Initializes the MIB value.
    `java.lang.Object` | `toObject()` Returns a Java Number representation of this value.
    `java.lang.String` | `toString()` Returns a string representation of this value.

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

      `clear, getName, getReferenceSymbol, isReferenceTo, isReferenceTo, setReferenceSymbol`

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

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

- - ### Constructor Detail

    - #### NumberValue

          public NumberValue(java.lang.Number value)

      Creates a new number value.
      Parameters:
        `value` - the number value

  - ### Method Detail

    - #### initialize

          public MibValue initialize(MibLoaderLog log,
                                     MibType type)

      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

    - #### 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

    - #### compareTo

          public int compareTo(java.lang.Object obj)

      Compares this object with the specified object for order. This method will attempt to compare by numerical value, but will use a string comparison as the default comparison operation.
      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

    - #### toObject

          public java.lang.Object toObject()

      Returns a Java Number representation of this value.
      Specified by:
        `toObject` in class `MibValue`
      Returns:
        a Java Number representation of this value

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this value.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of this value

    - #### getByteSize

          protected int getByteSize(MibType type,
                                    int initialBytes)

      Returns the number of bytes required by the specified type and initial value size. If the type has no size requirement specified, a value of one (1) will always be returned. If the type size constraint allows for zero length, a zero might also be returned.
      Parameters:
        `type` - the MIB value type
        `initialBytes` - the initial number of bytes used
      Returns:
        the number of bytes required