CSVObjects Framework

net.sf.anupam.csv
Class CSVParser

java.lang.Object
  extended by net.sf.anupam.csv.CSVParser
All Implemented Interfaces:
Iterable<Object>

public class CSVParser
extends Object
implements Iterable<Object>

Parses CSV files and creates the mapped POJO objects. This is the primary interface into the CSV parsing framework.

The class implements Iterable interface and can be used in the new Tiger for loops to iterate over all the CSV records in the file.

Configuration of the parser is performed via the csv-mapping.xml file. See the package description for more details.

Note that the class is not meant to be instantiated directly. Instead, the CSVParserFactory factory should be used for creation of instances.

Since:
1.5
Version:
$Revision: 1.3 $
Author:
Anupam Sengupta
See Also:
CSVParserFactory

Constructor Summary
CSVParser(CSVBeanMapping rootBeanMapping, CSVReader reader)
          Constructor for CSVParser.
 
Method Summary
protected  void finalize()
          Finalizes this parser and closes the reader.
 Iterator<Object> iterator()
          Returns the iterator for retrieving the parsed POJO beans.
 String toString()
          Dumps the root bean mapping configuration for this parser.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CSVParser

public CSVParser(CSVBeanMapping rootBeanMapping,
                 CSVReader reader)
Constructor for CSVParser. The constructor accepts the bean mapping to use as the starting CSV mapping configuration (a.k.a the root bean mapping) and the CSV reader/parser engine to use for actual parsing.

Parameters:
rootBeanMapping - the bean mapping to use as the starting configuration
reader - the CSV Reader object which will actually parse the CSV file
Method Detail

toString

public String toString()
Dumps the root bean mapping configuration for this parser. This is meant for debugging only.

Overrides:
toString in class Object
Returns:
the string representation of this parser
See Also:
Object.toString()

finalize

protected void finalize()
                 throws Throwable
Finalizes this parser and closes the reader.

Overrides:
finalize in class Object
Throws:
Throwable - thrown if the finalization fails
See Also:
Object.finalize()

iterator

public Iterator<Object> iterator()
Returns the iterator for retrieving the parsed POJO beans.

Specified by:
iterator in interface Iterable<Object>
Returns:
the iterator over the parsed beans
See Also:
Iterable.iterator()

SourceForge.net Logo

© Anupam Sengupta 2005