public final class IpProtocol extends CacheableDataType implements Comparable<IpProtocol>
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.
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.
|
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.
|
getRefQ, keyFromBytes
public static final IpProtocol TCP
public static final IpProtocol UDP
public static final IpProtocol SCTP
public static final IpProtocol ICMP
public static final IpProtocol ICMPv6
public String toString()
public String getName()
public String getShortName()
public int getNumber()
public boolean isUnknown()
public int compareTo(IpProtocol o)
compareTo
in interface Comparable<IpProtocol>
o
- the other IP Protocol instanceComparable.compareTo(T)
public static IpProtocol valueOf(String value)
IpProtocol tcpProto = IpProtocol.valueOf("tcp"); String s = tcpProto.getName(); // "TCP : Transmission Control Protocol" IpProtocol tcpAlso = IpProtocol.valueOf(s); assert tcpAlso.equals(tcpProto);
value
- the protocol identifierpublic static IpProtocol valueOf(int protocolNumber)
protocolNumber
- the IP Protocol numberIllegalArgumentException
- if the parameter is < 0 or > 255Copyright © 2015. All Rights Reserved.