Package jnr.netdb
Class Protocol
- java.lang.Object
-
- jnr.netdb.Protocol
-
public final class Protocol extends java.lang.Object
An entry in the system protocol database
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Protocol.ProtocolDBSingletonHolder
Holds the global lazily-loaded instance of the ProtocolDB
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<java.lang.String>
aliases
All the aliases for this protocolprivate int
proto
private java.lang.String
protocolName
Official protocol name
-
Constructor Summary
Constructors Constructor Description Protocol(java.lang.String name, int proto, java.util.Collection<java.lang.String> aliases)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<java.lang.String>
getAliases()
Returns a list of aliases thisProtocol
is also known by.java.lang.String
getName()
Returns the official IANA name of thisProtocol
int
getProto()
Returns the official IANA protocol number for thisProtocol
static Protocol
getProtocolByName(java.lang.String name)
Locates a protocol by name.static Protocol
getProtocolByNumber(int proto)
Locates a protocol by number.private static ProtocolsDB
getProtocolDB()
Returns the currently loaded ProtocolDBjava.lang.String
toString()
-
-
-
Method Detail
-
getProtocolByName
public static final Protocol getProtocolByName(java.lang.String name)
Locates a protocol by name.- Parameters:
name
- the official IANA name for the protocol, or an alias.- Returns:
- a
Protocol
instance, ornull
if the protocol could not be found.
-
getProtocolByNumber
public static final Protocol getProtocolByNumber(int proto)
Locates a protocol by number.- Parameters:
proto
- the internet protocol number of the protocol.- Returns:
- a
Protocol
instance, ornull
if the protocol could not be found.
-
getName
public final java.lang.String getName()
Returns the official IANA name of thisProtocol
- Returns:
- The name of this
Protocol
as aString
-
getProto
public final int getProto()
Returns the official IANA protocol number for thisProtocol
- Returns:
- The protocol number for this
Protocol
as anint
-
getAliases
public final java.util.Collection<java.lang.String> getAliases()
Returns a list of aliases thisProtocol
is also known by.- Returns:
- A
Collection
of Strings for aliases thisProtocol
-
getProtocolDB
private static final ProtocolsDB getProtocolDB()
Returns the currently loaded ProtocolDB- Returns:
- an instance of
ProtocolDB
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-