com.h3c.util.ip

## Class U16Id

- java.lang.Object
- - com.h3c.util.cache.CacheableDataType
  - - com.h3c.util.ip.UnsignedId
    - - com.h3c.util.ip.UnsignedIntBasedId
      - - com.h3c.util.ip.U16Id

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    PortNumber, VId

      public abstract class U16Id
      extends UnsignedIntBasedId

  A base class for unsigned 16-bit identifiers.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `E_BYTES_BAD_LEN` Error message when byte array is incorrect length.
    `static int` | `LENGTH_IN_BYTES` Length of the identifier when encoded as a byte array.
    `static int` | `MAX_VALUE` Highest valid value.

    - ### Fields inherited from class com.h3c.util.ip.UnsignedIntBasedId

      `id`

    - ### Fields inherited from class com.h3c.util.ip.UnsignedId

      `E_BAD, E_NULL_BYTES, E_NULL_STR, E_OOR, MIN_VALUE`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `U16Id(int id)` Constructs the id.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static void` | `rangeCheck(int value)` Ensures that the given value is within range.
    `byte[]` | `toByteArray()` Returns this id as a 2-byte array.

    - ### Methods inherited from class com.h3c.util.ip.UnsignedIntBasedId

      `equals, hashCode, toInt, toString`

    - ### Methods inherited from class com.h3c.util.ip.UnsignedId

      `parseIntStr, parseLongStr`

    - ### Methods inherited from class com.h3c.util.cache.CacheableDataType

      `getRefQ, keyFromBytes`

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

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

- - ### Field Detail

    - #### MAX_VALUE

          public static final int MAX_VALUE

      Highest valid value.
      See Also:
        Constant Field Values

    - #### LENGTH_IN_BYTES

          public static final int LENGTH_IN_BYTES

      Length of the identifier when encoded as a byte array.
      See Also:
        Constant Field Values

    - #### E_BYTES_BAD_LEN

          protected static final String E_BYTES_BAD_LEN

      Error message when byte array is incorrect length.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### U16Id

          protected U16Id(int id)

      Constructs the id.
      Parameters:
        `id` - the id value

  - ### Method Detail

    - #### toByteArray

          public byte[] toByteArray()

      Returns this id as a 2-byte array. Note that the bytes are in Network order; i.e. the most significant byte is at index zero.
      Returns:
        the id as a byte array

    - #### rangeCheck

          protected static void rangeCheck(int value)

      Ensures that the given value is within range. If it is, the method returns silently; if not, an exception is thrown.
      Parameters:
        `value` - the value to check
      Throws:
        `IllegalArgumentException` - if the value is out of range

Copyright © 2014. All Rights Reserved.