Package com.imsl.io
Class Tokenizer
java.lang.Object
com.imsl.io.Tokenizer
Breaks a line into tokens.
The Tokenizer divides a line into tokens separated by deliminators. There can be any number of deliminators set. All of the deliminators are treated equally.
There can be at most one quote character set. If it is set then deliminators inside of a quoted string are treated as part of the string and not as deliminators. The quotes are not returned as part of the token. To escape a quote, repeat it.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of times that the nextToken method can be called without generating an exception.booleanReturns true if a call to nextToken will not generate an exception.Returns the next token.voidSets the line to be tokenized.
-
Constructor Details
-
Tokenizer
Creates a Tokenizer.- Parameters:
deliminators- is a String containing the deliminator characters.quote- is a char containing the quote character. If 0 then quoting is disabled.mergeMultipleDeliminators- is true if multiple consecutive deliminators are to be treated as a single deliminator.
-
-
Method Details
-
parse
Sets the line to be tokenized. Any tokens left from the previous line are discarded.- Parameters:
line- is the line to be tokenized.
-
hasMoreTokens
public boolean hasMoreTokens()Returns true if a call to nextToken will not generate an exception. -
countTokens
public int countTokens()Returns the number of times that the nextToken method can be called without generating an exception. -
nextToken
Returns the next token.- Returns:
- the next token.
- Throws:
NoSuchElementException- if there are no more tokens to be returned.
-