java.lang.Object
org.cybergarage.upnp.event.Subscription

public class Subscriptionextends Object
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 Details

    • XMLNS

      public static final String XMLNS
      XML namespace of the UPnP eventing schema.
      See Also:
    • TIMEOUT_HEADER

      public static final String TIMEOUT_HEADER
      Prefix of the TIMEOUT header, whose value carries the seconds.
      See Also:
    • INFINITE_STRING

      public static final String INFINITE_STRING
      TIMEOUT header text standing for an unlimited subscription.
      See Also:
    • INFINITE_VALUE

      public static final int INFINITE_VALUE
      Sentinel lifetime in seconds marking a subscription as unlimited.
      See Also:
    • UUID

      public static final String UUID
      Prefix every SID header value carries.
      See Also:
    • SUBSCRIBE_METHOD

      public static final String SUBSCRIBE_METHOD
      HTTP method name that opens a subscription.
      See Also:
    • UNSUBSCRIBE_METHOD

      public static final String 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

      public static final String toTimeoutHeaderString(long time)
      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

      public static final long getTimeout(String headerValue)
      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

      public static final String createSID()
      Mints a fresh subscription identifier.
      Returns:
      a freshly generated UUID to serve as a subscription identifier
    • toSIDHeaderString

      public static final String toSIDHeaderString(String id)
      Prefixes a bare identifier to form a SID header value.
      Parameters:
      id - the bare subscription identifier, without the uuid: prefix
      Returns:
      the SID header value, the identifier with the uuid: prefix prepended
    • getSID

      public static final String getSID(String headerValue)
      Strips the uuid: prefix from a SID header value.
      Parameters:
      headerValue - the SID header contents to strip the prefix from
      Returns:
      the bare identifier, unchanged without the uuid: prefix, or "" when absent