public class Tokenizer extends InputStream
Modifier and Type | Class and Description |
---|---|
static interface |
Tokenizer.TokenValidator |
Modifier and Type | Field and Description |
---|---|
protected int |
lineNo |
protected int |
linePos |
protected int |
readOffset |
Constructor and Description |
---|
Tokenizer(InputStream in,
boolean enclosedContent) |
Modifier and Type | Method and Description |
---|---|
Token |
expect(String expected)
Expect at a valid token containing anything.
|
Token |
expect(String expected,
Tokenizer.TokenValidator validator) |
Token |
expectIdentifier(String message) |
Token |
expectInteger(String message) |
Token |
expectLiteral(String message) |
char |
expectSymbol(String expected,
char... symbols) |
protected TokenizerException |
failure(int startLineNo,
int startLinePos,
int length,
String format,
Object... params) |
protected TokenizerException |
failure(String format,
Object... params) |
protected TokenizerException |
failure(Throwable cause,
int startLineNo,
int startLinePos,
int length,
String message,
Object... params) |
TokenizerException |
failure(Token token,
String message,
Object... params) |
String |
getLine(int theLine)
Get the full non-delimited line content of the 1-indexed line.
|
boolean |
hasNext() |
Token |
next() |
protected Token |
nextSymbol(int lastByte) |
Token |
peek() |
Token |
peek(String expected) |
int |
read() |
String |
readBinary(char end)
Read the 'content' of encoded binary.
|
protected Token |
token(int off,
int len,
int linePos) |
Token |
token(int off,
int len,
int lineNo,
int linePos) |
available, close, mark, markSupported, read, read, reset, skip
protected int readOffset
protected int lineNo
protected int linePos
public Tokenizer(InputStream in, boolean enclosedContent) throws IOException
IOException
public int read()
read
in class InputStream
public Token expect(@Nonnull String expected) throws IOException
expected
- The expectation description.IOException
- If failed to read a token.public Token expect(@Nonnull String expected, @Nonnull Tokenizer.TokenValidator validator) throws IOException
IOException
public Token peek(@Nonnull String expected) throws IOException
IOException
public Token peek() throws IOException
IOException
public char expectSymbol(@Nonnull String expected, char... symbols) throws IOException
IOException
public Token expectIdentifier(@Nonnull String message) throws IOException
IOException
@Nonnull public Token expectInteger(String message) throws IOException
IOException
@Nonnull public Token expectLiteral(String message) throws IOException
IOException
public boolean hasNext() throws IOException
IOException
public Token next() throws IOException
IOException
protected Token nextSymbol(int lastByte) throws TokenizerException
TokenizerException
@Nonnull public String getLine(int theLine)
theLine
- The nine number.public String readBinary(char end) throws IOException
end
- The char that ends the binary content.TokenizerException
- On illegal content.IOException
@Nonnull public TokenizerException failure(Token token, String message, Object... params)
@Nonnull protected TokenizerException failure(int startLineNo, int startLinePos, int length, String format, Object... params)
@Nonnull protected TokenizerException failure(Throwable cause, int startLineNo, int startLinePos, int length, String message, Object... params)
@Nonnull protected TokenizerException failure(String format, Object... params)
Copyright © 2015–2017 morimekta.net. All rights reserved.