public final class TcpUdpPort extends CacheableDataType implements Comparable<TcpUdpPort>
All constructors for this class are private. Creating instances
of WellKnownPort
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 ports is presented in an intuitive order.
Modifier and Type | Field and Description |
---|---|
static TcpUdpPort |
UNDETERMINED_TCP
A value representing an undetermined TCP port.
|
static TcpUdpPort |
UNDETERMINED_UDP
A value representing an undetermined UDP port.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TcpUdpPort o)
Implements the Comparable interface, to return ports in a natural order.
|
boolean |
equals(Object o) |
String |
getName()
Returns the descriptive name of the port.
|
int |
getNumber()
Returns the port number.
|
IpProtocol |
getProtocol()
Returns the IP Protocol.
|
String |
getProtocolName()
Returns the short name of the protocol in lowercase.
|
String |
getShortName()
Returns the short name of the port.
|
int |
hashCode() |
boolean |
isUndetermined()
Returns true if this instance of port number
represents an "undetermined" port.
|
static TcpUdpPort |
tcpPort(int portNumber)
Delegates to
valueOf(int,IpProtocol) , specifying the
protocol to be TCP. |
String |
toString()
Returns a string consisting of the port number followed by
a slash character followed by the protocol.
|
static TcpUdpPort |
udpPort(int portNumber)
Delegates to
valueOf(int,IpProtocol) , specifying the
protocol to be UDP. |
static TcpUdpPort |
valueOf(int portNumber,
IpProtocol protocol)
Returns an object that represents the value of the tcp/udp port
identified by the specified port number and protocol.
|
static TcpUdpPort |
valueOf(String value)
Returns an object that represents the value of the tcp/udp port
identified by the specified string.
|
getRefQ, keyFromBytes
public static final TcpUdpPort UNDETERMINED_TCP
public static final TcpUdpPort UNDETERMINED_UDP
public String toString()
public String getName()
public String getShortName()
public int getNumber()
public IpProtocol getProtocol()
public String getProtocolName()
public boolean isUndetermined()
public int compareTo(TcpUdpPort o)
compareTo
in interface Comparable<TcpUdpPort>
o
- the other port to compare toComparable.compareTo(T)
public static TcpUdpPort valueOf(String value)
"nnnn/ppp"
where 'nnnn' is the port number, and 'ppp' is
the protocol: either "tcp"
or "udp"
. For example:
TcpUdpPort p = TcpUdpPort.valueOf("7/tcp");
value
- the port specificationNullPointerException
- if value is nullIllegalArgumentException
- if the string is incorrectly formattedpublic static TcpUdpPort valueOf(int portNumber, IpProtocol protocol)
TcpUdpPort p = TcpUdpPort.valueOf(7, IpProtocol.TCP)
portNumber
- the port numberprotocol
- the protocol (either IpProtocol.TCP
or
IpProtocol.UDP
)NullPointerException
- if protocol is nullIllegalArgumentException
- if protocol is not TCP or UDP, or if
the port number is < 0 or > 65535public static TcpUdpPort tcpPort(int portNumber)
valueOf(int,IpProtocol)
, specifying the
protocol to be TCP.portNumber
- the port numberIllegalArgumentException
- if the port number
is < 0 or > 65535public static TcpUdpPort udpPort(int portNumber)
valueOf(int,IpProtocol)
, specifying the
protocol to be UDP.portNumber
- the port numberIllegalArgumentException
- if the port number
is < 0 or > 65535Copyright © 2015. All Rights Reserved.