net.sourceforge.jdbcimporter.config
Class ImportEntityConfigDelegate

java.lang.Object
  extended bynet.sourceforge.jdbcimporter.config.ImportEntityConfigDelegate
All Implemented Interfaces:
EntityConfigDelegate

public class ImportEntityConfigDelegate
extends java.lang.Object
implements EntityConfigDelegate

The ImportEntityConfigDelegate is an implementation of the EntityConfigDelegate that creates ImportEntityDef and ImportColumnDef. A custom object factory should be set before creating the EntityDef.

Version:
0.6
Author:
Chris Nagy

Field Summary
protected  CustomObjectFactory binaryDelimiterParserFactory
          Custom object factory that creates binary delimiter parsers.
static java.lang.String COLUMN_TRANSLATOR_ATTR
          The element name that contains the ColumnTranslator classname to use on all column values to be imported.
static java.lang.String COLUMN_TRANSLATOR_TAG
          The element name that contains the ColumnTranslator definition to use on all column values to be imported.
static java.lang.String COLUMN_TRANSLATOR_TYPE_ATTR
          The attribute name that contains the ColumnTranslator type that maps to a classname.
protected  CustomObjectFactory columnTranslatorFactory
          Custom object factory that creates column translators.
static java.lang.String DELIMITER_TAG
          The element name that contains the DelimiterParser definition.
static java.lang.String DELIMITER_TYPE_ATTR
          The attribute name in the DELIMITER_TAG element that contains contains the delimiter type.
protected  CustomObjectFactory delimiterParserFactory
          Custom object factory that creates delimiter parsers.
static java.lang.String GENERATE_ATTR
          The attribute name in the COLUMN_TAG element that defines whether the column is imported from the source file (false) or generated (true).
protected  GenerateEntityConfigDelegate generateColumnConfigDelegate
          Delegate used to create GenerateColumnDef.
static java.lang.String IMPORT_ENGINE_ATTR
          The attribute name that contains the class name of import engine used to import this entity.
protected static org.apache.commons.logging.Log LOG
          The log for debug information.
static java.lang.String ROW_TRANSLATOR_TAG
          The element name that contains the RowTranslator definition.
static java.lang.String ROW_TRANSLATOR_TYPE_ATTR
          The attribute name that contains the RowTranslator type that maps to a classname.
protected  CustomObjectFactory rowTranslatorFactory
          Custom object factory that creates row translators.
static java.lang.String SOURCE_ATTR
          The attribute name that contains the name of data file to import with this entity.
static java.lang.String SOURCE_ENCODING_ATTR
          The attribute name that contains the encoding of the source file.
 
Constructor Summary
ImportEntityConfigDelegate()
          Creates an ImportEntityConfigDelegate.
 
Method Summary
 ColumnDef createColumnDef(org.w3c.dom.Node column)
          Create a ColumnDef from the given node and apply any custom attributes.
 EntityDef createEntityDef(org.w3c.dom.Node node)
          Create an EntityDef from the given node and apply any custom attributes.
protected  void initDelimiter(ImportEntityDef entityDef, org.w3c.dom.Node delimiter)
          Initialize the delimiter parser from the XML node.
protected  void initRowTranslator(ImportEntityDef entityDef, org.w3c.dom.Node rowTranslator)
          Initialize the row translator from the XML node.
protected  ColumnTranslator instantiateTranslator(java.lang.String className)
          Instantiate the ColumnTranslator.
 void setBinaryDelimiterParserFactory(CustomObjectFactory newFactory)
          Sets the BinaryDelimiterParser factory to use when creating the EntityDef.
 void setColumnTranslatorFactory(CustomObjectFactory newFactory)
          Sets the ColumnTranslator factory to use when creating the ColumnDef(s).
 void setColumnValueGeneratorFactory(CustomObjectFactory factory)
          Set the custom object factory for creating column value generators.
 void setDelimiterParserFactory(CustomObjectFactory newFactory)
          Sets the DelimiterParser factory to use when creating the EntityDef.
 void setRowTranslatorFactory(CustomObjectFactory newFactory)
          Set the custom object factory for create row translators.
 
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.


SOURCE_ATTR

public static final java.lang.String SOURCE_ATTR
The attribute name that contains the name of data file to import with this entity.

See Also:
Constant Field Values

SOURCE_ENCODING_ATTR

public static final java.lang.String SOURCE_ENCODING_ATTR
The attribute name that contains the encoding of the source file.

See Also:
Constant Field Values

IMPORT_ENGINE_ATTR

public static final java.lang.String IMPORT_ENGINE_ATTR
The attribute name that contains the class name of import engine used to import this entity.

See Also:
Constant Field Values

GENERATE_ATTR

public static final java.lang.String GENERATE_ATTR
The attribute name in the COLUMN_TAG element that defines whether the column is imported from the source file (false) or generated (true).

See Also:
Constant Field Values

DELIMITER_TAG

public static final java.lang.String DELIMITER_TAG
The element name that contains the DelimiterParser definition.

See Also:
Constant Field Values

DELIMITER_TYPE_ATTR

public static final java.lang.String DELIMITER_TYPE_ATTR
The attribute name in the DELIMITER_TAG element that contains contains the delimiter type.

See Also:
Constant Field Values

COLUMN_TRANSLATOR_ATTR

public static final java.lang.String COLUMN_TRANSLATOR_ATTR
The element name that contains the ColumnTranslator classname to use on all column values to be imported.

See Also:
Constant Field Values

COLUMN_TRANSLATOR_TAG

public static final java.lang.String COLUMN_TRANSLATOR_TAG
The element name that contains the ColumnTranslator definition to use on all column values to be imported.

