Class WebSocketExtension

  • Direct Known Subclasses:
    PerMessageCompressionExtension

    public class WebSocketExtension
    extends java.lang.Object
    A class to hold the name and the parameters of a WebSocket extension.
    • Field Detail

      • mName

        private final java.lang.String mName
      • mParameters

        private final java.util.Map<java.lang.String,​java.lang.String> mParameters
    • Constructor Detail

      • WebSocketExtension

        public WebSocketExtension​(java.lang.String name)
        Constructor with an extension name.
        Parameters:
        name - The extension name.
        Throws:
        java.lang.IllegalArgumentException - The given name is not a valid token.
      • WebSocketExtension

        public WebSocketExtension​(WebSocketExtension source)
        Copy constructor.
        Parameters:
        source - A source extension. Must not be null.
        Throws:
        java.lang.IllegalArgumentException - The given argument is null.
        Since:
        1.6
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the extension name.
        Returns:
        The extension name.
      • getParameters

        public java.util.Map<java.lang.String,​java.lang.String> getParameters()
        Get the parameters.
        Returns:
        The parameters.
      • containsParameter

        public boolean containsParameter​(java.lang.String key)
        Check if the parameter identified by the key is contained.
        Parameters:
        key - The name of the parameter.
        Returns:
        true if the parameter is contained.
      • getParameter

        public java.lang.String getParameter​(java.lang.String key)
        Get the value of the specified parameter.
        Parameters:
        key - The name of the parameter.
        Returns:
        The value of the parameter. null may be returned.
      • setParameter

        public WebSocketExtension setParameter​(java.lang.String key,
                                               java.lang.String value)
        Set a value to the specified parameter.
        Parameters:
        key - The name of the parameter.
        value - The value of the parameter. If not null, it must be a valid token. Note that RFC 6455 says "When using the quoted-string syntax variant, the value after quoted-string unescaping MUST conform to the 'token' ABNF."
        Returns:
        this object.
        Throws:
        java.lang.IllegalArgumentException -
        • The key is not a valid token.
        • The value is not null and it is not a valid token.
      • toString

        public java.lang.String toString()
        Stringify this object into the format "{name}[; {key}[={value}]]*".
        Overrides:
        toString in class java.lang.Object
      • extractValue

        private static java.lang.String extractValue​(java.lang.String[] pair)
      • createInstance

        private static WebSocketExtension createInstance​(java.lang.String name)