public final class Service
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
Service.ServicesDBSingletonHolder
Holds the global lazily-loaded instance of the ServicesDB
|
Modifier and Type | Field and Description |
---|---|
private java.util.Collection<java.lang.String> |
aliases
All the aliases for this service
|
private int |
port
TCP or UDP port number
|
(package private) java.lang.String |
proto
Protocol to use
|
private java.lang.String |
serviceName
Official service name
|
Constructor and Description |
---|
Service(java.lang.String name,
int port,
java.lang.String proto,
java.util.Collection<java.lang.String> aliases) |
Modifier and Type | Method and Description |
---|---|
java.util.Collection<java.lang.String> |
getAliases()
Gets a list of aliases this
Service is also known as. |
static java.util.Collection<Service> |
getAllServices()
Returns a list of all services.
|
java.lang.String |
getName()
Returns the official IANA name of this
Service |
int |
getPort()
Returns the official IANA port for this
Service |
static Service |
getServiceByName(java.lang.String name,
java.lang.String proto)
Locates a service by name and protocol.
|
static Service |
getServiceByPort(int port,
java.lang.String proto)
Locates a service by port and protocol.
|
private static ServicesDB |
getServicesDB()
Returns the currently loaded ServicesDB
|
java.lang.String |
toString() |
private final java.lang.String serviceName
private final int port
final java.lang.String proto
private final java.util.Collection<java.lang.String> aliases
Service(java.lang.String name, int port, java.lang.String proto, java.util.Collection<java.lang.String> aliases)
public static final Service getServiceByName(java.lang.String name, java.lang.String proto)
name
- the official IANA name for the service, or an alias.proto
- the protocol for the service. Usually "tcp" or "udp".Service
instance, or null
if the service could not be found.public static final Service getServiceByPort(int port, java.lang.String proto)
port
- the TCP or UDP port of the service.proto
- the protocol for the service. Usually "tcp" or "udp".Service
instance, or null
if the service could not be found.public static final java.util.Collection<Service> getAllServices()
Collection
of Service
instances.public final java.lang.String getName()
Service
Service
as a String
public final int getPort()
Service
Service
as an int
public final java.util.Collection<java.lang.String> getAliases()
Service
is also known as.Collection
of Strings for aliases this Service
private static final ServicesDB getServicesDB()
ServicesDB
public java.lang.String toString()
toString
in class java.lang.Object