|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object aima.basic.Tokenizer
public class Tokenizer
Replacement for StringTokenizer in java.util, beacuse of bug in the Sun's implementation.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_DELIMITERS
Default delimiters "\t\n\r\f": the space character, the tab character, the newline character, the carriage-return character, and the form-feed character. |
Constructor Summary | |
---|---|
Tokenizer(java.lang.String str)
Constructs a string tokenizer for the specified string. |
|
Tokenizer(java.lang.String str,
char delim)
Constructs a string tokenizer for the specified string. |
|
Tokenizer(java.lang.String str,
java.lang.String delim)
Constructs a string tokenizer for the specified string. |
|
Tokenizer(java.lang.String str,
java.lang.String delim,
boolean returnTokens)
Constructs a string tokenizer for the specified string. |
Method Summary | |
---|---|
int |
countTokens()
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception. |
boolean |
hasMoreElements()
Returns the same value as the hasMoreTokens method. |
boolean |
hasMoreTokens()
Tests if there are more tokens available from this tokenizer's string. |
java.lang.Object |
nextElement()
Returns the same value as the nextToken method, except that its declared return value is Object rather than String. |
java.lang.String |
nextToken()
Returns the next token from this string tokenizer. |
java.lang.String |
nextToken(java.lang.String delim)
Returns the next token in this string tokenizer's string. |
void |
reset()
Resets this tokenizer's state so the tokenizing starts from the begin. |
static java.lang.String[] |
tokenize(java.lang.String str,
java.lang.String delim,
boolean returnTokens)
Constructs a string tokenizer for the specified string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_DELIMITERS
Constructor Detail |
---|
public Tokenizer(java.lang.String str, java.lang.String delim, boolean returnTokens)
str
- a string to be parseddelim
- the delimitersreturnTokens
- flag indicating whether to return the delimiters as tokenspublic Tokenizer(java.lang.String str, java.lang.String delim)
str
- a string to be parseddelim
- the delimiterspublic Tokenizer(java.lang.String str, char delim)
str
- a string to be parseddelim
- the delimiterpublic Tokenizer(java.lang.String str)
str
- a string to be parsedMethod Detail |
---|
public boolean hasMoreTokens()
public java.lang.String nextToken() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there are no more tokens in this tokenizer's stringpublic java.lang.String nextToken(java.lang.String delim) throws java.util.NoSuchElementException
delim
- the new delimiters
java.util.NoSuchElementException
- if there are no more tokens in this tokenizer's string.public boolean hasMoreElements()
hasMoreElements
in interface java.util.Enumeration
public java.lang.Object nextElement()
nextElement
in interface java.util.Enumeration
java.util.NoSuchElementException
- if there are no more tokens in this tokenizer's stringpublic int countTokens()
public void reset()
public static java.lang.String[] tokenize(java.lang.String str, java.lang.String delim, boolean returnTokens)
str
- a string to be parseddelim
- the delimitersreturnTokens
- flag indicating whether to return the delimiters as tokens
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |