public class WebSocketExtension extends Object
A class to hold the name and the parameters of a WebSocket extension.
| Modifier and Type | Field and Description |
|---|---|
static String |
PERMESSAGE_DEFLATE
The name of <code>permessage-deflate</code> extension that is
defined in <a href="https://tools.ietf.org/html/rfc7692#section-7"
>7. The "permessage-deflate" Extension</a> in <a href=
"https://tools.ietf.org/html/rfc7692">RFC 7692</a>.
|
| Constructor and Description |
|---|
WebSocketExtension(String name)
Constructor with an extension name.
|
WebSocketExtension(WebSocketExtension source)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsParameter(String key)
Check if the parameter identified by the key is contained.
|
String |
getName()
Get the extension name.
|
String |
getParameter(String key)
Get the value of the specified parameter.
|
Map<String,String> |
getParameters()
Get the parameters.
|
static WebSocketExtension |
parse(String string)
Parse a string as a
WebSocketExtension. |
WebSocketExtension |
setParameter(String key,
String value)
Set a value to the specified parameter.
|
String |
toString()
Stringify this object into the format "websockets-javase[; {key}[={value}]]*".
|
public static final String PERMESSAGE_DEFLATE
The name of <code>permessage-deflate</code> extension that is defined in <a href="https://tools.ietf.org/html/rfc7692#section-7" >7. The "permessage-deflate" Extension</a> in <a href= "https://tools.ietf.org/html/rfc7692">RFC 7692</a>.
public WebSocketExtension(String name)
Constructor with an extension name.
name - The extension name.IllegalArgumentException - The given name is not a valid token.public WebSocketExtension(WebSocketExtension source)
Copy constructor.
source - A source extension. Must not be null.IllegalArgumentException - The given argument is null.public String getName()
Get the extension name.
public Map<String,String> getParameters()
Get the parameters.
public boolean containsParameter(String key)
Check if the parameter identified by the key is contained.
key - The name of the parameter.true if the parameter is contained.public String getParameter(String key)
Get the value of the specified parameter.
key - The name of the parameter.null may be returned.public WebSocketExtension setParameter(String key, String value)
Set a value to the specified parameter.
key - The name of the parameter.value - The value of the parameter. If not null, it must be
a valid token. Note that <a href="http://tools.ietf.org/html/rfc6455"
>RFC 6455</a> says "<i>When using the quoted-string syntax
variant, the value after quoted-string unescaping MUST
conform to the 'token' ABNF.</i>"this object.IllegalArgumentException - <ul>
<li>The key is not a valid token.
<li>The value is not null and it is not a valid token.
</ul>public String toString()
Stringify this object into the format "websockets-javase[; {key}[={value}]]*".
public static WebSocketExtension parse(String string)
Parse a string as a WebSocketExtension. The input string
should comply with the format described in <a href=
"https://tools.ietf.org/html/rfc6455#section-9.1">9.1. Negotiating
Extensions</a> in <a href="https://tools.ietf.org/html/rfc6455"
>RFC 6455</a>.
string - A string that represents a WebSocket extension.WebSocketExtension instance that represents
the given string. If the input string does not comply with
RFC 6455, null is returned.Copyright © 2021. All Rights Reserved.