com.h3c.util.ip

## Class BigPortNumber

- 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.util.ip.BigPortNumber

- All Implemented Interfaces:
    Serializable, Comparable<BigPortNumber>

      public final class BigPortNumber
      extends U32Id
      implements Comparable<BigPortNumber>

  Represents a switch port number (unsigned 32-bit).

  All constructors for this class are private. Creating instances of `BigPortNumber` 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 port numbers is presented in an intuitive order.

  See Also:
    `PortNumber`, Serialized Form

- - ### Field Summary

    - ### 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(BigPortNumber o)` Implements the Comparable interface, to return port numbers in natural order.
    `static BigPortNumber` | `valueFrom(ByteBuffer buffer)` Reads 4 bytes from the specified byte buffer and creates a port number entity from their value.
    `static BigPortNumber` | `valueOf(byte[] bytes)` Returns an object that represents the port number defined by the specified byte array.
    `static BigPortNumber` | `valueOf(long port)` Returns an object that represents the big port number defined by the specified long.
    `static BigPortNumber` | `valueOf(String portStr)` Returns an object that represents the big port number 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, 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`

- - ### Method Detail

    - #### compareTo

          public int compareTo(BigPortNumber o)

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

    - #### valueOf

          public static BigPortNumber valueOf(long port)

      Returns an object that represents the big port number defined by the specified long.
      Parameters:
        `port` - the port number
      Returns:
        a BigPortNumber instance
      Throws:
        `IllegalArgumentException` - if the port number is invalid

    - #### valueOf

          public static BigPortNumber valueOf(String portStr)

      Returns an object that represents the big port number 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:
        `portStr` - the port number as a string
      Returns:
        a BigPortNumber instance
      Throws:
        `IllegalArgumentException` - if the string is invalid
        `NullPointerException` - if the string is null

    - #### valueOf

          public static BigPortNumber valueOf(byte[] bytes)

      Returns an object that represents the port number 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 BigPortNumber instance
      Throws:
        `NullPointerException` - if the byte array is null
        `IllegalArgumentException` - if the byte array is not 4 bytes long

    - #### valueFrom

          public static BigPortNumber valueFrom(ByteBuffer buffer)

      Reads 4 bytes from the specified byte buffer and creates a port number entity from their value.
      Parameters:
        `buffer` - byte buffer to get bytes from
      Returns:
        a port number instance
      Throws:
        `BufferUnderflowException` - the buffer does not have sufficient number of bytes remaining

Copyright © 2014. All Rights Reserved.