JmDNS 3.4.1

javax.jmdns
Class ServiceInfo

java.lang.Object
  extended by javax.jmdns.ServiceInfo
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ServiceInfoImpl

public abstract class ServiceInfo
extends java.lang.Object
implements java.lang.Cloneable

The fully qualified service name is build using up to 5 components with the following structure:

            <app>.<protocol>.<servicedomain>.<parentdomain>.
<Instance>.<app>.<protocol>.<servicedomain>.<parentdomain>.
<sub>._sub.<app>.<protocol>.<servicedomain>.<parentdomain>.
  1. <servicedomain>.<parentdomain>: This is the domain scope of the service typically "local.", but this can also be something similar to "in-addr.arpa." or "ip6.arpa."
  2. <protocol>: This is either "_tcp" or "_udp"
  3. <app>: This define the application protocol. Typical example are "_http", "_ftp", etc.
  4. <Instance>: This is the service name
  5. <sub>: This is the subtype for the application protocol


Nested Class Summary
static class ServiceInfo.Fields
          Fields for the fully qualified map.
 
Field Summary
static byte[] NO_VALUE
          This is the no value text byte.
 
Constructor Summary
ServiceInfo()
           
 
Method Summary
 ServiceInfo clone()
           
static ServiceInfo create(java.util.Map<ServiceInfo.Fields,java.lang.String> qualifiedNameMap, int port, int weight, int priority, boolean persistent, java.util.Map<java.lang.String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, int port, int weight, int priority, boolean persistent, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, int port, int weight, int priority, boolean persistent, java.util.Map<java.lang.String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, int port, int weight, int priority, boolean persistent, java.lang.String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, int port, int weight, int priority, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, int port, int weight, int priority, java.util.Map<java.lang.String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, int port, int weight, int priority, java.lang.String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, int port, java.lang.String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, java.lang.String subtype, int port, int weight, int priority, boolean persistent, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, java.lang.String subtype, int port, int weight, int priority, boolean persistent, java.util.Map<java.lang.String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, java.lang.String subtype, int port, int weight, int priority, boolean persistent, java.lang.String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, java.lang.String subtype, int port, int weight, int priority, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, java.lang.String subtype, int port, int weight, int priority, java.util.Map<java.lang.String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, java.lang.String subtype, int port, int weight, int priority, java.lang.String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(java.lang.String type, java.lang.String name, java.lang.String subtype, int port, java.lang.String text)
          Construct a service description for registering with JmDNS.
abstract  java.net.InetAddress getAddress()
          Deprecated. since 3.1.8
abstract  java.lang.String getApplication()
          Returns the application of the service info suitable for printing.
abstract  java.lang.String getDomain()
          Returns the domain of the service info suitable for printing.
abstract  java.lang.String getHostAddress()
          Deprecated. since 3.2.3
abstract  java.lang.String[] getHostAddresses()
          Returns the host IP addresses string in textual presentation.
abstract  java.net.Inet4Address getInet4Address()
          Deprecated. since 3.2.3
abstract  java.net.Inet4Address[] getInet4Addresses()
          Returns a list of all IPv4 InetAddresses that can be used for this service.
abstract  java.net.Inet6Address getInet6Address()
          Deprecated. since 3.2.3
abstract  java.net.Inet6Address[] getInet6Addresses()
          Returns a list of all IPv6 InetAddresses that can be used for this service.
abstract  java.net.InetAddress getInetAddress()
          Deprecated. since 3.2.3
abstract  java.net.InetAddress[] getInetAddresses()
          Returns a list of all InetAddresses that can be used for this service.
abstract  java.lang.String getKey()
          The key is used to retrieve service info in hash tables.
The key is the lower case qualified name.
abstract  java.lang.String getName()
          Unqualified service instance name, such as foobar .
abstract  java.lang.String getNiceTextString()
          Returns a description of the service info suitable for printing.
abstract  int getPort()
          Get the port for the service.
abstract  int getPriority()
          Get the priority of the service.
abstract  byte[] getPropertyBytes(java.lang.String name)
          Get a property of the service.
abstract  java.util.Enumeration<java.lang.String> getPropertyNames()
          Enumeration of the property names.
abstract  java.lang.String getPropertyString(java.lang.String name)
          Get a property of the service.
abstract  java.lang.String getProtocol()
          Returns the protocol of the service info suitable for printing.
abstract  java.lang.String getQualifiedName()
          Fully qualified service name, such as foobar._http._tcp.local. .
abstract  java.util.Map<ServiceInfo.Fields,java.lang.String> getQualifiedNameMap()
          Returns a dictionary of the fully qualified name component of this service.
abstract  java.lang.String getServer()
          Get the name of the server.
abstract  java.lang.String getSubtype()
          Returns the sub type of the service info suitable for printing.
abstract  byte[] getTextBytes()
          Get the text for the service as raw bytes.
abstract  java.lang.String getTextString()
          Deprecated. since 3.1.7
abstract  java.lang.String getType()
          Fully qualified service type name, such as _http._tcp.local.
abstract  java.lang.String getTypeWithSubtype()
          Fully qualified service type name with the subtype if appropriate, such as _printer._sub._http._tcp.local.
abstract  java.lang.String getURL()
          Deprecated. since 3.2.3
abstract  java.lang.String getURL(java.lang.String protocol)
          Deprecated. since 3.2.3
abstract  java.lang.String[] getURLs()
          Get the list of URL for this service.
abstract  java.lang.String[] getURLs(java.lang.String protocol)
          Get the list of URL for this service.
abstract  int getWeight()
          Get the weight of the service.
abstract  boolean hasData()
          Returns true if the service info is filled with data.
abstract  boolean isPersistent()
          Returns true if ServiceListener.resolveService will be called whenever new new information is received.
abstract  void setText(byte[] text)
          Set the text for the service.
abstract  void setText(java.util.Map<java.lang.String,?> props)
          Set the text for the service.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_VALUE

public static final byte[] NO_VALUE
This is the no value text byte. According top the specification it is one byte with 0 value.

Constructor Detail

ServiceInfo

public ServiceInfo()
Method Detail

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 int port,
                                 java.lang.String text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
port - the local port on which the service runs
text - string describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String subtype,
                                 int port,
                                 java.lang.String text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
subtype - service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumeration
port - the local port on which the service runs
text - string describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 java.lang.String text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
text - string describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 java.lang.String text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
subtype - service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumeration
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
text - string describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 java.util.Map<java.lang.String,?> props)
Construct a service description for registering with JmDNS. The properties hashtable must map property names to either Strings or byte arrays describing the property values.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
props - properties describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 java.util.Map<java.lang.String,?> props)
Construct a service description for registering with JmDNS. The properties hashtable must map property names to either Strings or byte arrays describing the property values.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
subtype - service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumeration
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
props - properties describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 byte[] text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
text - bytes describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 byte[] text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
subtype - service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumeration
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
text - bytes describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 java.lang.String text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
persistent - if true ServiceListener.resolveService will be called whenever new new information is received.
text - string describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 java.lang.String text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
subtype - service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumeration
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
persistent - if true ServiceListener.resolveService will be called whenever new new information is received.
text - string describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 java.util.Map<java.lang.String,?> props)
Construct a service description for registering with JmDNS. The properties hashtable must map property names to either Strings or byte arrays describing the property values.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
persistent - if true ServiceListener.resolveService will be called whenever new new information is received.
props - properties describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 java.util.Map<java.lang.String,?> props)
Construct a service description for registering with JmDNS. The properties hashtable must map property names to either Strings or byte arrays describing the property values.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
subtype - service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumeration
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
persistent - if true ServiceListener.resolveService will be called whenever new new information is received.
props - properties describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 byte[] text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
persistent - if true ServiceListener.resolveService will be called whenever new new information is received.
text - bytes describing the service
Returns:
new service info

