net.sourceforge.jdbcexporter
Class EntityExporter

java.lang.Object
  extended bynet.sourceforge.jdbcexporter.EntityExporter

public class EntityExporter
extends java.lang.Object

The EntityExporter class exports an entity into the database using a given export engine. It ensures that all the columns for the entity have their SQL Types defined properly. The data is formatted using the DelimiterFormatter defined by the EntityDef. Each column value may be transformed by a ColumnTranslator before the current row is passed to the ExportEngine.

Version:
0.6
Author:
Chris Nagy

Field Summary
protected  ExportEngine defaultEngine
          The export engine.
protected  java.util.List exportListeners
          The list of export listeners.
protected static org.apache.commons.logging.Log LOG
          The log for debug information.
 
Constructor Summary
EntityExporter()
           
 
Method Summary
 void addExportListener(ExportListener listener)
          Adds an export listener.
protected  void fillInColumnTypes(ExportEntityDef entityDef)
          Fill in the column SQL Types that are missing.
protected  ColumnValue[] fillInValues(ExportEntityDef entityDef, ColumnValue[] values)
          Returns the transformed column values.
protected  void fireExportEntityRowEvent(ExportEntityRowEvent e)
          Fire an export entity row event to the listeners.
 void processEntity(ExportEntityDef entityDef)
          Process the given entity definition by ensuring that all columns defined have an SQL Type, applying any ColumnTranslator to each column value, formatting the rows with the appropriate DelimiterFormatter and using the ExportEngine to export the row to a file.
 void removeExportListener(ExportListener listener)
          Removes an export listener.
 void setExportEngine(ExportEngine newEngine)
          Sets the export engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static org.apache.commons.logging.Log LOG
The log for debug information.


defaultEngine

protected ExportEngine defaultEngine
The export engine.


exportListeners

protected java.util.List exportListeners
The list of export listeners.

Constructor Detail

EntityExporter

public EntityExporter()
Method Detail

setExportEngine

public void setExportEngine(ExportEngine newEngine)
Sets the export engine.

Parameters:
newEngine - export engine

processEntity

public void processEntity(ExportEntityDef entityDef)
                   throws java.sql.SQLException,
                          java.io.IOException
Process the given entity definition by ensuring that all columns defined have an SQL Type, applying any ColumnTranslator to each column value, formatting the rows with the appropriate DelimiterFormatter and using the ExportEngine to export the row to a file.

Parameters:
entityDef - entity definition to export.
Throws:
java.sql.SQLException
java.io.IOException

addExportListener

public void addExportListener(ExportListener listener)
Adds an export listener.

Parameters:
listener - the listener

removeExportListener

public void removeExportListener(ExportListener listener)
Removes an export listener.

Parameters:
listener - the listener

fillInColumnTypes

protected void fillInColumnTypes(ExportEntityDef entityDef)
                          throws java.sql.SQLException
Fill in the column SQL Types that are missing.

Parameters:
entityDef - the entity definition
Throws:
java.sql.SQLException - if the column SQL Types could not be retrieved from the database meta

fillInValues

protected ColumnValue[] fillInValues(ExportEntityDef entityDef,
                                     ColumnValue[] values)
                              throws MalformedDataException
Returns the transformed column values.

Parameters:
entityDef - the entity definition
values - the rows' values
Returns:
column values the rows' values with defaults and column transformers applied.
Throws:
MalformedDataException - if the rows' values are incorrect

fireExportEntityRowEvent

protected void fireExportEntityRowEvent(ExportEntityRowEvent e)
Fire an export entity row event to the listeners.

Parameters:
e - the export entity row event