Class GrammarUtil
java.lang.Object
org.glassfish.jersey.message.internal.GrammarUtil
Class containing static utility methods to work with HTTP headers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Represents comment type in the TYPE_TABLE.static final int
Represents control type in the TYPE_TABLE.private static final boolean[]
convenience table mapping chars to true if they are tokens.private static final boolean[]
Convenience table mapping chars to true if they are white space chars.static final int
Represents quotes type in the TYPE_TABLE.static final int
Represents separator type in the TYPE_TABLE.private static final char[]
Array of chars representing separators.static final int
Represents token type in the TYPE_TABLE.private static final int[]
Mapping of chars to types.private static final char[]
Array of chars representing white spaces. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returnstrue
if string s contains a white space char.private static int[]
private static boolean[]
private static boolean[]
static String
filterToken
(CharSequence s, int start, int end) Filter a substring of a string by removing any new-line characters and un-escaping escaped characters.static String
filterToken
(CharSequence s, int start, int end, boolean preserveBackslash) Filter a substring of a string by removing any new-line characters and un-escaping escaped characters (unless preserveBackslash is set totrue
).static int
getType
(char c) Get the character type.static boolean
isSeparator
(char c) Returnstrue
if the provided char is a separator.static boolean
isToken
(char c) Returnstrue
if the provided char is a token.static boolean
Returnstrue
if all chars in string s are tokens.static boolean
isWhiteSpace
(char c) Returnstrue
if the provided char is a white space.
-
Field Details
-
TOKEN
public static final int TOKENRepresents token type in the TYPE_TABLE.- See Also:
-
QUOTED_STRING
public static final int QUOTED_STRINGRepresents quotes type in the TYPE_TABLE.- See Also:
-
COMMENT
public static final int COMMENTRepresents comment type in the TYPE_TABLE.- See Also:
-
SEPARATOR
public static final int SEPARATORRepresents separator type in the TYPE_TABLE.- See Also:
-
CONTROL
public static final int CONTROLRepresents control type in the TYPE_TABLE.- See Also:
-
WHITE_SPACE
private static final char[] WHITE_SPACEArray of chars representing white spaces. -
SEPARATORS
private static final char[] SEPARATORSArray of chars representing separators. -
TYPE_TABLE
private static final int[] TYPE_TABLEMapping of chars to types. -
IS_WHITE_SPACE
private static final boolean[] IS_WHITE_SPACEConvenience table mapping chars to true if they are white space chars. -
IS_TOKEN
private static final boolean[] IS_TOKENconvenience table mapping chars to true if they are tokens.
-
-
Constructor Details
-
GrammarUtil
private GrammarUtil()Prevents instantiation.
-
-
Method Details
-
createEventTable
private static int[] createEventTable() -
createWhiteSpaceTable
private static boolean[] createWhiteSpaceTable() -
createTokenTable
private static boolean[] createTokenTable() -
isWhiteSpace
public static boolean isWhiteSpace(char c) Returnstrue
if the provided char is a white space.- Parameters:
c
- char to check.- Returns:
true
if c is a white space.
-
isToken
public static boolean isToken(char c) Returnstrue
if the provided char is a token.- Parameters:
c
- char to check.- Returns:
true
if c is a token.
-
getType
public static int getType(char c) Get the character type.- Parameters:
c
- char to check.- Returns:
- character type identifier.
- Throws:
IllegalArgumentException
- in case the character value is greater than 127.
-
isSeparator
public static boolean isSeparator(char c) Returnstrue
if the provided char is a separator.- Parameters:
c
- char to check.- Returns:
true
if c is a token.
-
isTokenString
Returnstrue
if all chars in string s are tokens.- Parameters:
s
- string to check for tokens.- Returns:
true
if all chars in s are tokens.
-
containsWhiteSpace
Returnstrue
if string s contains a white space char.- Parameters:
s
- string to check for white spaces.- Returns:
true
if s contains white spaces.
-
filterToken
Filter a substring of a string by removing any new-line characters and un-escaping escaped characters.- Parameters:
s
- character sequence to use for substring token filtering.start
- start filtering position in the string.end
- end filtering position in the string.- Returns:
- filtered substring.
-
filterToken
Filter a substring of a string by removing any new-line characters and un-escaping escaped characters (unless preserveBackslash is set totrue
).- Parameters:
s
- character sequence to use for substring token filtering.start
- start filtering position in the string.end
- end filtering position in the string.preserveBackslash
- if set totrue
, this method does not treat backslash as an escape character (treats it as a regular character instead)- Returns:
- filtered substring.
-