net.sf.jmatchparser.util.csv
Class AbstractCSVReader

java.lang.Object
  extended by net.sf.jmatchparser.util.csv.AbstractCSVReader
Direct Known Subclasses:
CSVReader, FixedWidthCSVReader, PropertiesCSVReader, XMLCSVReader, XPathCSVReader

public abstract class AbstractCSVReader
extends Object

Abstract base class to read data from several CSV-like file formats.


Constructor Summary
AbstractCSVReader()
           
 
Method Summary
abstract  void close()
          Close this reader.
abstract  String[] read()
          Read a line from the CSV file.
 String[] read(int columnCount)
          Read a line from the CSV file and pad it to the given number of columns with empty strings.
<T> Map<T,String>
read(T[] headers, boolean includeEmptyColumns)
          Read a line from the CSV file, and pass its columns into a Map using the given keys/headers.
 void writeTo(AbstractCSVWriter writer)
          Write the complete content of this reader to the given AbstractCSVWriter and close both reader and writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCSVReader

public AbstractCSVReader()
Method Detail

read

public final <T> Map<T,String> read(T[] headers,
                                    boolean includeEmptyColumns)
                         throws IOException
Read a line from the CSV file, and pass its columns into a Map using the given keys/headers.

Type Parameters:
T - Type of the keys
Parameters:
headers - Keys/Headers
includeEmptyColumns - Whether to include empty column values in the map
Throws:
IOException

read

public final String[] read(int columnCount)
                    throws IOException
Read a line from the CSV file and pad it to the given number of columns with empty strings.

Parameters:
columnCount - Desired number of columns
Returns:
The padded line
Throws:
IOException - if there are too many columns in the original line.

writeTo

public void writeTo(AbstractCSVWriter writer)
             throws IOException
Write the complete content of this reader to the given AbstractCSVWriter and close both reader and writer.

Parameters:
writer - The writer to write to
Throws:
IOException

read

public abstract String[] read()
                       throws IOException
Read a line from the CSV file.

Throws:
IOException

close

public abstract void close()
                    throws IOException
Close this reader.

Throws:
IOException


Copyright © 2011. All Rights Reserved.