java.lang.Object
org.cybergarage.upnp.UPnP
Global utility class for UPnP framework configuration and operations.
This class provides static methods and constants for configuring the UPnP framework, including network settings, XML parser configuration, and utility functions for UUID generation, server identification, and framework initialization.
The class serves as the main entry point for framework-wide configuration and provides constants used throughout the UPnP implementation.
Field Summary
Modifier and TypeFieldDescriptionstatic final intMaximum value for UPnP.org configuration IDs.static final intDefault extra time in seconds before considering a device expired.static final intDefault time-to-live value for multicast packets.static final StringINMPR03 protocol identifier.static final intNumber of discovery attempts over wireless interfaces for INMPR03.static final StringINMPR03 protocol version.static final StringFramework name used in server identification.static final intNumber of retry attempts for server operations.private static intHops a search message may cross.static final intEnable IPv6 administrative scope addresses.static final intEnable IPv6 global scope addresses.static final intEnable IPv6 link-local scope addresses.static final intEnable IPv6 site-local scope addresses.static final intEnable IPv6 subnet scope addresses.static final intEnable loopback address usage.static final intEnable IPv4-only addressing mode.static final intEnable IPv6-only addressing mode.static final intEnable SSDP search responses on multiple interfaces.static final StringFramework version used in server identification.static final StringName of the system properties used to identifies the default XML Parser.
The value of the properties MUST BE the fully qualified class name of
XML Parser which CyberLink should use.static final StringStandard XML declaration for UPnP documents.private static Parser/////////////////////////////////////////////Constructor Summary
ConstructorsConstructorDescriptionUPnP()Every constant, version string and protocol singleton below is static, so an instance carries nothing.Method Summary
Modifier and TypeMethodDescriptionstatic final intcaluculateConfigId(String configXml) Calculates a configuration ID from the given XML configuration.static final intCreates a boot ID for UPnP device identification.static final StringCreates a unique UUID for UPnP device identification.static final StringGenerates the server identification string for UPnP operations.static final intGets the current time-to-live value for multicast packets.static final ParserGets the XML parser used by the UPnP framework.static final voidInitializes the UPnP framework.static final booleanisEnabled(int value) Checks if a specific UPnP framework feature or configuration option is enabled.private static ParserThis method loads the default XML Parser using the following behavior: - First if present loads the parsers specified by the system propertyXML_CLASS_PROPERTTY
- Second by a fall-back technique, it tries to load the XMLParser from one
of the following classes:JaxpParser,kXML2Parser,XercesParserstatic final voidsetDisable(int value) Disables a specific UPnP framework feature or configuration option.static final voidsetEnable(int value) Enables a specific UPnP framework feature or configuration option.static final voidsetTimeToLive(int value) Sets the time-to-live value for multicast packets.static final voidsetXMLParser(Parser parser) Sets the XML parser to be used by the UPnP framework.private static final StringtoUUID(int seed) Formats a seed as a uuid-like string.
Field Details
XML_CLASS_PROPERTTY
Name of the system properties used to identifies the default XML Parser.
The value of the properties MUST BE the fully qualified class name of
XML Parser which CyberLink should use.- See Also:
NAME
Framework name used in server identification.- See Also:
VERSION
Framework version used in server identification.- See Also:
SERVER_RETRY_COUNT
public static final int SERVER_RETRY_COUNTNumber of retry attempts for server operations.- See Also:
DEFAULT_EXPIRED_DEVICE_EXTRA_TIME
public static final int DEFAULT_EXPIRED_DEVICE_EXTRA_TIMEDefault extra time in seconds before considering a device expired.- See Also:
INMPR03
INMPR03_VERSION
INMPR03_DISCOVERY_OVER_WIRELESS_COUNT
public static final int INMPR03_DISCOVERY_OVER_WIRELESS_COUNTNumber of discovery attempts over wireless interfaces for INMPR03.- See Also:
XML_DECLARATION
Standard XML declaration for UPnP documents.- See Also:
CONFIGID_UPNP_ORG_MAX
public static final int CONFIGID_UPNP_ORG_MAXMaximum value for UPnP.org configuration IDs.- See Also:
USE_ONLY_IPV6_ADDR
public static final int USE_ONLY_IPV6_ADDREnable IPv6-only addressing mode.- See Also:
USE_LOOPBACK_ADDR
public static final int USE_LOOPBACK_ADDREnable loopback address usage.- See Also:
USE_IPV6_LINK_LOCAL_SCOPE
public static final int USE_IPV6_LINK_LOCAL_SCOPEEnable IPv6 link-local scope addresses.- See Also:
USE_IPV6_SUBNET_SCOPE
public static final int USE_IPV6_SUBNET_SCOPEEnable IPv6 subnet scope addresses.- See Also:
USE_IPV6_ADMINISTRATIVE_SCOPE
public static final int USE_IPV6_ADMINISTRATIVE_SCOPEEnable IPv6 administrative scope addresses.- See Also:
USE_IPV6_SITE_LOCAL_SCOPE
public static final int USE_IPV6_SITE_LOCAL_SCOPEEnable IPv6 site-local scope addresses.- See Also:
USE_IPV6_GLOBAL_SCOPE
public static final int USE_IPV6_GLOBAL_SCOPEEnable IPv6 global scope addresses.- See Also:
USE_SSDP_SEARCHRESPONSE_MULTIPLE_INTERFACES
public static final int USE_SSDP_SEARCHRESPONSE_MULTIPLE_INTERFACESEnable SSDP search responses on multiple interfaces.- See Also:
USE_ONLY_IPV4_ADDR
public static final int USE_ONLY_IPV4_ADDREnable IPv4-only addressing mode.- See Also:
xmlParser
/////////////////////////////////////////////DEFAULT_TTL
public static final int DEFAULT_TTLDefault time-to-live value for multicast packets.- See Also:
timeToLive
private static int timeToLiveHops a search message may cross.
Constructor Details
UPnP
public UPnP()Every constant, version string and protocol singleton below is static, so an instance carries nothing.
Method Details
getServerName
Generates the server identification string for UPnP operations.- Returns:
- a server identification string in the format "OS/Version UPnP/1.0 FrameworkName/FrameworkVersion"
setEnable
public static final void setEnable(int value) Enables a specific UPnP framework feature or configuration option.- Parameters:
value- the feature to enable (one of the USE_* constants)
setDisable
public static final void setDisable(int value) Disables a specific UPnP framework feature or configuration option.- Parameters:
value- the feature to disable (one of the USE_* constants)
isEnabled
public static final boolean isEnabled(int value) Checks if a specific UPnP framework feature or configuration option is enabled.- Parameters:
value- the feature to check (one of the USE_* constants)- Returns:
- true if the feature is enabled, false otherwise
toUUID
Formats a seed as a uuid-like string.- Parameters:
seed- the number to format- Returns:
- the uuid string
createUUID
Creates a unique UUID for UPnP device identification.- Returns:
- a UUID string in the standard UPnP format
createBootId
public static final int createBootId()Creates a boot ID for UPnP device identification.- Returns:
- a boot ID based on the current system time in seconds
caluculateConfigId
Calculates a configuration ID from the given XML configuration.- Parameters:
configXml- the XML configuration string- Returns:
- the calculated configuration ID
setXMLParser
Sets the XML parser to be used by the UPnP framework.- Parameters:
parser- the XML parser implementation
getXMLParser
Gets the XML parser used by the UPnP framework.- Returns:
- the XML parser implementation
- Throws:
RuntimeException- if no XML parser is available
loadDefaultXMLParser
This method loads the default XML Parser using the following behavior: - First if present loads the parsers specified by the system propertyXML_CLASS_PROPERTTY
- Second by a fall-back technique, it tries to load the XMLParser from one
of the following classes:JaxpParser,kXML2Parser,XercesParser- Returns:
Parserwhich has been loaded successfully or null otherwise
setTimeToLive
public static final void setTimeToLive(int value) Sets the time-to-live value for multicast packets.- Parameters:
value- the TTL value to set
getTimeToLive
public static final int getTimeToLive()Gets the current time-to-live value for multicast packets.- Returns:
- the current TTL value
initialize
public static final void initialize()Initializes the UPnP framework. This method ensures the static initialization block is executed.