| java.lang.Object org.apache.turbine.util.parser.DataStreamParser org.apache.turbine.util.parser.CSVParser
CSVParser | public class CSVParser extends DataStreamParser (Code) | | CSVParser is used to parse a stream with comma-separated values and
generate ParameterParser objects which can be used to
extract the values in the desired type.
The class extends the abstract class DataStreamParser and implements
initTokenizer with suitable values for CSV files to provide this
functionality.
The class (indirectly through DataStreamParser) implements the
java.util.Iterator interface for convenience.
This allows simple use in a Velocity template for example:
#foreach ($row in $csvfile)
Name: $row.Name
Description: $row.Description
#end
author: Sean Legassick author: Martin van den Bemt author: Henning P. Schmiedehausen version: $Id: CSVParser.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
protected void | initTokenizer(StreamTokenizer tokenizer) Initialize the StreamTokenizer instance used to read the lines
from the input reader. |
CSVParser | public CSVParser(Reader in)(Code) | | Create a new CSVParser instance. Requires a Reader to read the
comma-separated values from. The column headers must be set
independently either explicitly, or by reading the first line
of the CSV values.
Parameters: in - the input reader. |
CSVParser | public CSVParser(Reader in, List columnNames)(Code) | | Create a new CSVParser instance. Requires a Reader to read the
comma-separated values from, and a list of column names.
Parameters: in - the input reader. Parameters: columnNames - a list of column names. |
CSVParser | public CSVParser(Reader in, List columnNames, String characterEncoding)(Code) | | Create a new CSVParser instance. Requires a Reader to read the
comma-separated values from, a list of column names and a
character encoding.
Parameters: in - the input reader. Parameters: columnNames - a list of column names. Parameters: characterEncoding - the character encoding of the input. |
initTokenizer | protected void initTokenizer(StreamTokenizer tokenizer)(Code) | | Initialize the StreamTokenizer instance used to read the lines
from the input reader.
It is now only needed to set the fieldSeparator
|
Fields inherited from org.apache.turbine.util.parser.DataStreamParser | final protected static String EMPTYFIELDNAME(Code)(Java Doc)
|
|
|