org.apache.turbine.util
Class TSVParser
java.lang.Object
|
+--org.apache.turbine.util.DataStreamParser
|
+--org.apache.turbine.util.TSVParser
- All Implemented Interfaces:
- java.util.Iterator
- public class TSVParser
- extends DataStreamParser
TSVParser is used to parse a stream with tab-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 TSV 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 $tsvfile)
Name: $row.Name
Description: $row.Description
#end
- Version:
- $Id$
- Author:
- Sean Legassick
Constructor Summary |
TSVParser(java.io.Reader in)
Create a new TSVParser instance. |
TSVParser(java.io.Reader in,
java.util.List columnNames)
Create a new TSVParser instance. |
TSVParser(java.io.Reader in,
java.util.List columnNames,
java.lang.String characterEncoding)
Create a new TSVParser instance. |
Method Summary |
protected void |
initTokenizer(java.io.StreamTokenizer tokenizer)
Initialize the StreamTokenizer instance used to read the lines
from the input reader. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
TSVParser
public TSVParser(java.io.Reader in)
- Create a new TSVParser instance. Requires a Reader to read the
tab-separated values from. The column headers must be set
independently either explicitly, or by reading the first line
of the TSV values.
- Parameters:
in
- the input reader.
TSVParser
public TSVParser(java.io.Reader in,
java.util.List columnNames)
- Create a new TSVParser instance. Requires a Reader to read the
tab-separated values from, and a list of column names.
- Parameters:
in
- the input reader.columnNames
- a list of column names.
TSVParser
public TSVParser(java.io.Reader in,
java.util.List columnNames,
java.lang.String characterEncoding)
- Create a new TSVParser instance. Requires a Reader to read the
tab-separated values from, a list of column names and a
character encoding.
- Parameters:
in
- the input reader.columnNames
- a list of column names.characterEncoding
- the character encoding of the input.
initTokenizer
protected void initTokenizer(java.io.StreamTokenizer tokenizer)
- Initialize the StreamTokenizer instance used to read the lines
from the input reader.
- Overrides:
initTokenizer
in class DataStreamParser
Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.