|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.util.DataStreamParser
DataStreamParser is used to parse a stream with a fixed format and generate ValueParser objects which can be used to extract the values in the desired type.
The class itself is abstract - a concrete subclass which implements the initTokenizer method such as CSVParser or TSVParser is required to use the functionality.
The class implements the java.util.Iterator interface for convenience. This allows simple use in a Velocity template for example:
#foreach ($row in $datastream) Name: $row.Name Description: $row.Description #end
Field Summary | |
private java.lang.String |
characterEncoding
The character encoding of the input |
private java.util.List |
columnNames
The list of column names. |
private static boolean |
DEBUG
Conditional compilation flag. |
private ValueParser |
lineValues
The parameter parser holding the values of columns for the current line. |
private boolean |
neverRead
Indicates whether or not the tokenizer has read anything yet. |
private java.io.StreamTokenizer |
tokenizer
The stream tokenizer for reading values from the input reader. |
Constructor Summary | |
DataStreamParser(java.io.Reader in,
java.util.List columnNames,
java.lang.String characterEncoding)
Create a new DataStreamParser instance. |
Method Summary | |
boolean |
hasNext()
Determine whether a further row of values exists in the input. |
boolean |
hasNextRow()
Determine whether a further row of values exists in the input. |
protected abstract void |
initTokenizer(java.io.StreamTokenizer tokenizer)
Initialize the StreamTokenizer instance used to read the lines from the input reader. |
java.lang.Object |
next()
Returns a ValueParser object containing the next row of values. |
ValueParser |
nextRow()
Returns a ValueParser object containing the next row of values. |
void |
readColumnNames()
Read the list of column names from the input reader using the tokenizer. |
void |
remove()
The optional Iterator.remove method is not supported. |
void |
setColumnNames(java.util.List columnNames)
Set the list of column names explicitly. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static final boolean DEBUG
private java.util.List columnNames
private java.io.StreamTokenizer tokenizer
private ValueParser lineValues
private boolean neverRead
private java.lang.String characterEncoding
Constructor Detail |
public DataStreamParser(java.io.Reader in, java.util.List columnNames, java.lang.String characterEncoding)
in
- the input reader.columnNames
- a list of column names.characterEncoding
- the character encoding of the input.Method Detail |
protected abstract void initTokenizer(java.io.StreamTokenizer tokenizer)
public void setColumnNames(java.util.List columnNames)
columnNames
- A list of column names.public void readColumnNames() throws java.io.IOException
java.io.IOException
- an IOException occurred.public boolean hasNextRow() throws java.io.IOException
java.io.IOException
- an IOException occurred.public ValueParser nextRow() throws java.io.IOException, java.util.NoSuchElementException
java.io.IOException
- an IOException occurred.java.util.NoSuchElementException
- there are no more rows in the input.public boolean hasNext()
hasNext
in interface java.util.Iterator
public java.lang.Object next() throws java.util.NoSuchElementException
next
in interface java.util.Iterator
java.util.NoSuchElementException
- there are no more rows in the input
or an IOException occurred.public void remove() throws java.lang.UnsupportedOperationException
remove
in interface java.util.Iterator
java.lang.UnsupportedOperationException
- the operation is not supported.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |