Package org.apache.fulcrum.parser
Klasse DataStreamParser
java.lang.Object
org.apache.fulcrum.parser.DataStreamParser
- Alle implementierten Schnittstellen:
Iterator<ValueParser>
,org.apache.avalon.framework.logger.LogEnabled
public abstract class DataStreamParser
extends Object
implements Iterator<ValueParser>, org.apache.avalon.framework.logger.LogEnabled
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
- Version:
- $Id$
- Autor:
- Sean Legassick
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected org.apache.avalon.framework.logger.Logger
Logger to use -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungDataStreamParser
(Reader in, List<String> columnNames, String characterEncoding) Create a new DataStreamParser instance. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
enableLogging
(org.apache.avalon.framework.logger.Logger logger) Provide a loggerboolean
hasNext()
Determine whether a further row of values exists in the input.boolean
Determine whether a further row of values exists in the input.protected abstract void
initTokenizer
(StreamTokenizer tokenizer) Initialize the StreamTokenizer instance used to read the lines from the input reader.next()
Returns a ValueParser object containing the next row of values.nextRow()
Returns a ValueParser object containing the next row of values.void
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
(List<String> columnNames) Set the list of column names explicitly.Von Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Von Schnittstelle geerbte Methoden java.util.Iterator
forEachRemaining
-
Felddetails
-
log
protected org.apache.avalon.framework.logger.Logger logLogger to use
-
-
Konstruktordetails
-
DataStreamParser
Create a new DataStreamParser instance. Requires a Reader to read the comma-separated values from, a list of column names and a character encoding.- Parameter:
in
- the input reader.columnNames
- a list of column names.characterEncoding
- the character encoding of the input.
-
-
Methodendetails
-
initTokenizer
Initialize the StreamTokenizer instance used to read the lines from the input reader. This must be implemented in subclasses to set up the tokenizing properties.- Parameter:
tokenizer
- the StreamTokenizer to use
-
enableLogging
public void enableLogging(org.apache.avalon.framework.logger.Logger logger) Provide a logger- Angegeben von:
enableLogging
in Schnittstelleorg.apache.avalon.framework.logger.LogEnabled
- Siehe auch:
-
setColumnNames
Set the list of column names explicitly.- Parameter:
columnNames
- A list of column names.
-
readColumnNames
Read the list of column names from the input reader using the tokenizer.- Löst aus:
IOException
- an IOException occurred.
-
hasNextRow
Determine whether a further row of values exists in the input.- Gibt zurück:
- true if the input has more rows.
- Löst aus:
IOException
- an IOException occurred.
-
nextRow
Returns a ValueParser object containing the next row of values.- Gibt zurück:
- a ValueParser object.
- Löst aus:
IOException
- an IOException occurred.NoSuchElementException
- there are no more rows in the input.
-
hasNext
public boolean hasNext()Determine whether a further row of values exists in the input.- Angegeben von:
hasNext
in SchnittstelleIterator<ValueParser>
- Gibt zurück:
- true if the input has more rows.
-
next
Returns a ValueParser object containing the next row of values.- Angegeben von:
next
in SchnittstelleIterator<ValueParser>
- Gibt zurück:
- a ValueParser object as an Object.
- Löst aus:
NoSuchElementException
- there are no more rows in the input or an IOException occurred.
-
remove
The optional Iterator.remove method is not supported.- Angegeben von:
remove
in SchnittstelleIterator<ValueParser>
- Löst aus:
UnsupportedOperationException
- the operation is not supported.
-