|
||||||||||
| 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 Character |
_escape
Escape character, if available. |
protected boolean |
_isEscape
The current character is the escape character. |
Stack<Integer> |
_pushed
Stack of characters having been pushed back. |
protected Reader |
_reader
Input Reader. |
protected BalancingStreamTokenizer.State |
_state
Current state of the tokenizer. |
protected Stack<BalancingStreamTokenizer.State> |
_stateStack
Stack of previous states. |
BalancingStreamTokenizer.Token |
_token
|
protected boolean |
_wasEscape
The previous character was the escape character. |
| Constructor Summary | |
|---|---|
BalancingStreamTokenizer(Reader r)
Create a new balancing stream tokenizer. |
|
BalancingStreamTokenizer(Reader r,
Character escape)
Create a new balancing stream tokenizer. |
|
| Method Summary | |
|---|---|
void |
addKeyword(String kw)
Specify a new keyword. |
void |
addQuotes(String begin,
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 String |
escape(String s)
|
protected String |
findMatch(int c,
TreeSet<String> choices,
Lambda<String,String> notFoundLambda)
|
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 TreeSet<String> |
prefixSet(Set<String> set,
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 String |
unescape(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 Reader _reader
public Stack<Integer> _pushed
protected BalancingStreamTokenizer.State _state
protected Stack<BalancingStreamTokenizer.State> _stateStack
protected Character _escape
protected boolean _wasEscape
protected boolean _isEscape
public volatile BalancingStreamTokenizer.Token _token
| Constructor Detail |
|---|
public BalancingStreamTokenizer(Reader r)
r - reader to tokenize
public BalancingStreamTokenizer(Reader r,
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 IOException
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(String begin,
String end)
begin - the beginning quotation markend - the ending quotation markpublic void addKeyword(String kw)
kw - the new keyword
public String getNextToken()
throws IOException
IOException
public static TreeSet<String> prefixSet(Set<String> set,
String prefix)
set - parent setprefix - prefix string
protected String findMatch(int c,
TreeSet<String> choices,
Lambda<String,String> notFoundLambda)
throws IOException
IOExceptionprotected String escape(String s)
protected String unescape(String s)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||