create

public static ServiceInfo create(java.lang.String type,
                                 java.lang.String name,
                                 java.lang.String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 byte[] text)
Construct a service description for registering with JmDNS.

Parameters:
type - fully qualified service type name, such as _http._tcp.local..
name - unqualified service instance name, such as foobar
subtype - service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumeration
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
persistent - if true ServiceListener.resolveService will be called whenever new new information is received.
text - bytes describing the service
Returns:
new service info

create

public static ServiceInfo create(java.util.Map<ServiceInfo.Fields,java.lang.String> qualifiedNameMap,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 java.util.Map<java.lang.String,?> props)
Construct a service description for registering with JmDNS. The properties hashtable must map property names to either Strings or byte arrays describing the property values.

Parameters:
qualifiedNameMap - dictionary of values to build the fully qualified service name. Mandatory keys are Application and Instance. The Domain default is local, the Protocol default is tcp and the subtype default is none.
port - the local port on which the service runs
weight - weight of the service
priority - priority of the service
persistent - if true ServiceListener.resolveService will be called whenever new new information is received.
props - properties describing the service
Returns:
new service info

hasData

public abstract boolean hasData()
Returns true if the service info is filled with data.

Returns:
true if the service info has data, false otherwise.

getType

public abstract java.lang.String getType()
Fully qualified service type name, such as _http._tcp.local.

