Package com.neovisionaries.ws.client
Class WebSocketExtension
java.lang.Object
com.neovisionaries.ws.client.WebSocketExtension
- Direct Known Subclasses:
PerMessageCompressionExtension
A class to hold the name and the parameters of
a WebSocket extension.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
static final String
The name ofpermessage-deflate
extension that is defined in 7. The "permessage-deflate" Extension in RFC 7692. -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketExtension
(WebSocketExtension source) Copy constructor.WebSocketExtension
(String name) Constructor with an extension name. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsParameter
(String key) Check if the parameter identified by the key is contained.private static WebSocketExtension
createInstance
(String name) private static String
extractValue
(String[] pair) getName()
Get the extension name.getParameter
(String key) Get the value of the specified parameter.Get the parameters.static WebSocketExtension
Parse a string as aWebSocketExtension
.setParameter
(String key, String value) Set a value to the specified parameter.toString()
Stringify this object into the format "{name}[; {key}[={value}]]*".(package private) void
validate()
Validate this instance.
-
Field Details
-
PERMESSAGE_DEFLATE
The name ofpermessage-deflate
extension that is defined in 7. The "permessage-deflate" Extension in RFC 7692.- Since:
- 1.17
- See Also:
-
mName
-
mParameters
-
-
Constructor Details
-
WebSocketExtension
Constructor with an extension name.- Parameters:
name
- The extension name.- Throws:
IllegalArgumentException
- The given name is not a valid token.
-
WebSocketExtension
Copy constructor.- Parameters:
source
- A source extension. Must not benull
.- Throws:
IllegalArgumentException
- The given argument isnull
.- Since:
- 1.6
-
-
Method Details
-
getName
Get the extension name.- Returns:
- The extension name.
-
getParameters
Get the parameters.- Returns:
- The parameters.
-
containsParameter
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
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
Set a value to the specified parameter.- Parameters:
key
- The name of the parameter.value
- The value of the parameter. If notnull
, 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:
IllegalArgumentException
-- The key is not a valid token.
- The value is not
null
and it is not a valid token.
-
toString
Stringify this object into the format "{name}[; {key}[={value}]]*". -
validate
Validate this instance. This method is expected to be overridden.- Throws:
WebSocketException
-
parse
Parse a string as aWebSocketExtension
. The input string should comply with the format described in 9.1. Negotiating Extensions in RFC 6455.- Parameters:
string
- A string that represents a WebSocket extension.- Returns:
- A new
WebSocketExtension
instance that represents the given string. If the input string does not comply with RFC 6455,null
is returned.
-
extractValue
-
createInstance
-