Package jnr.netdb
Class Service
java.lang.Object
jnr.netdb.Service
Holds information about TCP and UDP services on a host.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Holds the global lazily-loaded instance of the ServicesDB -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Collection
<String> All the aliases for this serviceprivate final int
TCP or UDP port number(package private) final String
Protocol to useprivate final String
Official service name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Collection
<String> Gets a list of aliases thisService
is also known as.static final Collection
<Service> Returns a list of all services.final String
getName()
Returns the official IANA name of thisService
final int
getPort()
Returns the official IANA port for thisService
static final Service
getServiceByName
(String name, String proto) Locates a service by name and protocol.static final Service
getServiceByPort
(int port, String proto) Locates a service by port and protocol.private static final ServicesDB
Returns the currently loaded ServicesDBtoString()
-
Field Details
-
serviceName
Official service name -
port
private final int portTCP or UDP port number -
proto
Protocol to use -
aliases
All the aliases for this service
-
-
Constructor Details
-
Service
Service(String name, int port, String proto, Collection<String> aliases)
-
-
Method Details
-
getServiceByName
Locates a service by name and protocol.- Parameters:
name
- the official IANA name for the service, or an alias.proto
- the protocol for the service. Usually "tcp" or "udp".- Returns:
- a
Service
instance, ornull
if the service could not be found.
-
getServiceByPort
Locates a service by port and protocol.- Parameters:
port
- the TCP or UDP port of the service.proto
- the protocol for the service. Usually "tcp" or "udp".- Returns:
- a
Service
instance, ornull
if the service could not be found.
-
getAllServices
Returns a list of all services.- Returns:
- a
Collection
ofService
instances.
-
getName
Returns the official IANA name of thisService
- Returns:
- The name of this
Service
as aString
-
getPort
public final int getPort()Returns the official IANA port for thisService
- Returns:
- The port for this
Service
as anint
-
getAliases
Gets a list of aliases thisService
is also known as.- Returns:
- A
Collection
of Strings for aliases thisService
-
getServicesDB
Returns the currently loaded ServicesDB- Returns:
- an instance of
ServicesDB
-
toString
-