Returns:
service type name

getTypeWithSubtype

public abstract java.lang.String getTypeWithSubtype()
Fully qualified service type name with the subtype if appropriate, such as _printer._sub._http._tcp.local.

Returns:
service type name

getName

public abstract java.lang.String getName()
Unqualified service instance name, such as foobar .

Returns:
service name

getKey

public abstract java.lang.String getKey()
The key is used to retrieve service info in hash tables.
The key is the lower case qualified name.

Returns:
the key

getQualifiedName

public abstract java.lang.String getQualifiedName()
Fully qualified service name, such as foobar._http._tcp.local. .

Returns:
qualified service name

getServer

public abstract java.lang.String getServer()
Get the name of the server.

Returns:
server name

getHostAddress

@Deprecated
public abstract java.lang.String getHostAddress()
Deprecated. since 3.2.3

Returns the host IP address string in textual presentation.
Note: This can be either an IPv4 or an IPv6 representation.

Returns:
the host raw IP address in a string format.
See Also:
getHostAddresses()

getHostAddresses

public abstract java.lang.String[] getHostAddresses()
Returns the host IP addresses string in textual presentation.

Returns:
list of host raw IP address in a string format.

getAddress

@Deprecated
public abstract java.net.InetAddress getAddress()
Deprecated. since 3.1.8

Get the host address of the service.

Returns:
host Internet address
See Also:
getInetAddresses()

getInetAddress

@Deprecated
public abstract java.net.InetAddress getInetAddress()
Deprecated. since 3.2.3

Get the InetAddress of the service. This will return the IPv4 if it exist, otherwise it return the IPv6 if set.
Note: This return null if the service IP address cannot be resolved.

Returns:
Internet address
See Also:
getInetAddresses()

getInet4Address

@Deprecated
public abstract java.net.Inet4Address getInet4Address()
Deprecated. since 3.2.3

Get the IPv4 InetAddress of the service.
Note: This return null if the service IPv4 address cannot be resolved.

Returns:
Internet address
See Also:
getInet4Addresses()

getInet6Address

@Deprecated
public abstract java.net.Inet6Address getInet6Address()
Deprecated. since 3.2.3

Get the IPv6 InetAddress of the service.
Note: This return null if the service IPv6 address cannot be resolved.

Returns:
Internet address
See Also:
getInet6Addresses()

getInetAddresses

public abstract java.net.InetAddress[] getInetAddresses()
Returns a list of all InetAddresses that can be used for this service.

In a multi-homed environment service info can be associated with more than one address.

Returns:
list of InetAddress objects

getInet4Addresses

public abstract java.net.Inet4Address[] getInet4Addresses()
Returns a list of all IPv4 InetAddresses that can be used for this service.

In a multi-homed environment service info can be associated with more than one address.

Returns:
list of InetAddress objects

getInet6Addresses

public abstract java.net.Inet6Address[] getInet6Addresses()
Returns a list of all IPv6 InetAddresses that can be used for this service.

In a multi-homed environment service info can be associated with more than one address.

Returns:
list of InetAddress objects

getPort

public abstract int getPort()
Get the port for the service.

Returns:
service port

getPriority

