net.sf.anupam.csv package
Provides a framework for parsing and reading CSV files transparently, via meta-data definitions, a'la Hibernate.
This allows yor application's CSV processing and parsing logic to be completely transparent and dependent only
on POJO JavaBean representation of the the CSV records.
The main class for the framework is {@link net.sf.anupam.csv.CSVParser CSVParser}, which provides a {@link java.lang.Iterable Iterable}
interface for parsing and retrieving the POJO beans from the CSV records transparently. Configuration of the parser is done via
XML mapping files.
The {@link net.sf.anupam.csv.CSVParserFactory CSVParserFactory} is the main factory for creation and
instantiation on the CSV parsers.
Implementation of the framework is based on Stephen Ostermiller's excellent
CSV parsing engine.
Configuration
Configuration of the CSV to POJO mapping is done via an XML mapping file, which
should be named csv-mapping.xml . The file needs to be present
in the CLASSPATH at the root level.
The parser framework provides convenience
Xdoclet tagsets and
templates for auto-generation of the mapping XML file directly from the
POJOs being mapped. This is similar to the Xdoclet support
for Hibernate persistance framework,
and behaves in a similar fashion in terms of the mapping and configuration
generation.
Format of the file is:
<?xml version="1.0"?>
<csv-mapping>
<bean-mapping name="declarative name of the POJO bean to be mapped"
class="fully qualified name of the POJO's class">
</bean-mapping>
</csv-mapping>
Logging and Debugging
The framework uses the Jakarta Commons logging as its logging framework.
Any standard setup (including Log4j) can be used as the actual logger.
Notes
- Note that the current implementation is read-only
and does not offer any mechanism for writing out Java objects to CSV files.
- The current implementation is Java 1.5 only
|