java.lang.Object
org.cybergarage.upnp.event.Subscription
Utility class for UPnP event subscription management.
This class provides constants and utility methods for managing UPnP event subscriptions, including timeout handling, subscription methods, and UUID generation. It serves as a helper class for the GENA (General Event Notification Architecture) protocol used in UPnP.
Key features:
- Subscription timeout management and conversion
- SUBSCRIBE and UNSUBSCRIBE method constants
- UUID generation and management
- XML namespace definitions for event messages
- Infinite timeout support
This class provides the foundational constants and utility methods used throughout the UPnP event notification system for managing subscription lifecycles.
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTIMEOUT header text standing for an unlimited subscription.static final intSentinel lifetime in seconds marking a subscription as unlimited.static final StringHTTP method name that opens a subscription.static final StringPrefix of the TIMEOUT header, whose value carries the seconds.static final StringHTTP method name that closes a subscription.static final StringPrefix every SID header value carries.static final StringXML namespace of the UPnP eventing schema.Constructor Summary
ConstructorsConstructorDescriptionThe header constants and the timeout parsers below are all static, so an instance carries nothing.Method Summary
All MethodsModifier and TypeMethodDescriptionstatic final StringMints a fresh subscription identifier.static final StringStrips the uuid: prefix from a SID header value.static final longgetTimeout(String headerValue) Parses the seconds out of a TIMEOUT header value.static final StringPrefixes a bare identifier to form a SID header value.static final StringtoTimeoutHeaderString(long time) Formats a lifetime as a TIMEOUT header value.
Field Details
XMLNS
XML namespace of the UPnP eventing schema.- See Also:
TIMEOUT_HEADER
Prefix of the TIMEOUT header, whose value carries the seconds.- See Also:
INFINITE_STRING
TIMEOUT header text standing for an unlimited subscription.- See Also:
INFINITE_VALUE
public static final int INFINITE_VALUESentinel lifetime in seconds marking a subscription as unlimited.- See Also:
UUID
SUBSCRIBE_METHOD
HTTP method name that opens a subscription.- See Also:
UNSUBSCRIBE_METHOD
HTTP method name that closes a subscription.- See Also:
Constructor Details
Subscription
public Subscription()The header constants and the timeout parsers below are all static, so an instance carries nothing.
Method Details
toTimeoutHeaderString
Formats a lifetime as a TIMEOUT header value.- Parameters:
time- the subscription lifetime in seconds, or INFINITE_VALUE for unlimited- Returns:
- the TIMEOUT header value, "infinite" when time is INFINITE_VALUE
getTimeout
Parses the seconds out of a TIMEOUT header value.- Parameters:
headerValue- the TIMEOUT header contents, whose seconds follow a '-'- Returns:
- the lifetime in seconds, or INFINITE_VALUE if absent or unparseable
createSID
Mints a fresh subscription identifier.- Returns:
- a freshly generated UUID to serve as a subscription identifier
toSIDHeaderString
getSID