Class QuoteUtil
java.lang.Object
org.eclipse.jetty.websocket.api.util.QuoteUtil
Provide some consistent Http header value and Extension configuration parameter quoting support.
While QuotedStringTokenizer exists in jetty-util, and works great with http header values, using it in websocket-api is undesired.
- Using QuotedStringTokenizer would introduce a dependency to jetty-util that would need to be exposed via the WebAppContext classloader
- ABNF defined extension parameter parsing requirements of RFC-6455 (WebSocket) ABNF, is slightly different than the ABNF parsing defined in RFC-2616 (HTTP/1.1).
- Future HTTPbis ABNF changes for parsing will impact QuotedStringTokenizer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
ABNF from RFC 2616, RFC 822, and RFC 6455 specified characters requiring quoting.private static final char[]
private static final char
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
dehex
(byte b) static String
Remove quotes from a string, only if the input string start with and end with the same quote character.static void
escape
(StringBuilder buf, String str) static String
static String
join
(Collection<?> objs, String delim) static void
quote
(StringBuilder buf, String str) Simple quote of a string, escaping where needed.static void
quoteIfNeeded
(StringBuilder buf, String str, String delim) Append into buf the provided string, adding quotes if needed.Create an iterator of the input string, breaking apart the string at the provided delimiters, removing quotes and triming the parts of the string as needed.static String
-
Field Details
-
ABNF_REQUIRED_QUOTING
ABNF from RFC 2616, RFC 822, and RFC 6455 specified characters requiring quoting.- See Also:
-
UNICODE_TAG
private static final char UNICODE_TAG- See Also:
-
escapes
private static final char[] escapes
-
-
Constructor Details
-
QuoteUtil
public QuoteUtil()
-
-
Method Details
-
dehex
private static int dehex(byte b) -
dequote
Remove quotes from a string, only if the input string start with and end with the same quote character.- Parameters:
str
- the string to remove surrounding quotes from- Returns:
- the de-quoted string
-
escape
-
quote
Simple quote of a string, escaping where needed.- Parameters:
buf
- the StringBuilder to append tostr
- the string to quote
-
quoteIfNeeded
Append into buf the provided string, adding quotes if needed.Quoting is determined if any of the characters in the
delim
are found in the inputstr
.- Parameters:
buf
- the buffer to append tostr
- the string to possibly quotedelim
- the delimiter characters that will trigger automatic quoting
-
splitAt
Create an iterator of the input string, breaking apart the string at the provided delimiters, removing quotes and triming the parts of the string as needed.- Parameters:
str
- the input string to split apartdelims
- the delimiter characters to split the string on- Returns:
- the iterator of the parts of the string, trimmed, with quotes around the string part removed, and unescaped
-
unescape
-
join
-
join
-