See Also:
Constant Field Values

COLUMN_TRANSLATOR_TYPE_ATTR

public static final java.lang.String COLUMN_TRANSLATOR_TYPE_ATTR
The attribute name that contains the ColumnTranslator type that maps to a classname.

See Also:
Constant Field Values

ROW_TRANSLATOR_TAG

public static final java.lang.String ROW_TRANSLATOR_TAG
The element name that contains the RowTranslator definition.

Since:
0.72
See Also:
Constant Field Values

ROW_TRANSLATOR_TYPE_ATTR

public static final java.lang.String ROW_TRANSLATOR_TYPE_ATTR
The attribute name that contains the RowTranslator type that maps to a classname.

Since:
0.72
See Also:
Constant Field Values

delimiterParserFactory

protected CustomObjectFactory delimiterParserFactory
Custom object factory that creates delimiter parsers.


binaryDelimiterParserFactory

protected CustomObjectFactory binaryDelimiterParserFactory
Custom object factory that creates binary delimiter parsers.

Since:
0.74

columnTranslatorFactory

protected CustomObjectFactory columnTranslatorFactory
Custom object factory that creates column translators.


generateColumnConfigDelegate

protected GenerateEntityConfigDelegate generateColumnConfigDelegate
Delegate used to create GenerateColumnDef.


rowTranslatorFactory

protected CustomObjectFactory rowTranslatorFactory
Custom object factory that creates row translators.

Since:
0.72
Constructor Detail

ImportEntityConfigDelegate

public ImportEntityConfigDelegate()
Creates an ImportEntityConfigDelegate.

Method Detail

setDelimiterParserFactory

public void setDelimiterParserFactory(CustomObjectFactory newFactory)
Sets the DelimiterParser factory to use when creating the EntityDef.

Parameters:
newFactory - the delimiter parser factory

setBinaryDelimiterParserFactory

public void setBinaryDelimiterParserFactory(CustomObjectFactory newFactory)
Sets the BinaryDelimiterParser factory to use when creating the EntityDef.

Parameters:
newFactory - the binary delimiter parser factory
Since:
0.74

setColumnTranslatorFactory

public void setColumnTranslatorFactory(CustomObjectFactory newFactory)
Sets the ColumnTranslator factory to use when creating the ColumnDef(s).

Parameters:
newFactory - the column translator factory

setColumnValueGeneratorFactory

public void setColumnValueGeneratorFactory(CustomObjectFactory factory)
Set the custom object factory for creating column value generators.

Parameters:
factory - the column value generator factory

setRowTranslatorFactory

public void setRowTranslatorFactory(CustomObjectFactory newFactory)
Set the custom object factory for create row translators.

Parameters:
newFactory - the row translator factory

createEntityDef

public EntityDef createEntityDef(org.w3c.dom.Node node)
                          throws org.w3c.dom.DOMException,
                                 InvalidCustomObjectDefException
Description copied from interface: EntityConfigDelegate
Create an EntityDef from the given node and apply any custom attributes. The following are standard attributes that are applied by the EntityConfig: catalog, schema, table.

Specified by:
createEntityDef in interface EntityConfigDelegate
Parameters:
node - the element node with the name 'entity'
Returns:
the EntityDef
Throws:
InvalidCustomObjectDefException - if the custom EntityDef could not be created
org.w3c.dom.DOMException - if any custom attributes are missing or invalid
See Also:
EntityConfigDelegate.createEntityDef(org.w3c.dom.Node)

initDelimiter

protected void initDelimiter(ImportEntityDef entityDef,
                             org.w3c.dom.Node delimiter)
                      throws org.w3c.dom.DOMException,
                             InvalidCustomObjectDefException
Initialize the delimiter parser from the XML node.

Parameters:
entityDef - the entity definition to add the delimiter parser
delimiter - the node
Throws:
org.w3c.dom.DOMException - if the node has missing attributes/elements
InvalidCustomObjectDefException - if the delimiter parser could not be created from the delimiter parser factory

initRowTranslator

protected void initRowTranslator(ImportEntityDef entityDef,
                                 org.w3c.dom.Node rowTranslator)
                          throws org.w3c.dom.DOMException,
                                 InvalidCustomObjectDefException
Initialize the row translator from the XML node.

Parameters:
entityDef - the entity definition to add the row translator
rowTranslator - the node
Throws:
org.w3c.dom.DOMException - if the node has missing elements/attributes
InvalidCustomObjectDefException - if the row translator could not be created from the row translator factory
Since:
0.72

createColumnDef

public ColumnDef createColumnDef(org.w3c.dom.Node column)
                          throws org.w3c.dom.DOMException,
                                 InvalidCustomObjectDefException
Description copied from interface: EntityConfigDelegate
Create a ColumnDef from the given node and apply any custom attributes. The following are standard attributes that are applied by the EntityConfig: name, SQLType, format, default.

Specified by:
createColumnDef in interface EntityConfigDelegate
Parameters:
column - the element node with the name 'column'
Returns:
the ColumnDef
Throws:
org.w3c.dom.DOMException - if any custom attributes are missing or invalid
InvalidCustomObjectDefException - if the custom ColumnDef could not be created
See Also:
EntityConfigDelegate.createColumnDef(org.w3c.dom.Node)

instantiateTranslator

protected ColumnTranslator instantiateTranslator(java.lang.String className)
                                          throws org.w3c.dom.DOMException
Instantiate the ColumnTranslator.

Parameters:
className - the class name of the column translator
Returns:
column translator
Throws:
org.w3c.dom.DOMException - if the column translator could not be created