Class Device

  • All Implemented Interfaces:
    java.lang.Comparable<Device>

    public class Device
    extends java.lang.Object
    implements java.lang.Comparable<Device>
    Class to represent an UPnP device.
    • Constructor Summary

      Constructors 
      Constructor Description
      Device​(java.net.InetAddress inetAddress)  
    • Constructor Detail

      • Device

        public Device​(java.net.InetAddress inetAddress)
    • 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 the inetAddress of the device.
        Returns:
        the inetAddress
      • getLocalAddress

        public java.net.InetAddress getLocalAddress()
        Gets the localAddress of the device.
        Returns:
        the localAddress
      • setLocalAddress

        public void setLocalAddress​(java.net.InetAddress localAddress)
        Sets the localAddress.
        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 interface java.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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object