final class GrammarUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
COMMENT
Represents comment type in the TYPE_TABLE.
|
static int |
CONTROL
Represents control type in the TYPE_TABLE.
|
private static boolean[] |
IS_TOKEN
convenience table mapping chars to true if they are tokens.
|
private static boolean[] |
IS_WHITE_SPACE
Convenience table mapping chars to true if they are white space chars.
|
static int |
QUOTED_STRING
Represents quotes type in the TYPE_TABLE.
|
static int |
SEPARATOR
Represents separator type in the TYPE_TABLE.
|
private static char[] |
SEPARATORS
Array of chars representing separators.
|
static int |
TOKEN
Represents token type in the TYPE_TABLE.
|
private static int[] |
TYPE_TABLE
Mapping of chars to types.
|
private static char[] |
WHITE_SPACE
Array of chars representing white spaces.
|
Modifier | Constructor and Description |
---|---|
private |
GrammarUtil()
Prevents instantiation.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
containsWhiteSpace(java.lang.String s)
Returns
true if string s contains a white space char. |
private static int[] |
createEventTable() |
private static boolean[] |
createTokenTable() |
private static boolean[] |
createWhiteSpaceTable() |
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.
|
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 to
true ). |
static int |
getType(char c)
Get the character type.
|
static boolean |
isSeparator(char c)
Returns
true if the provided char is a separator. |
static boolean |
isToken(char c)
Returns
true if the provided char is a token. |
static boolean |
isTokenString(java.lang.String s)
Returns
true if all chars in string s are tokens. |
static boolean |
isWhiteSpace(char c)
Returns
true if the provided char is a white space. |
public static final int TOKEN
public static final int QUOTED_STRING
public static final int COMMENT
public static final int SEPARATOR
public static final int CONTROL
private static final char[] WHITE_SPACE
private static final char[] SEPARATORS
private static final int[] TYPE_TABLE
private static final boolean[] IS_WHITE_SPACE
private static final boolean[] IS_TOKEN
private static int[] createEventTable()
private static boolean[] createWhiteSpaceTable()
private static boolean[] createTokenTable()
public static boolean isWhiteSpace(char c)
true
if the provided char is a white space.c
- char to check.true
if c is a white space.public static boolean isToken(char c)
true
if the provided char is a token.c
- char to check.true
if c is a token.public static int getType(char c)
c
- char to check.java.lang.IllegalArgumentException
- in case the character value is greater than 127.public static boolean isSeparator(char c)
true
if the provided char is a separator.c
- char to check.true
if c is a token.public static boolean isTokenString(java.lang.String s)
true
if all chars in string s are tokens.s
- string to check for tokens.true
if all chars in s are tokens.public static boolean containsWhiteSpace(java.lang.String s)
true
if string s contains a white space char.s
- string to check for white spaces.true
if s contains white spaces.public static java.lang.String filterToken(java.lang.CharSequence s, int start, int end)
s
- character sequence to use for substring token filtering.start
- start filtering position in the string.end
- end filtering position in the string.public static java.lang.String filterToken(java.lang.CharSequence s, int start, int end, boolean preserveBackslash)
true
).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 to true
, this method does not treat backslash as an escape character
(treats it as a regular character instead)