Public Member Functions | |
boolean | atEnd () |
void | consume (final String token) throws ParseException |
boolean | consumeBoolean () throws ParseException |
ByteString | consumeByteString () throws ParseException |
double | consumeDouble () throws ParseException |
float | consumeFloat () throws ParseException |
String | consumeIdentifier () throws ParseException |
int | consumeInt32 () throws ParseException |
long | consumeInt64 () throws ParseException |
String | consumeString () throws ParseException |
int | consumeUInt32 () throws ParseException |
long | consumeUInt64 () throws ParseException |
boolean | lookingAt (String text) |
boolean | lookingAtInteger () |
void | nextToken () |
ParseException | parseException (final String description) |
ParseException | parseExceptionPreviousToken (final String description) |
boolean | tryConsume (final String token) |
boolean | tryConsumeDouble () |
boolean | tryConsumeFloat () |
boolean | tryConsumeIdentifier () |
boolean | tryConsumeInt64 () |
boolean | tryConsumeString () |
boolean | tryConsumeUInt64 () |
UnknownFieldParseException | unknownFieldParseExceptionPreviousToken (final String unknownField, final String description) |
Private Member Functions | |
void | consumeByteString (List< ByteString > list) throws ParseException |
ParseException | floatParseException (final NumberFormatException e) |
ParseException | integerParseException (final NumberFormatException e) |
void | skipWhitespace () |
Tokenizer (final CharSequence text) | |
Private Attributes | |
int | column = 0 |
String | currentToken |
int | line = 0 |
final Matcher | matcher |
int | pos = 0 |
int | previousColumn = 0 |
int | previousLine = 0 |
final CharSequence | text |
Static Private Attributes | |
static final Pattern | DOUBLE_INFINITY |
static final Pattern | FLOAT_INFINITY |
static final Pattern | FLOAT_NAN = Pattern.compile("nanf?", Pattern.CASE_INSENSITIVE) |
static final Pattern | TOKEN |
static final Pattern | WHITESPACE = Pattern.compile("(\\s|(#.*$))++", Pattern.MULTILINE) |
Represents a stream of tokens parsed from a
.
The Java standard library provides many classes that you might think would be useful for implementing this, but aren't. For example:
Luckily, Java's regular expression support does manage to be useful to us. (Barely: We need
, which is new in Java 1.5.) So, we can use that, at least. Unfortunately, this implies that we need to have the entire input in one contiguous string.
Definition at line 741 of file TextFormat.java.
|
inlineprivate |
Construct a tokenizer that parses tokens from the given text.
Definition at line 776 of file TextFormat.java.
|
inline |
Are we at the end of the input?
Definition at line 800 of file TextFormat.java.
|
inline |
If the next token exactly matches
, consume it. Otherwise, throw a {}.
Definition at line 864 of file TextFormat.java.
|
inline |
If the next token is a boolean, consume it and return its value. Otherwise, throw a {}.
Definition at line 1083 of file TextFormat.java.
|
inline |
If the next token is a string, consume it, unescape it as a ByteString, and return it. Otherwise, throw a ParseException.
Definition at line 1123 of file TextFormat.java.
|
inlineprivate |
Like consumeByteString() but adds each token of the string to the given list. String literals (whether bytes or text) may come in multiple adjacent tokens which are automatically concatenated, like in C or Python.
Definition at line 1137 of file TextFormat.java.
|
inline |
If the next token is a double, consume it and return its value. Otherwise, throw a {}.
Definition at line 1007 of file TextFormat.java.
|
inline |
If the next token is a float, consume it and return its value. Otherwise, throw a {}.
Definition at line 1045 of file TextFormat.java.
|
inline |
If the next token is an identifier, consume it and return its value. Otherwise, throw a ParseException.
Definition at line 889 of file TextFormat.java.
|
inline |
If the next token is a 32-bit signed integer, consume it and return its value. Otherwise, throw a ParseException.
Definition at line 925 of file TextFormat.java.
|
inline |
If the next token is a 64-bit signed integer, consume it and return its value. Otherwise, throw a ParseException.
Definition at line 953 of file TextFormat.java.
|
inline |
If the next token is a string, consume it and return its (unescaped) value. Otherwise, throw a ParseException.
Definition at line 1105 of file TextFormat.java.
|
inline |
If the next token is a 32-bit unsigned integer, consume it and return its value. Otherwise, throw a ParseException.
Definition at line 939 of file TextFormat.java.
|
inline |
If the next token is a 64-bit unsigned integer, consume it and return its value. Otherwise, throw a ParseException.
Definition at line 980 of file TextFormat.java.
|
inlineprivate |
Constructs an appropriate ParseException for the given
when trying to parse a float or double.
Definition at line 1187 of file TextFormat.java.
|
inlineprivate |
Constructs an appropriate ParseException for the given
when trying to parse an integer.
Definition at line 1179 of file TextFormat.java.
|
inline |
Returns
if the current token's text is equal to that specified.
Definition at line 881 of file TextFormat.java.
|
inline |
Returns
if the next token is an integer, but does not consume it.
Definition at line 871 of file TextFormat.java.
|
inline |
Advance to the next token.
Definition at line 805 of file TextFormat.java.
|
inline |
Returns a ParseException with the current line and column numbers in the description, suitable for throwing.
Definition at line 1161 of file TextFormat.java.
|
inline |
Returns a ParseException with the line and column numbers of the previous token in the description, suitable for throwing.
Definition at line 1170 of file TextFormat.java.
|
inlineprivate |
Skip over any whitespace so that the matcher region starts at the next token.
Definition at line 840 of file TextFormat.java.
|
inline |
If the next token exactly matches
, consume it and return
. Otherwise, return
without doing anything.
Definition at line 851 of file TextFormat.java.
|
inline |
If the next token is a double, consume it and return
. Otherwise, return
without doing anything.
Definition at line 1032 of file TextFormat.java.
|
inline |
If the next token is a float, consume it and return
. Otherwise, return
without doing anything.
Definition at line 1070 of file TextFormat.java.
|
inline |
If the next token is an identifier, consume it and return
. Otherwise, return
without doing anything.
Definition at line 912 of file TextFormat.java.
|
inline |
If the next token is a 64-bit signed integer, consume it and return
. Otherwise, return
without doing anything.
Definition at line 967 of file TextFormat.java.
|
inline |
If the next token is a string, consume it and return true. Otherwise, return false.
Definition at line 1110 of file TextFormat.java.
|
inline |
If the next token is a 64-bit unsigned integer, consume it and return
. Otherwise, return
without doing anything.
Definition at line 994 of file TextFormat.java.
|
inline |
Returns a UnknownFieldParseException with the line and column numbers of the previous token in the description, and the unknown field name, suitable for throwing.
Definition at line 1195 of file TextFormat.java.
|
private |
Definition at line 751 of file TextFormat.java.
|
private |
Definition at line 744 of file TextFormat.java.
|
staticprivate |
Definition at line 769 of file TextFormat.java.
|
staticprivate |
Definition at line 771 of file TextFormat.java.
|
staticprivate |
Definition at line 773 of file TextFormat.java.
|
private |
Definition at line 750 of file TextFormat.java.
|
private |
Definition at line 743 of file TextFormat.java.
|
private |
Definition at line 747 of file TextFormat.java.
|
private |
Definition at line 756 of file TextFormat.java.
|
private |
Definition at line 755 of file TextFormat.java.
|
private |
Definition at line 742 of file TextFormat.java.
|
staticprivate |
Definition at line 761 of file TextFormat.java.
|
staticprivate |
Definition at line 760 of file TextFormat.java.