@CodeReview(reviewer="Kevin R. Dixon", date="2008-02-08", changesNeeded=true, comments={"Should this class be merged with CSVUtility?","To a large extend, this class seems like a generalization of CSV.","Please review."}, response=@CodeReviewResponse(respondent="Justin Basilico",date="2008-02-18",moreChangesNeeded=false,comments="No, its different enough that it could exist on its own.")) public class ReaderTokenizer extends java.lang.Object
Constructor and Description |
---|
ReaderTokenizer(java.io.Reader reader)
Creates a new instance of ReaderTokenizer
|
Modifier and Type | Method and Description |
---|---|
java.io.BufferedReader |
getBufferedReader()
Getter for bufferedReader
|
protected int |
getLastTokenNum()
Getter for lastTokenNum
|
boolean |
isValid()
Returns the status of the ReaderTokenizer
|
java.util.ArrayList<java.lang.String> |
readNextLine()
Reads the next line of the Reader, returning each token on the line as
an entry in an ArrayList
|
void |
setBufferedReader(java.io.BufferedReader bufferedReader)
Setter for bufferedReader
|
protected void |
setLastTokenNum(int lastTokenNum)
Setter for lastTokenNum
|
protected void |
setValid(boolean valid)
Setter for valid
|
static java.util.ArrayList<java.lang.String> |
tokenizeString(java.lang.String data)
Returns an ArrayList with each of the tokens as an entry in the array
|
static java.util.ArrayList<java.lang.String> |
tokenizeString(java.lang.String data,
int expectedTokenNum)
Returns an ArrayList with each of the tokens as an entry in the array
|
public ReaderTokenizer(java.io.Reader reader)
reader
- Input stream from which to parse linespublic boolean isValid()
public static java.util.ArrayList<java.lang.String> tokenizeString(java.lang.String data)
data
- String to tokenizepublic static java.util.ArrayList<java.lang.String> tokenizeString(java.lang.String data, int expectedTokenNum)
data
- String to tokenizeexpectedTokenNum
- Expected number of tokens on the line, may be greater than or less than
actual amount, but algorithm will be faster if the number is correct.
Throws run-time exception if less than zero.public java.util.ArrayList<java.lang.String> readNextLine() throws java.io.IOException
java.io.IOException
- if the read failsprotected void setValid(boolean valid)
valid
- status of the ReaderTokenizerprotected int getLastTokenNum()
protected void setLastTokenNum(int lastTokenNum)
lastTokenNum
- Number of tokens read in the last call to readNextLine()public java.io.BufferedReader getBufferedReader()
public void setBufferedReader(java.io.BufferedReader bufferedReader)
bufferedReader
- BufferedReader from which we will read lines