java.lang.Object
org.cybergarage.upnp.xml.NodeData
org.cybergarage.upnp.xml.DeviceData
Data container for UPnP device information and metadata.
This class extends NodeData to represent device definitions from UPnP device descriptions. It encapsulates metadata about devices including description files, locations, and advertisement settings.
Key features:
- Device description file management
- Multiple location support (I2P enhancement)
- Advertisement configuration
- XML node data inheritance
- Device metadata handling
This class is used by UPnP devices to manage their description data and configuration, enabling proper device advertisement and service discovery functionality.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Advertiser/////////////////////////////////////////////private ListenerList/////////////////////////////////////////////private FileThe device description file.private String/////////////////////////////////////////////private InetAddress[]The addresses the http server binds to.private int/////////////////////////////////////////////private HTTPServerList/////////////////////////////////////////////private int/////////////////////////////////////////////private String/////////////////////////////////////////////private StringThe IPv6 location url of the device.private InetAddress[]The addresses SSDP binds to.private StringThe IPv4 multicast address for SSDP.private StringThe IPv6 multicast address for SSDP.private SSDPPacket/////////////////////////////////////////////private SSDPPacketThe IPv6 SSDP packet received.private intThe port used for SSDP.private SSDPSearchSocketList/////////////////////////////////////////////Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionFetches the advertiser scheduling this device's announcements.Fetches the listeners notified when a control action arrives.Fetches the file this description was parsed from.Fetches the URL this description was fetched from.Fetches the addresses the embedded HTTP server binds to.intFetches the port the embedded HTTP server listens on.Fetches the HTTP server list, building it on first use.intFetches the advertised lease duration in seconds.Fetches the control URL this device advertises.getLocation(boolean preferIPv6) I2P for multiple location support.Returns the IPv4 multicast address.Returns the IPv6 multicast address.Returns the SSDP bind addresses.Fetches the packet advertising this device.getSSDPPacket(boolean preferIPv6) I2P for multiple location support.intReturns the SSDP port used for binding.Fetches the SSDP search sockets, building them on first use.voidsetAdvertiser(Advertiser adv) Records the advertiser that schedules this device's announcements.voidsetDescriptionFile(File descriptionFile) Records the file this description was parsed from.voidsetDescriptionURI(String descriptionURI) Records the URL this description was fetched from.voidsetHTTPBindAddress(InetAddress[] inets) Records which addresses the embedded HTTP server binds to.voidsetHTTPPort(int port) Records the port the embedded HTTP server should listen on.voidsetLeaseTime(int val) Records the lease duration advertised in seconds.voidsetLocation(String location) Records the control URL, filing a bracketed host as the IPv6 location.voidSets the IPv4 multicast address.voidSets the IPv6 multicast address.voidsetSSDPBindAddress(InetAddress[] inets) Sets the SSDP bind addresses.voidsetSSDPPacket(SSDPPacket packet) Records the advertisement packet, filing a bracketed host as the IPv6 one.voidsetSSDPPort(int port) Sets the SSDP port for binding.
Field Details
descriptionURI
/////////////////////////////////////////////descriptionFile
The device description file.location
/////////////////////////////////////////////location_ipv6
The IPv6 location url of the device.leaseTime
private int leaseTime/////////////////////////////////////////////httpServerList
/////////////////////////////////////////////httpBinds
The addresses the http server binds to.httpPort
private int httpPort/////////////////////////////////////////////controlActionListenerList
/////////////////////////////////////////////ssdpSearchSocketList
/////////////////////////////////////////////ssdpMulticastIPv4
The IPv4 multicast address for SSDP.ssdpMulticastIPv6
The IPv6 multicast address for SSDP.ssdpPort
private int ssdpPortThe port used for SSDP.ssdpBinds
The addresses SSDP binds to.ssdpPacket
/////////////////////////////////////////////ssdpPacket_ipv6
The IPv6 SSDP packet received.advertiser
/////////////////////////////////////////////
Constructor Details
DeviceData
public DeviceData()Creates an empty device data holder.
Method Details
getDescriptionFile
Fetches the file this description was parsed from.- Returns:
- the local file backing the description, or null if this device was not registered from a file
getDescriptionURI
Fetches the URL this description was fetched from.- Returns:
- the URL the description was fetched from, or null if it was parsed from a file
setDescriptionFile
Records the file this description was parsed from.- Parameters:
descriptionFile- the local file this description was parsed from, or null when it was fetched over the network
setDescriptionURI
Records the URL this description was fetched from.- Parameters:
descriptionURI- the URL this description was fetched from, or null when it was parsed from a file
getLocation
Fetches the control URL this device advertises.- Returns:
- the control URL of this device, preferring the IPv4 form
getLocation
I2P for multiple location support.- Parameters:
preferIPv6- whether to prefer IPv6 address- Returns:
- the location string
setLocation
Records the control URL, filing a bracketed host as the IPv6 location.- Parameters:
location- the control URL to advertise; a host in brackets is filed as the IPv6 location, and a malformed URL is rejected with a warning
getLeaseTime
public int getLeaseTime()Fetches the advertised lease duration in seconds.- Returns:
- the advertised lease duration in seconds
setLeaseTime
public void setLeaseTime(int val) Records the lease duration advertised in seconds.- Parameters:
val- the advertised lease duration in seconds
getHTTPServerList
Fetches the HTTP server list, building it on first use.- Returns:
- the HTTP server list, lazily created on first use from the bind addresses and port
setHTTPBindAddress
Records which addresses the embedded HTTP server binds to.- Parameters:
inets- the addresses the embedded HTTP server binds to, or null for the default behaviour
getHTTPBindAddress
Fetches the addresses the embedded HTTP server binds to.- Returns:
- the addresses the embedded HTTP server binds to, or null when the default behaviour applies
getHTTPPort
public int getHTTPPort()Fetches the port the embedded HTTP server listens on.- Returns:
- the port the embedded HTTP server listens on
setHTTPPort
public void setHTTPPort(int port) Records the port the embedded HTTP server should listen on.- Parameters:
port- the port the embedded HTTP server should listen on
getControlActionListenerList
Fetches the listeners notified when a control action arrives.- Returns:
- the list notified when a control action message arrives
getSSDPSearchSocketList
Fetches the SSDP search sockets, building them on first use.- Returns:
- the SSDP search socket list, lazily created on first use from the bind addresses, port and multicast addresses
setSSDPPort
public void setSSDPPort(int port) Sets the SSDP port for binding.- Parameters:
port- The port to use for binding the SSDP service. The port will be used as source port for all SSDP messages
getSSDPPort
public int getSSDPPort()Returns the SSDP port used for binding.- Returns:
- The port used for binding the SSDP service. The port will be used as source port for all SSDP messages
setSSDPBindAddress
Sets the SSDP bind addresses.- Parameters:
inets- TheInetAddressthat will be bound for listing this service. Usenullfor the default behavior.- See Also:
getSSDPBindAddress
Returns the SSDP bind addresses.- Returns:
- The
InetAddressthat will be bound for this servicenullmeans that default behavior will be used
setMulticastIPv4Address
Sets the IPv4 multicast address.- Parameters:
ip- The IPv4 address used as destination address for Multicast communication
getMulticastIPv4Address
Returns the IPv4 multicast address.- Returns:
- The IPv4 address used for Multicast communication
setMulticastIPv6Address
Sets the IPv6 multicast address.- Parameters:
ip- The IPv6 address used as destination address for Multicast communication
getMulticastIPv6Address
Returns the IPv6 multicast address.- Returns:
- The IPv6 address used as destination address for Multicast communication
getSSDPPacket
Fetches the packet advertising this device.- Returns:
- the packet describing this device, preferring the IPv4 form
getSSDPPacket
I2P for multiple location support.- Parameters:
preferIPv6- whether to prefer IPv6 address- Returns:
- the SSDP packet
setSSDPPacket
Records the advertisement packet, filing a bracketed host as the IPv6 one.- Parameters:
packet- the packet to advertise; a bracketed host in its location is filed as the IPv6 packet, and a malformed URL is rejected with a warning
setAdvertiser
Records the advertiser that schedules this device's announcements.- Parameters:
adv- the advertiser to schedule this device's SSDP announcements with
getAdvertiser
Fetches the advertiser scheduling this device's announcements.- Returns:
- the advertiser scheduling this device's SSDP announcements, or null when none has been set