JmDNS 3.4.1

javax.jmdns
Class ServiceInfo

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

public abstract class ServiceInfo
extends Object
implements 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(Map<ServiceInfo.Fields,String> qualifiedNameMap, int port, int weight, int priority, boolean persistent, Map<String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, int port, int weight, int priority, boolean persistent, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, int port, int weight, int priority, boolean persistent, Map<String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, int port, int weight, int priority, boolean persistent, String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, int port, int weight, int priority, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, int port, int weight, int priority, Map<String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, int port, int weight, int priority, String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, int port, String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, String subtype, int port, int weight, int priority, boolean persistent, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, String subtype, int port, int weight, int priority, boolean persistent, Map<String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, String subtype, int port, int weight, int priority, boolean persistent, String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, String subtype, int port, int weight, int priority, byte[] text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, String subtype, int port, int weight, int priority, Map<String,?> props)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, String subtype, int port, int weight, int priority, String text)
          Construct a service description for registering with JmDNS.
static ServiceInfo create(String type, String name, String subtype, int port, String text)
          Construct a service description for registering with JmDNS.
abstract  InetAddress getAddress()
          Deprecated. since 3.1.8
abstract  String getApplication()
          Returns the application of the service info suitable for printing.
abstract  String getDomain()
          Returns the domain of the service info suitable for printing.
abstract  String getHostAddress()
          Deprecated. since 3.2.3
abstract  String[] getHostAddresses()
          Returns the host IP addresses string in textual presentation.
abstract  Inet4Address getInet4Address()
          Deprecated. since 3.2.3
abstract  Inet4Address[] getInet4Addresses()
          Returns a list of all IPv4 InetAddresses that can be used for this service.
abstract  Inet6Address getInet6Address()
          Deprecated. since 3.2.3
abstract  Inet6Address[] getInet6Addresses()
          Returns a list of all IPv6 InetAddresses that can be used for this service.
abstract  InetAddress getInetAddress()
          Deprecated. since 3.2.3
abstract  InetAddress[] getInetAddresses()
          Returns a list of all InetAddresses that can be used for this service.
abstract  String getKey()
          The key is used to retrieve service info in hash tables.
The key is the lower case qualified name.
abstract  String getName()
          Unqualified service instance name, such as foobar .
abstract  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(String name)
          Get a property of the service.
abstract  Enumeration<String> getPropertyNames()
          Enumeration of the property names.
abstract  String getPropertyString(String name)
          Get a property of the service.
abstract  String getProtocol()
          Returns the protocol of the service info suitable for printing.
abstract  String getQualifiedName()
          Fully qualified service name, such as foobar._http._tcp.local. .
abstract  Map<ServiceInfo.Fields,String> getQualifiedNameMap()
          Returns a dictionary of the fully qualified name component of this service.
abstract  String getServer()
          Get the name of the server.
abstract  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  String getTextString()
          Deprecated. since 3.1.7
abstract  String getType()
          Fully qualified service type name, such as _http._tcp.local.
abstract  String getTypeWithSubtype()
          Fully qualified service type name with the subtype if appropriate, such as _printer._sub._http._tcp.local.
abstract  String getURL()
          Deprecated. since 3.2.3
abstract  String getURL(String protocol)
          Deprecated. since 3.2.3
abstract  String[] getURLs()
          Get the list of URL for this service.
abstract  String[] getURLs(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(Map<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(String type,
                                 String name,
                                 int port,
                                 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(String type,
                                 String name,
                                 String subtype,
                                 int port,
                                 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(String type,
                                 String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 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(String type,
                                 String name,
                                 String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 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(String type,
                                 String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 Map<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(String type,
                                 String name,
                                 String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 Map<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(String type,
                                 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(String type,
                                 String name,
                                 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(String type,
                                 String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 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(String type,
                                 String name,
                                 String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 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(String type,
                                 String name,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 Map<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(String type,
                                 String name,
                                 String subtype,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 Map<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(String type,
                                 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(String type,
                                 String name,
                                 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(Map<ServiceInfo.Fields,String> qualifiedNameMap,
                                 int port,
                                 int weight,
                                 int priority,
                                 boolean persistent,
                                 Map<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 String getType()
Fully qualified service type name, such as _http._tcp.local.

Returns:
service type name

getTypeWithSubtype

public abstract 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 String getName()
Unqualified service instance name, such as foobar .

Returns:
service name

getKey

public abstract 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 String getQualifiedName()
Fully qualified service name, such as foobar._http._tcp.local. .

Returns:
qualified service name

getServer

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

Returns:
server name

getHostAddress

@Deprecated
public abstract 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 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 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 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 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 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 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 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 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 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 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 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 String getURL(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 String[] getURLs(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(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 String getPropertyString(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 Enumeration<String> getPropertyNames()
Enumeration of the property names.

Returns:
property name enumeration

getNiceTextString

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

Returns:
service info description

setText

public abstract void setText(byte[] text)
                      throws 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:
IllegalStateException - if attempting to set the text for a non persistent service info.

setText

public abstract void setText(Map<String,?> props)
                      throws 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:
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 String getDomain()
Returns the domain of the service info suitable for printing.

Returns:
service domain

getProtocol

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

Returns:
service protocol

getApplication

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

Returns:
service application

getSubtype

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

Returns:
service sub type

getQualifiedNameMap

public abstract Map<ServiceInfo.Fields,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 Object

Last updated 2011-08-25 12:40

Copyright © 2002-2011 JmDNS. All Rights Reserved.