com.h3c.util.ip

## Class IpProtocol

- java.lang.Object
- - com.h3c.util.cache.CacheableDataType
  - - com.h3c.util.ip.IpProtocol

- All Implemented Interfaces:
    Serializable, Comparable<IpProtocol>

      public final class IpProtocol
      extends CacheableDataType
      implements Comparable<IpProtocol>

  Represents an IP Protocol.

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

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

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

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

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static IpProtocol` | `ICMP` The instance representing ICMP.
    `static IpProtocol` | `ICMPv6` The instance representing ICMPv6.
    `static IpProtocol` | `SCTP` The instance representing SCTP.
    `static IpProtocol` | `TCP` The instance representing TCP.
    `static IpProtocol` | `UDP` The instance representing UDP.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(IpProtocol o)` Implements the Comparable interface, to return protocols in natural order.
    `boolean` | `equals(Object o)`
    `String` | `getName()` Returns the descriptive name of the protocol.
    `int` | `getNumber()` Returns the protocol number.
    `String` | `getShortName()` Returns the short name of the protocol.
    `int` | `hashCode()`
    `boolean` | `isUnknown()` Returns true if the protocol number is not one of the "named" protocols.
    `String` | `toString()` Returns a string describing the IP Protocol.
    `static IpProtocol` | `valueOf(int protocolNumber)` Returns an object that represents the value of the IP Protocol identified by the specified protocol number.
    `static IpProtocol` | `valueOf(String value)` Returns an object that represents the value of the IP Protocol identified by the specified string.

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

    - #### TCP

          public static final IpProtocol TCP

      The instance representing TCP.

    - #### UDP

          public static final IpProtocol UDP

      The instance representing UDP.

    - #### SCTP

          public static final IpProtocol SCTP

      The instance representing SCTP.

    - #### ICMP

          public static final IpProtocol ICMP

      The instance representing ICMP.

    - #### ICMPv6

          public static final IpProtocol ICMPv6

      The instance representing ICMPv6.

  - ### Method Detail

    - #### toString

          public String toString()

      Returns a string describing the IP Protocol.
      Overrides:
        `toString` in class `Object`
      Returns:
        the protocol number and name

    - #### getName

          public String getName()

      Returns the descriptive name of the protocol. E.g. "TCP : Transmission Control Protocol"
      Returns:
        the descriptive name

    - #### getShortName

          public String getShortName()

      Returns the short name of the protocol. E.g. "TCP"
      Returns:
        the short name

    - #### getNumber

          public int getNumber()

      Returns the protocol number.
      Returns:
        the protocol number

    - #### isUnknown

          public boolean isUnknown()

      Returns true if the protocol number is not one of the "named" protocols. More specifically, the protocol is not defined in the ipProtocols resource bundle.
      Returns:
        true if unknown

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### compareTo

          public int compareTo(IpProtocol o)

      Implements the Comparable interface, to return protocols in natural order.
      Specified by:
        `compareTo` in interface `Comparable<IpProtocol>`
      Parameters:
        `o` - the other IP Protocol instance
      Returns:
        an integer value indicating relative ordering
      See Also:
        `Comparable.compareTo(T)`

    - #### valueOf

          public static IpProtocol valueOf(String value)

      Returns an object that represents the value of the IP Protocol identified by the specified string. For example:

             IpProtocol tcpProto = IpProtocol.valueOf("tcp");
             String s = tcpProto.getName(); // "TCP : Transmission Control Protocol"
             IpProtocol tcpAlso = IpProtocol.valueOf(s);
             assert tcpAlso.equals(tcpProto);

      Parameters:
        `value` - the protocol identifier
      Returns:
        an object representing the specified protocol

    - #### valueOf

          public static IpProtocol valueOf(int protocolNumber)

      Returns an object that represents the value of the IP Protocol identified by the specified protocol number.
      Parameters:
        `protocolNumber` - the IP Protocol number
      Returns:
        an object representing the specified protocol
      Throws:
        `IllegalArgumentException` - if the parameter is < 0 or > 255

Copyright © 2014. All Rights Reserved.