Class GrammarUtil
- java.lang.Object
-
- org.glassfish.jersey.message.internal.GrammarUtil
-
final class GrammarUtil extends java.lang.ObjectClass containing static utility methods to work with HTTP headers.
-
-
Field Summary
Fields Modifier and Type Field Description static intCOMMENTRepresents comment type in the TYPE_TABLE.static intCONTROLRepresents control type in the TYPE_TABLE.private static boolean[]IS_TOKENconvenience table mapping chars to true if they are tokens.private static boolean[]IS_WHITE_SPACEConvenience table mapping chars to true if they are white space chars.static intQUOTED_STRINGRepresents quotes type in the TYPE_TABLE.static intSEPARATORRepresents separator type in the TYPE_TABLE.private static char[]SEPARATORSArray of chars representing separators.static intTOKENRepresents token type in the TYPE_TABLE.private static int[]TYPE_TABLEMapping of chars to types.private static char[]WHITE_SPACEArray of chars representing white spaces.
-
Constructor Summary
Constructors Modifier Constructor Description privateGrammarUtil()Prevents instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancontainsWhiteSpace(java.lang.String s)Returnstrueif string s contains a white space char.private static int[]createEventTable()private static boolean[]createTokenTable()private static boolean[]createWhiteSpaceTable()static java.lang.StringfilterToken(java.lang.CharSequence s, int start, int end)Filter a substring of a string by removing any new-line characters and un-escaping escaped characters.static java.lang.StringfilterToken(java.lang.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 intgetType(char c)Get the character type.static booleanisSeparator(char c)Returnstrueif the provided char is a separator.static booleanisToken(char c)Returnstrueif the provided char is a token.static booleanisTokenString(java.lang.String s)Returnstrueif all chars in string s are tokens.static booleanisWhiteSpace(char c)Returnstrueif the provided char is a white space.
-
-
-
Field Detail
-
TOKEN
public static final int TOKEN
Represents token type in the TYPE_TABLE.- See Also:
- Constant Field Values
-
QUOTED_STRING
public static final int QUOTED_STRING
Represents quotes type in the TYPE_TABLE.- See Also:
- Constant Field Values
-
COMMENT
public static final int COMMENT
Represents comment type in the TYPE_TABLE.- See Also:
- Constant Field Values
-
SEPARATOR
public static final int SEPARATOR
Represents separator type in the TYPE_TABLE.- See Also:
- Constant Field Values
-
CONTROL
public static final int CONTROL
Represents control type in the TYPE_TABLE.- See Also:
- Constant Field Values
-
WHITE_SPACE
private static final char[] WHITE_SPACE
Array of chars representing white spaces.
-
SEPARATORS
private static final char[] SEPARATORS
Array of chars representing separators.
-
TYPE_TABLE
private static final int[] TYPE_TABLE
Mapping of chars to types.
-
IS_WHITE_SPACE
private static final boolean[] IS_WHITE_SPACE
Convenience table mapping chars to true if they are white space chars.
-
IS_TOKEN
private static final boolean[] IS_TOKEN
convenience table mapping chars to true if they are tokens.
-
-
Method Detail
-
createEventTable
private static int[] createEventTable()
-
createWhiteSpaceTable
private static boolean[] createWhiteSpaceTable()
-
createTokenTable
private static boolean[] createTokenTable()
-
isWhiteSpace
public static boolean isWhiteSpace(char c)
Returnstrueif the provided char is a white space.- Parameters:
c- char to check.- Returns:
trueif c is a white space.
-
isToken
public static boolean isToken(char c)
Returnstrueif the provided char is a token.- Parameters:
c- char to check.- Returns:
trueif 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:
java.lang.IllegalArgumentException- in case the character value is greater than 127.
-
isSeparator
public static boolean isSeparator(char c)
Returnstrueif the provided char is a separator.- Parameters:
c- char to check.- Returns:
trueif c is a token.
-
isTokenString
public static boolean isTokenString(java.lang.String s)
Returnstrueif all chars in string s are tokens.- Parameters:
s- string to check for tokens.- Returns:
trueif all chars in s are tokens.
-
containsWhiteSpace
public static boolean containsWhiteSpace(java.lang.String s)
Returnstrueif string s contains a white space char.- Parameters:
s- string to check for white spaces.- Returns:
trueif s contains white spaces.
-
filterToken
public static java.lang.String filterToken(java.lang.CharSequence s, int start, int end)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
public static java.lang.String filterToken(java.lang.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).- 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.
-
-