|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jdbcimporter.EntityImporter
The EntityImporter class imports an entity into the database using a given import engine. It ensures that all the columns for the entity have their SQL Types defined properly. The data is parsed using the DelimiterParser defined by the EntityDef. Each column value may be transformed by a ColumnTranslator before the current row is passed to the ImportEngine.
Field Summary | |
protected int |
batchCount
The number of rows to import before calling executeBatch. |
protected int |
commitCount
The number of rows to import before calling commit on the connection. |
protected ImportEngine |
defaultEngine
The import engine that will be used. |
protected boolean |
failOnError
Flag indicating that the import should stop on the first error (default is false). |
protected java.util.List |
importListeners
The list of import listeners. |
protected static org.apache.commons.logging.Log |
LOG
The log for debug information. |
protected java.util.Random |
random
Random number generator used for columns that will be generated. |
protected boolean |
supportsBatch
The flag indicating the JDBC driver supports batch updates. |
protected boolean |
trimValues
The flag indicating that values should be trimmed after being read by the delimiter parser. |
Constructor Summary | |
EntityImporter()
|
Method Summary | |
void |
addImportListener(ImportListener listener)
Adds an import listener. |
protected java.lang.String |
columnValuesToString(ColumnValue[] values)
Convert the column values into a string representation for logging purposes. |
protected void |
fillInColumnTypes(ImportEntityDef entityDef)
Fill in the column types. |
protected ColumnValue[] |
fillInValues(net.sourceforge.jdbcimporter.EntityImporterState state,
ColumnValue[] values)
Fill in the column values with default values, if necessary, and call column translators for the values. |
protected void |
fireImportEntityBatchEvent(ImportEntityBatchEvent e)
Fire an import entity batch event to the listeners. |
protected void |
fireImportEntityRowEvent(ImportEntityRowEvent e)
Fire an import entity row event to the listeners. |
protected boolean |
importNextRow(net.sourceforge.jdbcimporter.EntityImporterState state,
java.lang.Object nextRow)
Import the next row. |
protected int |
processBatchUpdateException(ImportEntityDef entityDef,
java.util.List batchRows,
java.sql.BatchUpdateException bue)
Process batch update exception. |
void |
processEntity(ImportEntityDef entityDef)
Process the given entity definition by ensuring that all columns defined have an SQL Type, parsing the file with the appropriate DelimiterParser, applying any ColumnTranslator to each column value and using the ImportEngine to import the row. |
void |
removeImportListener(ImportListener listener)
Removes an import listener. |
void |
setBatchCount(int count)
Sets the number of records to import before executing a batch update. |
void |
setCommitCount(int count)
Sets the number of records to import before committing. |
void |
setFailonerror(boolean flag)
Sets a flag to indicate that the import should stop after the first error. |
void |
setImportEngine(ImportEngine newEngine)
Sets the import engine. |
void |
setSupportsBatch(boolean flag)
Sets a flag to indicate whether the connection supports batch updates. |
void |
setTrimValues(boolean flag)
Sets a flag to indicate that values should be trimmed after being read by the delimiter parser |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.commons.logging.Log LOG
protected ImportEngine defaultEngine
protected int batchCount
protected int commitCount
protected boolean supportsBatch
protected boolean trimValues
protected java.util.List importListeners
protected boolean failOnError
protected java.util.Random random
Constructor Detail |
public EntityImporter()
Method Detail |
public void setImportEngine(ImportEngine newEngine)
newEngine
- import enginepublic void setBatchCount(int count)
count
- the number of recordspublic void setCommitCount(int count)
count
- the number of recordspublic void setSupportsBatch(boolean flag)
flag
- whether the connection supports batch update or notpublic void setTrimValues(boolean flag)
flag
- flagpublic void setFailonerror(boolean flag)
flag
- flagpublic void processEntity(ImportEntityDef entityDef) throws java.sql.SQLException, java.io.IOException
entityDef
- entity definition to import
java.sql.SQLException
java.io.IOException
public void addImportListener(ImportListener listener)
listener
- the listenerpublic void removeImportListener(ImportListener listener)
listener
- the listenerprotected void fillInColumnTypes(ImportEntityDef entityDef) throws java.sql.SQLException
entityDef
- the entity definition
java.sql.SQLException
- if the column types could not be read from the database metaprotected boolean importNextRow(net.sourceforge.jdbcimporter.EntityImporterState state, java.lang.Object nextRow)
state
- the entity import statenextRow
- the string representing the row
protected ColumnValue[] fillInValues(net.sourceforge.jdbcimporter.EntityImporterState state, ColumnValue[] values) throws MalformedDataException
state
- the entity import statevalues
- the column values
MalformedDataException
- if the number of column values is invalidprotected int processBatchUpdateException(ImportEntityDef entityDef, java.util.List batchRows, java.sql.BatchUpdateException bue)
entityDef
- the entity definitionbatchRows
- the rows processed during this batchbue
- the batch update exception
protected void fireImportEntityRowEvent(ImportEntityRowEvent e)
e
- the import entity row eventprotected void fireImportEntityBatchEvent(ImportEntityBatchEvent e)
e
- the import batch eventprotected java.lang.String columnValuesToString(ColumnValue[] values)
values
- the column values
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |