|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.util.BalancingStreamTokenizer
public class BalancingStreamTokenizer
A tokenizer that splits a stream into string tokens while balancing quoting characters.
| Nested Class Summary | |
|---|---|
static class |
BalancingStreamTokenizer.KeywordStartsWithQuoteException
Keyword starts with quote exception. |
static class |
BalancingStreamTokenizer.KeywordStartsWithWhitespaceException
Keyword starts with whitespace exception. |
static class |
BalancingStreamTokenizer.QuoteStartsWithWhitespaceException
Quote starts with whitespace exception. |
static class |
BalancingStreamTokenizer.SetupException
Setup exception. |
static class |
BalancingStreamTokenizer.StartsWithWhitespaceException
Quote or keyword starts with whitespace exception. |
static class |
BalancingStreamTokenizer.State
State of the tokenizer. |
static class |
BalancingStreamTokenizer.Token
Kind of tokens to be returned. |
| Field Summary | |
|---|---|
protected java.lang.Character |
_escape
Escape character, if available. |
protected boolean |
_isEscape
The current character is the escape character. |
java.util.Stack<java.lang.Integer> |
_pushed
Stack of characters having been pushed back. |
protected java.io.Reader |
_reader
Input Reader. |
protected BalancingStreamTokenizer.State |
_state
Current state of the tokenizer. |
protected java.util.Stack<BalancingStreamTokenizer.State> |
_stateStack
Stack of previous states. |
BalancingStreamTokenizer.Token |
_token
|
protected boolean |
_wasEscape
The previous character was the escape character. |
| Constructor Summary | |
|---|---|
BalancingStreamTokenizer(java.io.Reader r)
Create a new balancing stream tokenizer. |
|
BalancingStreamTokenizer(java.io.Reader r,
java.lang.Character escape)
Create a new balancing stream tokenizer. |
|
| Method Summary | |
|---|---|
void |
addKeyword(java.lang.String kw)
Specify a new keyword. |
void |
addQuotes(java.lang.String begin,
java.lang.String end)
Specify a pair of quotes. |
void |
defaultThreeQuoteCurlySetup()
Setup a tokenizer that recognizes ", ' and ` quotes and { } braces. |
void |
defaultThreeQuoteDollarCurlySetup()
Setup a tokenizer that recognizes ", ' and ` quotes and ${ } braces. |
void |
defaultThreeQuoteSetup()
Setup a tokenizer that recognizes ", ' and ` quotes. |
void |
defaultTwoQuoteCurlySetup()
Setup a tokenizer that recognizes " and ' quotes and { } braces. |
void |
defaultTwoQuoteSetup()
Setup a tokenizer that recognizes " and ' quotes. |
void |
defaultWhitespaceSetup()
Setup a tokenizer with just whitespace. |
protected java.lang.String |
escape(java.lang.String s)
|
protected java.lang.String |
findMatch(int c,
java.util.TreeSet<java.lang.String> choices,
Lambda<java.lang.String,java.lang.String> notFoundLambda)
|
java.lang.String |
getNextToken()
Return the next token, or null if the end of the stream has been reached. |
BalancingStreamTokenizer.State |
getState()
Return a copy of the current state of the tokenizer. |
protected int |
nextToken()
Return the next token from the reader, or from the stack if it isn't empty. |
protected void |
popState()
Pops the top of the state stack and makes it the current state. |
static java.util.TreeSet<java.lang.String> |
prefixSet(java.util.Set<java.lang.String> set,
java.lang.String prefix)
Return the subset of the set whose entries begin with the prefix. |
protected void |
pushState()
Push the current state onto the stack. |
protected void |
pushToken(int token)
Push a token back onto the stack. |
void |
setState(BalancingStreamTokenizer.State state)
Set the stream tokenizer the the state specified. |
BalancingStreamTokenizer.Token |
token()
Returns the type of the current token. |
protected java.lang.String |
unescape(java.lang.String s)
|
void |
whitespace(int... c)
Specify one or more characters as whitespace. |
void |
whitespaceRange(int lo,
int hi)
Specify a range characters as whitespace. |
void |
wordChars(int... c)
Specify one or more characters as word characters. |
void |
wordRange(int lo,
int hi)
Specify a range characters as word characters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.io.Reader _reader
public java.util.Stack<java.lang.Integer> _pushed
protected BalancingStreamTokenizer.State _state
protected java.util.Stack<BalancingStreamTokenizer.State> _stateStack
protected java.lang.Character _escape
protected boolean _wasEscape
protected boolean _isEscape
public volatile BalancingStreamTokenizer.Token _token
| Constructor Detail |
|---|
public BalancingStreamTokenizer(java.io.Reader r)
r - reader to tokenize
public BalancingStreamTokenizer(java.io.Reader r,
java.lang.Character escape)
r - reader to tokenizeescape - escape character or null| Method Detail |
|---|
public void defaultWhitespaceSetup()
public void defaultTwoQuoteSetup()
public void defaultThreeQuoteSetup()
public void defaultTwoQuoteCurlySetup()
public void defaultThreeQuoteCurlySetup()
public void defaultThreeQuoteDollarCurlySetup()
protected int nextToken()
throws java.io.IOException
java.io.IOExceptionprotected void pushToken(int token)
token - token to push backpublic BalancingStreamTokenizer.State getState()
public void setState(BalancingStreamTokenizer.State state)
state - stateprotected void pushState()
protected void popState()
public BalancingStreamTokenizer.Token token()
public void wordRange(int lo,
int hi)
lo - the character beginning the word character range, inclusivehi - the character ending the word character range, inclusivepublic void wordChars(int... c)
c - the character(s)
public void whitespaceRange(int lo,
int hi)
lo - the character beginning the whitespace range, inclusivehi - the character ending the whitespace range, inclusivepublic void whitespace(int... c)
c - the character(s)
public void addQuotes(java.lang.String begin,
java.lang.String end)
begin - the beginning quotation markend - the ending quotation markpublic void addKeyword(java.lang.String kw)
kw - the new keyword
public java.lang.String getNextToken()
throws java.io.IOException
java.io.IOException
public static java.util.TreeSet<java.lang.String> prefixSet(java.util.Set<java.lang.String> set,
java.lang.String prefix)
set - parent setprefix - prefix string
protected java.lang.String findMatch(int c,
java.util.TreeSet<java.lang.String> choices,
Lambda<java.lang.String,java.lang.String> notFoundLambda)
throws java.io.IOException
java.io.IOExceptionprotected java.lang.String escape(java.lang.String s)
protected java.lang.String unescape(java.lang.String s)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||