Package javax.jmdns.impl
Class HostInfo
- java.lang.Object
-
- javax.jmdns.impl.HostInfo
-
- All Implemented Interfaces:
DNSStatefulObject
public class HostInfo extends java.lang.Object implements DNSStatefulObject
HostInfo information on the local host to be able to cope with change of addresses.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
HostInfo.HostInfoState
-
Nested classes/interfaces inherited from interface javax.jmdns.impl.DNSStatefulObject
DNSStatefulObject.DefaultImplementation, DNSStatefulObject.DNSStatefulObjectSemaphore
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.InetAddress
_address
protected java.net.NetworkInterface
_interfaze
protected java.lang.String
_name
private HostInfo.HostInfoState
_state
private static org.slf4j.Logger
logger
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
advanceState(DNSTask task)
Sets the state and notifies all objects that wait on the ServiceInfo.java.util.Collection<DNSRecord>
answers(DNSRecordClass recordClass, boolean unique, int ttl)
void
associateWithTask(DNSTask task, DNSState state)
Sets the task associated with this Object.boolean
cancelState()
Sets the state and notifies all objects that wait on the ServiceInfo.boolean
closeState()
Sets the state and notifies all objects that wait on the ServiceInfo.boolean
conflictWithRecord(DNSRecord.Address record)
JmDNSImpl
getDns()
Returns the DNS associated with this object.private DNSRecord.Address
getDNS4AddressRecord(boolean unique, int ttl)
private DNSRecord.Pointer
getDNS4ReverseAddressRecord(boolean unique, int ttl)
private DNSRecord.Address
getDNS6AddressRecord(boolean unique, int ttl)
private DNSRecord.Pointer
getDNS6ReverseAddressRecord(boolean unique, int ttl)
(package private) DNSRecord.Address
getDNSAddressRecord(DNSRecordType type, boolean unique, int ttl)
(package private) DNSRecord.Pointer
getDNSReverseAddressRecord(DNSRecordType type, boolean unique, int ttl)
(package private) java.net.Inet4Address
getInet4Address()
(package private) java.net.Inet6Address
getInet6Address()
java.net.InetAddress
getInetAddress()
java.net.NetworkInterface
getInterface()
java.lang.String
getName()
(package private) java.lang.String
incrementHostName()
boolean
isAnnounced()
Returns true, if this is an announced state.boolean
isAnnouncing()
Returns true, if this is an announcing state.boolean
isAssociatedWithTask(DNSTask task, DNSState state)
Checks if this object is associated with the task and in the same state.boolean
isCanceled()
Returns true, if this is a canceled state.boolean
isCanceling()
Returns true, if this is a canceling state.boolean
isClosed()
Returns true, if this is a closed state.boolean
isClosing()
Returns true, if this is a closing state.boolean
isProbing()
Returns true, if this is a probing state.private static java.net.InetAddress
loopbackAddress()
static HostInfo
newHostInfo(java.net.InetAddress address, JmDNSImpl dns, java.lang.String jmdnsName)
boolean
recoverState()
Sets the state and notifies all objects that wait on the ServiceInfo.void
removeAssociationWithTask(DNSTask task)
Remove the association of the task with this Object.boolean
revertState()
Sets the state and notifies all objects that wait on the ServiceInfo.(package private) boolean
shouldIgnorePacket(java.net.DatagramPacket packet)
java.lang.String
toString()
boolean
waitForAnnounced(long timeout)
Waits for the object to be announced.boolean
waitForCanceled(long timeout)
Waits for the object to be canceled.
-
-
-
Field Detail
-
logger
private static org.slf4j.Logger logger
-
_name
protected java.lang.String _name
-
_address
protected java.net.InetAddress _address
-
_interfaze
protected java.net.NetworkInterface _interfaze
-
_state
private final HostInfo.HostInfoState _state
-
-
Constructor Detail
-
HostInfo
private HostInfo(java.net.InetAddress address, java.lang.String name, JmDNSImpl dns)
-
-
Method Detail
-
newHostInfo
public static HostInfo newHostInfo(java.net.InetAddress address, JmDNSImpl dns, java.lang.String jmdnsName)
- Parameters:
address
- IP address to binddns
- JmDNS instancejmdnsName
- JmDNS name- Returns:
- new HostInfo
-
loopbackAddress
private static java.net.InetAddress loopbackAddress()
-
getName
public java.lang.String getName()
-
getInetAddress
public java.net.InetAddress getInetAddress()
-
getInet4Address
java.net.Inet4Address getInet4Address()
-
getInet6Address
java.net.Inet6Address getInet6Address()
-
getInterface
public java.net.NetworkInterface getInterface()
-
conflictWithRecord
public boolean conflictWithRecord(DNSRecord.Address record)
-
incrementHostName
java.lang.String incrementHostName()
-
shouldIgnorePacket
boolean shouldIgnorePacket(java.net.DatagramPacket packet)
-
getDNSAddressRecord
DNSRecord.Address getDNSAddressRecord(DNSRecordType type, boolean unique, int ttl)
-
getDNS4AddressRecord
private DNSRecord.Address getDNS4AddressRecord(boolean unique, int ttl)
-
getDNS6AddressRecord
private DNSRecord.Address getDNS6AddressRecord(boolean unique, int ttl)
-
getDNSReverseAddressRecord
DNSRecord.Pointer getDNSReverseAddressRecord(DNSRecordType type, boolean unique, int ttl)
-
getDNS4ReverseAddressRecord
private DNSRecord.Pointer getDNS4ReverseAddressRecord(boolean unique, int ttl)
-
getDNS6ReverseAddressRecord
private DNSRecord.Pointer getDNS6ReverseAddressRecord(boolean unique, int ttl)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
answers
public java.util.Collection<DNSRecord> answers(DNSRecordClass recordClass, boolean unique, int ttl)
-
getDns
public JmDNSImpl getDns()
Returns the DNS associated with this object.- Specified by:
getDns
in interfaceDNSStatefulObject
- Returns:
- DNS resolver
-
advanceState
public boolean advanceState(DNSTask task)
Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
advanceState
in interfaceDNSStatefulObject
- Parameters:
task
- associated task- Returns:
true
if the state was changed by this thread,false
otherwise.- See Also:
DNSState.advance()
-
removeAssociationWithTask
public void removeAssociationWithTask(DNSTask task)
Remove the association of the task with this Object.- Specified by:
removeAssociationWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated task
-
revertState
public boolean revertState()
Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
revertState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.- See Also:
DNSState.revert()
-
associateWithTask
public void associateWithTask(DNSTask task, DNSState state)
Sets the task associated with this Object.- Specified by:
associateWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated taskstate
- state of the task
-
isAssociatedWithTask
public boolean isAssociatedWithTask(DNSTask task, DNSState state)
Checks if this object is associated with the task and in the same state.- Specified by:
isAssociatedWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated taskstate
- state of the task- Returns:
true
is the task is associated with this object,false
otherwise.
-
cancelState
public boolean cancelState()
Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
cancelState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
closeState
public boolean closeState()
Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
closeState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
recoverState
public boolean recoverState()
Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
recoverState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
isProbing
public boolean isProbing()
Returns true, if this is a probing state.- Specified by:
isProbing
in interfaceDNSStatefulObject
- Returns:
true
if probing state,false
otherwise
-
isAnnouncing
public boolean isAnnouncing()
Returns true, if this is an announcing state.- Specified by:
isAnnouncing
in interfaceDNSStatefulObject
- Returns:
true
if announcing state,false
otherwise
-
isAnnounced
public boolean isAnnounced()
Returns true, if this is an announced state.- Specified by:
isAnnounced
in interfaceDNSStatefulObject
- Returns:
true
if announced state,false
otherwise
-
isCanceling
public boolean isCanceling()
Returns true, if this is a canceling state.- Specified by:
isCanceling
in interfaceDNSStatefulObject
- Returns:
true
if canceling state,false
otherwise
-
isCanceled
public boolean isCanceled()
Returns true, if this is a canceled state.- Specified by:
isCanceled
in interfaceDNSStatefulObject
- Returns:
true
if canceled state,false
otherwise
-
isClosing
public boolean isClosing()
Returns true, if this is a closing state.- Specified by:
isClosing
in interfaceDNSStatefulObject
- Returns:
true
if closing state,false
otherwise
-
isClosed
public boolean isClosed()
Returns true, if this is a closed state.- Specified by:
isClosed
in interfaceDNSStatefulObject
- Returns:
true
if closed state,false
otherwise
-
waitForAnnounced
public boolean waitForAnnounced(long timeout)
Waits for the object to be announced.- Specified by:
waitForAnnounced
in interfaceDNSStatefulObject
- Parameters:
timeout
- the maximum time to wait in milliseconds.- Returns:
true
if the object is announced,false
otherwise
-
waitForCanceled
public boolean waitForCanceled(long timeout)
Waits for the object to be canceled.- Specified by:
waitForCanceled
in interfaceDNSStatefulObject
- Parameters:
timeout
- the maximum time to wait in milliseconds.- Returns:
true
if the object is canceled,false
otherwise
-
-