public abstract class ParseUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
formatTime(long value)
Format the given long value as a CQL time literal, using the following time pattern:
hh:mm:ss[.fffffffff] . |
static boolean |
isBlank(int c)
Return
true if the given character
is a valid whitespace character in CQL, that is,
if it is a regular space, a tabulation sign,
or a new line sign. |
static boolean |
isIdentifierChar(int c)
Return
true if the given character
is allowed in a CQL identifier, that is,
if it is in the range: [0..9a..zA..Z-+._&] . |
static boolean |
isLongLiteral(String str)
Check whether the given string corresponds
to a valid CQL long literal.
|
static boolean |
isQuoted(String value)
Return
true if the given string is surrounded
by single quotes, and false otherwise. |
static Date |
parseDate(String str)
Parse the given string as a date, using one of the accepted ISO-8601 date patterns.
|
static Date |
parseDate(String str,
String pattern)
Parse the given string as a date, using the supplied date pattern.
|
static long |
parseTime(String str)
Parse the given string as a time, using the following time pattern:
hh:mm:ss[.fffffffff] . |
static String |
quote(String value)
Quote the given string; single quotes are escaped.
|
static int |
skipCQLId(String toParse,
int idx)
Assuming that idx points to the beginning of a CQL identifier in toParse, returns the
index of the first character after this identifier.
|
static int |
skipCQLValue(String toParse,
int idx)
Assuming that idx points to the beginning of a CQL value in toParse, returns the
index of the first character after this value.
|
static int |
skipSpaces(String toParse,
int idx)
Returns the index of the first character in toParse from idx that is not a "space".
|
static String |
unquote(String value)
Unquote the given string if it is quoted; single quotes are unescaped.
|
public static int skipSpaces(String toParse, int idx)
toParse
- the string to skip space on.idx
- the index to start skipping space from.public static int skipCQLValue(String toParse, int idx)
toParse
- the string to skip a value form.idx
- the index to start parsing a value from.idx
.IllegalArgumentException
- if idx doesn't point to the start of a valid CQL
value.public static int skipCQLId(String toParse, int idx)
toParse
- the string to skip an identifier from.idx
- the index to start parsing an identifier from.idx
.IllegalArgumentException
- if idx doesn't point to the start of a valid CQL
identifier.public static boolean isIdentifierChar(int c)
true
if the given character
is allowed in a CQL identifier, that is,
if it is in the range: [0..9a..zA..Z-+._&]
.c
- The character to inspect.true
if the given character
is allowed in a CQL identifier, false
otherwise.public static boolean isBlank(int c)
true
if the given character
is a valid whitespace character in CQL, that is,
if it is a regular space, a tabulation sign,
or a new line sign.c
- The character to inspect.true
if the given character
is a valid whitespace character, false
otherwise.public static boolean isLongLiteral(String str)
str
- The string to inspect.true
if the given string corresponds
to a valid CQL integer literal, false
otherwise.public static boolean isQuoted(String value)
true
if the given string is surrounded
by single quotes, and false
otherwise.value
- The string to inspect.true
if the given string is surrounded
by single quotes, and false
otherwise.public static String quote(String value)
''
).value
- The value to quote.public static String unquote(String value)
value
- The string to unquote.public static Date parseDate(String str) throws ParseException
DateUtils.parseStrictly()
method (that is used Cassandra side
to parse date strings)..ParseException
- If the given string is not a valid ISO-8601 date.public static Date parseDate(String str, String pattern) throws ParseException
DateUtils.parseStrictly()
method (that is used Cassandra side
to parse date strings)..ParseException
- If the given string cannot be parsed with the given pattern.public static long parseTime(String str) throws ParseException
hh:mm:ss[.fffffffff]
.
This method is loosely based on java.sql.Timestamp
.str
- The string to parse.ParseException
- if the string cannot be parsed.public static String formatTime(long value)
hh:mm:ss[.fffffffff]
.value
- A long value representing the number of nanoseconds since midnight.