Package javax.jmdns
Class ServiceInfo
java.lang.Object
javax.jmdns.ServiceInfo
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ServiceInfoImpl
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>.
- <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."
- <protocol>: This is either "_tcp" or "_udp"
- <app>: This define the application protocol. Typical example are "_http", "_ftp", etc.
- <Instance>: This is the service name
- <sub>: This is the subtype for the application protocol
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Fields for the fully qualified map. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
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, String 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
Construct a service description for registering with JmDNS.static ServiceInfo
Construct a service description for registering with JmDNS.static ServiceInfo
Construct a service description for registering with JmDNS.static ServiceInfo
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, 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, Map<String, ?> props) Construct a service description for registering with JmDNS.static ServiceInfo
Construct a service description for registering with JmDNS.static ServiceInfo
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
Construct a service description for registering with JmDNS.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.abstract InetAddress
Deprecated.since 3.1.8abstract String
Returns the application of the service info suitable for printing.abstract String
Returns the domain of the service info suitable for printing.abstract String
Deprecated.since 3.2.3abstract String[]
Returns the host IP addresses string in textual presentation.abstract Inet4Address
Deprecated.since 3.2.3abstract Inet4Address[]
Returns a list of all IPv4 InetAddresses that can be used for this service.abstract Inet6Address
Deprecated.since 3.2.3abstract Inet6Address[]
Returns a list of all IPv6 InetAddresses that can be used for this service.abstract InetAddress
Deprecated.since 3.2.3abstract InetAddress[]
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 asfoobar
.abstract String
Returns a description of the service info suitable for printing.abstract int
getPort()
Get the port for the service.abstract int
Get the priority of the service.abstract byte[]
getPropertyBytes
(String name) Get a property of the service.abstract Enumeration
<String> Enumeration of the property names.abstract String
getPropertyString
(String name) Get a property of the service.abstract String
Returns the protocol of the service info suitable for printing.abstract String
Fully qualified service name, such asfoobar._http._tcp.local.
.abstract Map
<ServiceInfo.Fields, String> Returns a dictionary of the fully qualified name component of this service.abstract String
Get the name of the server.abstract String
Returns the sub type of the service info suitable for printing.abstract byte[]
Get the text for the service as raw bytes.abstract String
Deprecated.since 3.1.7abstract String
getType()
Fully qualified service type name, such as_http._tcp.local.
abstract String
Fully qualified service type name with the subtype if appropriate, such as_printer._sub._http._tcp.local.
abstract String
getURL()
Deprecated.since 3.2.3abstract String
Deprecated.since 3.2.3abstract String[]
getURLs()
Get the list of URL for this service.abstract String[]
Get the list of URL for this service.abstract int
Get the weight of the service.abstract boolean
hasData()
Returns true if the service info is filled with data.abstract boolean
hasSameAddresses
(ServiceInfo other) Compare addresses of another ServiceInfoabstract boolean
Returns true if the service info has a serverabstract boolean
Returnstrue
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
Set the text for the service.
-
Constructor Details
-
ServiceInfo
public ServiceInfo()
-
-
Method Details
-
create
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 asfoobar
port
- the local port on which the service runstext
- string describing the service- Returns:
- new service info
-
create
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 asfoobar
subtype
- service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumerationport
- the local port on which the service runstext
- 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 asfoobar
port
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicetext
- 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 asfoobar
subtype
- service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumerationport
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicetext
- 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 asfoobar
port
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the serviceprops
- 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 asfoobar
subtype
- service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumerationport
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the serviceprops
- 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 asfoobar
port
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicetext
- 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 asfoobar
subtype
- service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumerationport
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicetext
- 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 asfoobar
port
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicepersistent
- iftrue
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 asfoobar
subtype
- service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumerationport
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicepersistent
- iftrue
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 asfoobar
port
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicepersistent
- iftrue
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 asfoobar
subtype
- service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumerationport
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicepersistent
- iftrue
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 asfoobar
port
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicepersistent
- iftrue
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 asfoobar
subtype
- service subtype see draft-cheshire-dnsext-dns-sd-06.txt chapter 7.1 Selective Instance Enumerationport
- the local port on which the service runsweight
- weight of the servicepriority
- priority of the servicepersistent
- iftrue
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 runsweight
- weight of the servicepriority
- priority of the servicepersistent
- iftrue
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
Fully qualified service type name, such as_http._tcp.local.
- Returns:
- service type name
-
getTypeWithSubtype
Fully qualified service type name with the subtype if appropriate, such as_printer._sub._http._tcp.local.
- Returns:
- service type name
-
getName
Unqualified service instance name, such asfoobar
.- Returns:
- service name
-
getKey
The key is used to retrieve service info in hash tables.
The key is the lower case qualified name.- Returns:
- the key
-
getQualifiedName
Fully qualified service name, such asfoobar._http._tcp.local.
.- Returns:
- qualified service name
-
getServer
Get the name of the server. Note: This will be an empty string if no value has been set- Returns:
- server name
-
hasServer
public abstract boolean hasServer()Returns true if the service info has a server- Returns:
true
if the service info has a server specified,false
otherwise.
-
getHostAddress
Deprecated.since 3.2.3Returns 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
Returns the host IP addresses string in textual presentation.- Returns:
- list of host raw IP address in a string format.
-
getAddress
Deprecated.since 3.1.8Get the host address of the service.- Returns:
- host Internet address
- See Also:
-
getInetAddress
Deprecated.since 3.2.3Get 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:
-
getInet4Address
Deprecated.since 3.2.3Get the IPv4 InetAddress of the service.
Note: This return null if the service IPv4 address cannot be resolved.- Returns:
- Internet address
- See Also:
-
getInet6Address
Deprecated.since 3.2.3Get the IPv6 InetAddress of the service.
Note: This return null if the service IPv6 address cannot be resolved.- Returns:
- Internet address
- See Also:
-
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
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
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.since 3.1.7Get 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:
-
getURL
Deprecated.since 3.2.3Get the URL for this service. An http URL is created by combining the address, port, and path properties.- Returns:
- service URL
- See Also:
-
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.since 3.2.3Get 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
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
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
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
Enumeration of the property names.- Returns:
- property name enumeration
-
getNiceTextString
Returns a description of the service info suitable for printing.- Returns:
- service info description
-
setText
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
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()Returnstrue
if ServiceListener.resolveService will be called whenever new new information is received.- Returns:
- the persistent
-
getDomain
Returns the domain of the service info suitable for printing.- Returns:
- service domain
-
getProtocol
Returns the protocol of the service info suitable for printing.- Returns:
- service protocol
-
getApplication
Returns the application of the service info suitable for printing.- Returns:
- service application
-
getSubtype
Returns the sub type of the service info suitable for printing.- Returns:
- service sub type
-
getQualifiedNameMap
Returns a dictionary of the fully qualified name component of this service.- Returns:
- dictionary of the fully qualified name components
-
hasSameAddresses
Compare addresses of another ServiceInfo- Parameters:
other
- ServiceInfo to compare- Returns:
- true if addresses are the same, false if not
-
clone
-