Package com.metratec.lib.upnp
Class Device
- java.lang.Object
-
- com.metratec.lib.upnp.Device
-
-
Constructor Summary
Constructors Constructor Description Device(java.net.InetAddress inetAddress)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Device obj)
Compare this device to another device.boolean
equals(java.lang.Object obj)
DeviceDescription
getDescription()
Gets the device description.DeviceDescription
getDescription(boolean block)
Loads the device description from the URL for UPnP description.java.net.InetAddress
getInetAddress()
Gets theinetAddress
of the device.java.net.InetAddress
getLocalAddress()
Gets thelocalAddress
of the device.java.lang.String
getLocation()
Get the URL for UPnP description.java.lang.String
getNls()
Get the network location signature.java.lang.String
getSt()
Get the search target.java.lang.String
getUsn()
Get the unique service name.int
hashCode()
void
setLocalAddress(java.net.InetAddress localAddress)
Sets thelocalAddress
.void
setLocation(java.lang.String location)
Set the URL for UPnP description.void
setNls(java.lang.String nls)
Set the network location signature.void
setSt(java.lang.String st)
Set the search target.void
setUsn(java.lang.String usn)
Set the unique service name.java.lang.String
toString()
void
updateDevice()
Updates the device details by sending targeted discovery message to the device.
-
-
-
Method Detail
-
updateDevice
public void updateDevice() throws java.lang.Exception
Updates the device details by sending targeted discovery message to the device.- Throws:
java.lang.Exception
-
getDescription
public DeviceDescription getDescription()
Gets the device description.The method may block, if the device description hasn't already been fetched.
- Returns:
- the device description
-
getDescription
public DeviceDescription getDescription(boolean block)
Loads the device description from the URL for UPnP description.The description is loaded asynchronously in a new thread. If the value of block is set to 'false', then the method will simply return 'null' without waiting for the thread to complete its execution. If block is set to 'true', the method waits for the thread to complete then returns the result.
- Parameters:
block
- should the method block until the thread completes its execution- Returns:
- the device description
-
getInetAddress
public java.net.InetAddress getInetAddress()
Gets theinetAddress
of the device.- Returns:
- the
inetAddress
-
getLocalAddress
public java.net.InetAddress getLocalAddress()
Gets thelocalAddress
of the device.- Returns:
- the
localAddress
-
setLocalAddress
public void setLocalAddress(java.net.InetAddress localAddress)
Sets thelocalAddress
.- Parameters:
localAddress
- the address to set
-
getSt
public java.lang.String getSt()
Get the search target.- Returns:
- the search target
-
setSt
public void setSt(java.lang.String st)
Set the search target.- Parameters:
st
- the search target
-
getNls
public java.lang.String getNls()
Get the network location signature.- Returns:
- the network location signature
-
setNls
public void setNls(java.lang.String nls)
Set the network location signature.- Parameters:
nls
- the network location signature
-
getUsn
public java.lang.String getUsn()
Get the unique service name.- Returns:
- the unique service name
-
setUsn
public void setUsn(java.lang.String usn)
Set the unique service name.- Parameters:
usn
- the unique service name
-
getLocation
public java.lang.String getLocation()
Get the URL for UPnP description.- Returns:
- the URL for UPnP description
-
setLocation
public void setLocation(java.lang.String location)
Set the URL for UPnP description.- Parameters:
location
- the URL for UPnP description
-
compareTo
public int compareTo(Device obj)
Compare this device to another device. Devices are first compared based on their IP address bytes. If equal then the location is compared.- Specified by:
compareTo
in interfacejava.lang.Comparable<Device>
- Parameters:
obj
- device to compare to- Returns:
- negative value if this device is "less than" obj, 0 if this device "equals" obj, positive value if this device is "greater than" obj
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-