public abstract int getPriority()
Get the priority of the service.

Returns:
service priority

getWeight

public abstract int getWeight()
Get the weight of the service.

Returns:
service weight

getTextBytes

public abstract byte[] getTextBytes()
Get the text for the service as raw bytes.

Returns:
raw service text

getTextString

@Deprecated
public abstract java.lang.String getTextString()
Deprecated. since 3.1.7

Get the text for the service. This will interpret the text bytes as a UTF8 encoded string. Will return null if the bytes are not a valid UTF8 encoded string.
Note: Do not use. This method make the assumption that the TXT record is one string. This is false. The TXT record is a series of key value pairs.

Returns:
service text
See Also:
getPropertyNames(), getPropertyBytes(String), getPropertyString(String)

getURL

@Deprecated
public abstract java.lang.String getURL()
Deprecated. since 3.2.3

Get the URL for this service. An http URL is created by combining the address, port, and path properties.

Returns:
service URL
See Also:
getURLs()

getURLs

public abstract java.lang.String[] getURLs()
Get the list of URL for this service. An http URL is created by combining the address, port, and path properties.

Returns:
list of service URL

getURL

@Deprecated
public abstract java.lang.String getURL(java.lang.String protocol)
Deprecated. since 3.2.3

Get the URL for this service. An URL is created by combining the protocol, address, port, and path properties.

Parameters:
protocol - requested protocol
Returns:
service URL
See Also:
getURLs()

getURLs

public abstract java.lang.String[] getURLs(java.lang.String protocol)
Get the list of URL for this service. An URL is created by combining the protocol, address, port, and path properties.

Parameters:
protocol - requested protocol
Returns:
list of service URL

getPropertyBytes

public abstract byte[] getPropertyBytes(java.lang.String name)
Get a property of the service. This involves decoding the text bytes into a property list. Returns null if the property is not found or the text data could not be decoded correctly.

Parameters:
name - property name
Returns:
raw property text

getPropertyString

public abstract java.lang.String getPropertyString(java.lang.String name)
Get a property of the service. This involves decoding the text bytes into a property list. Returns null if the property is not found, the text data could not be decoded correctly, or the resulting bytes are not a valid UTF8 string.

Parameters:
name - property name
Returns:
property text

getPropertyNames

public abstract java.util.Enumeration<java.lang.String> getPropertyNames()
Enumeration of the property names.

Returns:
property name enumeration

getNiceTextString

public abstract java.lang.String getNiceTextString()
Returns a description of the service info suitable for printing.

Returns:
service info description

setText

public abstract void setText(byte[] text)
                      throws java.lang.IllegalStateException
Set the text for the service. Setting the text will fore a re-announce of the service.

Parameters:
text - the raw byte representation of the text field.
Throws:
java.lang.IllegalStateException - if attempting to set the text for a non persistent service info.

setText

public abstract void setText(java.util.Map<java.lang.String,?> props)
                      throws java.lang.IllegalStateException
Set the text for the service. Setting the text will fore a re-announce of the service.

Parameters:
props - a key=value map that will be encoded into raw bytes.
Throws:
java.lang.IllegalStateException - if attempting to set the text for a non persistent service info.

isPersistent

public abstract boolean isPersistent()
Returns true if ServiceListener.resolveService will be called whenever new new information is received.

Returns:
the persistent

getDomain

public abstract java.lang.String getDomain()
Returns the domain of the service info suitable for printing.

Returns:
service domain

getProtocol

public abstract java.lang.String getProtocol()
Returns the protocol of the service info suitable for printing.

Returns:
service protocol

getApplication

public abstract java.lang.String getApplication()
Returns the application of the service info suitable for printing.

Returns:
service application

getSubtype

public abstract java.lang.String getSubtype()
Returns the sub type of the service info suitable for printing.

Returns:
service sub type

getQualifiedNameMap

public abstract java.util.Map<ServiceInfo.Fields,java.lang.String> getQualifiedNameMap()
Returns a dictionary of the fully qualified name component of this service.

Returns:
dictionary of the fully qualified name components

clone

public ServiceInfo clone()
Overrides:
clone in class java.lang.Object

JmDNS 3.4.1