com.h3c.of.lib.dt

## Class BufferId

- java.lang.Object
- - com.h3c.util.cache.CacheableDataType
  - - com.h3c.util.ip.UnsignedId
    - - com.h3c.util.ip.UnsignedLongBasedId
      - - com.h3c.util.ip.U32Id
        - - com.h3c.of.lib.dt.BufferId

- All Implemented Interfaces:
    Serializable, Comparable<BufferId>

      public final class BufferId
      extends U32Id
      implements Comparable<BufferId>

  Represents a buffer identifier (unsigned 32-bit) assigned by datapath.

  All constructors for this class are private. Creating instances of `BufferId` is done via the static methods on the class.

  Instances of this class are immutable, making them inherently threadsafe.

  This class overrides `UnsignedLongBasedId.equals(java.lang.Object)` and `UnsignedLongBasedId.hashCode()` so that instances play nicely with the Collection classes.

  This class implements the `Comparable` interface to ensure that a sorted list of buffer IDs is presented in an intuitive order.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static BufferId` | `NO_BUFFER` Denotes no buffer available on the switch.

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

      `E_BYTES_BAD_LEN, LENGTH_IN_BYTES, MAX_VALUE`

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

      `id`

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

      `E_BAD, E_NULL_BYTES, E_NULL_STR, E_OOR, MIN_VALUE`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(BufferId o)` Implements the Comparable interface, to return buffer ids in natural order.
    `String` | `toString()` Returns a string representation of this id.
    `static BufferId` | `valueOf(byte[] bytes)` Returns an object that represents the buffer identifier defined by the specified byte array.
    `static BufferId` | `valueOf(long bid)` Returns an object that represents the buffer id defined by the specified long.
    `static BufferId` | `valueOf(String bidStr)` Returns an object that represents the buffer id defined by the specified string.

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

      `rangeCheck, toByteArray`

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

      `equals, hashCode, toLong`

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

    - #### NO_BUFFER

          public static final BufferId NO_BUFFER

      Denotes no buffer available on the switch.

  - ### Method Detail

    - #### toString

          public String toString()

      Description copied from class: `UnsignedLongBasedId`
      Returns a string representation of this id. This default implementation expresses the value as a hex number, beginning with "0x...".
      Overrides:
        `toString` in class `UnsignedLongBasedId`
      Returns:
        the id, as a string

    - #### compareTo

          public int compareTo(BufferId o)

      Implements the Comparable interface, to return buffer ids in natural order.
      Specified by:
        `compareTo` in interface `Comparable<BufferId>`
      Parameters:
        `o` - the other buffer id
      Returns:
        an integer value indicating relative ordering
      See Also:
        `Comparable.compareTo(T)`

    - #### valueOf

          public static BufferId valueOf(long bid)

      Returns an object that represents the buffer id defined by the specified long.
      Parameters:
        `bid` - the buffer id
      Returns:
        a BufferId instance
      Throws:
        `IllegalArgumentException` - if the buffer id is invalid

    - #### valueOf

          public static BufferId valueOf(String bidStr)

      Returns an object that represents the buffer id defined by the specified string. The string is parsed as a base-10 integer, unless it has a "0x" prefix, in which case it is parsed as a hex number.
      Parameters:
        `bidStr` - the buffer id as a string
      Returns:
        a BufferId instance
      Throws:
        `IllegalArgumentException` - if the string is invalid
        `NullPointerException` - if the string is null

    - #### valueOf

          public static BufferId valueOf(byte[] bytes)

      Returns an object that represents the buffer identifier defined by the specified byte array. The array is expected to be `U32Id.LENGTH_IN_BYTES` bytes long.
      Parameters:
        `bytes` - the encoded id
      Returns:
        a BufferId instance
      Throws:
        `NullPointerException` - if the byte array is null
        `IllegalArgumentException` - if the byte array is not 4 bytes long

Copyright © 2014. All Rights Reserved.