Top Description Inners Fields Constructors Methods
jnr.netdb

public final Class Service

extends Object
Class Inheritance
Imports
java.util.Collection, .Collections

Holds information about TCP and UDP services on a host.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Service.ServicesDBSingletonHolder

Holds the global lazily-loaded instance of the ServicesDB

Field Summary

Modifier and TypeField and Description
private final Collection<String>
aliases

All the aliases for this service

private final int
port

TCP or UDP port number

pack-priv final String
proto

Protocol to use

private final String
serviceName

Official service name

Constructor Summary

AccessConstructor and Description
pack-priv
Service(String name, int port, String proto, Collection<String> aliases)

Method Summary

Modifier and TypeMethod and Description
public final Collection<String>

Returns:

A Collection of Strings for aliases this Service
getAliases
()

Gets a list of aliases this Service is also known as.

public static final Collection<Service>

Returns:

a Collection of Service instances.
getAllServices
()

Returns a list of all services.

public final String

Returns:

The name of this Service as a String
getName
()

Returns the official IANA name of this Service

public final int

Returns:

The port for this Service as an int
getPort
()

Returns the official IANA port for this Service

public static final Service

Returns:

a Service instance, or null if the service could not be found.
getServiceByName
(String
the official IANA name for the service, or an alias.
name
,
String
the protocol for the service. Usually "tcp" or "udp".
proto
)

Locates a service by name and protocol.

public static final Service

Returns:

a Service instance, or null if the service could not be found.
getServiceByPort
(int
the TCP or UDP port of the service.
port
,
String
the protocol for the service. Usually "tcp" or "udp".
proto
)

Locates a service by port and protocol.

private static final ServicesDB

Returns:

an instance of ServicesDB
getServicesDB
()

Returns the currently loaded ServicesDB

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aliasesback to summary
private final Collection<String> aliases

All the aliases for this service

portback to summary
private final int port

TCP or UDP port number

protoback to summary
pack-priv final String proto

Protocol to use

serviceNameback to summary
private final String serviceName

Official service name

Constructor Detail

Serviceback to summary
pack-priv Service(String name, int port, String proto, Collection<String> aliases)

Method Detail

getAliasesback to summary
public final Collection<String> getAliases()

Gets a list of aliases this Service is also known as.

Returns:Collection<String>

A Collection of Strings for aliases this Service

getAllServicesback to summary
public static final Collection<Service> getAllServices()

Returns a list of all services.

Returns:Collection<Service>

a Collection of Service instances.

getNameback to summary
public final String getName()

Returns the official IANA name of this Service

Returns:String

The name of this Service as a String

getPortback to summary
public final int getPort()

Returns the official IANA port for this Service

Returns:int

The port for this Service as an int

getServiceByNameback to summary
public static final Service getServiceByName(String name, String proto)

Locates a service by name and protocol.

Parameters
name:String

the official IANA name for the service, or an alias.

proto:String

the protocol for the service. Usually "tcp" or "udp".

Returns:Service

a Service instance, or null if the service could not be found.

getServiceByPortback to summary
public static final Service getServiceByPort(int port, String proto)

Locates a service by port and protocol.

Parameters
port:int

the TCP or UDP port of the service.

proto:String

the protocol for the service. Usually "tcp" or "udp".

Returns:Service

a Service instance, or null if the service could not be found.

getServicesDBback to summary
private static final ServicesDB getServicesDB()

Returns the currently loaded ServicesDB

Returns:ServicesDB

an instance of ServicesDB

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
jnr.netdb back to summary

private final Class Service.ServicesDBSingletonHolder

extends Object
Class Inheritance

Holds the global lazily-loaded instance of the ServicesDB

Field Summary

Modifier and TypeField and Description
pack-priv static final ServicesDB

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static final ServicesDB
load()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
pack-priv static final ServicesDB INSTANCE

Constructor Detail

ServicesDBSingletonHolderback to summary
private ServicesDBSingletonHolder()

Method Detail

loadback to summary
private static final ServicesDB load()