net.sourceforge.jdbcimporter.config
Class ImportConfig

java.lang.Object
  extended bynet.sourceforge.jdbcimporter.config.ImportConfig

public class ImportConfig
extends java.lang.Object

The ImportConfig class parses a Node to create an ImportDef. The Node's name must be 'import'.

Version:
0.6
Author:
Chris Nagy

Field Summary
static java.lang.String BATCH_COUNT_ATTR
          The attribute name in the IMPORT_TAG element that contains the number of records to import before executing batch update.
static java.lang.String COMMIT_COUNT_ATTR
          The attribute name in the IMPORT_TAG element that contains the number of records to import before commiting.
static java.lang.String CONNECTION_TAG
          The element name that contains the ConnectionDef.
static java.lang.String CONNECTION_TYPE_ATTR
          The attribute name in the CONNECTION_TAG element that contains the connection type.
protected  CustomObjectFactory connectionDefFactory
          Custom object factory that creates connection definitions.
static java.lang.String ENTITY_TAG
          The element name that contains the EntityDef.
protected  EntityConfig entityConfig
          The entity config used to create entity definitions from XML nodes.
protected  ImportEntityConfigDelegate entityConfigDelegate
          The entity config delegate.
static java.lang.String IMPORT_TAG
          The element name that contains the ImportDef.
static java.lang.String LOG_BAD_ATTR
          The attribute name in the IMPORT_TAG element that contains the filename of the log file to write bad data.
static java.lang.String LOG_FILE_ATTR
          The attribute name in the IMPORT_TAG element that contains the filename of the log file.
static java.lang.String POST_SQL_FILE_ATTR
          The attribute name in the IMPORT_TAG element that contains the filename of the sql script file that will be executed after the import.
static java.lang.String PRE_SQL_FILE_ATTR
          The attribute name in the IMPORT_TAG element that contains the filename of the sql script file that will be executed before the import.
static java.lang.String PROPERTY_NAME_ATTR
          The attribute name in the PROPERTY_TAG element that contains the name of the custom property.
static java.lang.String PROPERTY_TAG
          The element name that contains a custom property.
static java.lang.String PROPERTY_VALUE_ATTR
          The attribute name in the PROPERTY_TAG element that contains the value of the custom property.
static java.lang.String TRIM_VALUES_ATTR
          The attribute name in the IMPORT_TAG element that contains the flag indicating that values should be trimmed after being read with the delimiter parser.
 
Constructor Summary
ImportConfig()
          Constructs an ImportConfig.
 
Method Summary
static void assertNodeName(java.lang.String nodeName, org.w3c.dom.Node node)
          Asserts that the given node has the given name.
static org.w3c.dom.Node getFirstElementChild(org.w3c.dom.Node parent)
          Returns the first element child of the given node.
static org.w3c.dom.Node getFirstElementChild(org.w3c.dom.Node parent, java.lang.String name)
          Returns the first element child of the given node with the given name.
 ImportDef getImport(org.w3c.dom.Node node)
          Returns the ImportDef defined in the given Node.
static org.w3c.dom.Node getNextElementSibling(org.w3c.dom.Node sibling)
          Returns the next element sibling of the given node.
static java.lang.String getNodeValue(org.w3c.dom.Node node)
          Returns the first child's value of the given node.
static java.util.Map getProperties(org.w3c.dom.NodeList properties)
          Returns a map of all the property elements found in the given node list.
protected  void initConnection(ImportDef importDef, org.w3c.dom.Node connection)
          Initializes the connection definition from the XML node.
 void setBinaryDelimiterParserFactory(CustomObjectFactory newFactory)
          Sets the BinaryDelimiterParser factory to use when creating EntityDef(s).
 void setColumnTranslatorFactory(CustomObjectFactory newFactory)
          Sets the ColumnTranslator factory to use when creating ColumnDef(s).
 void setColumnValueGeneratorFactory(CustomObjectFactory newFactory)
          Sets the ColumnValueGeneratorFactory to use when creating ColumnDef(s).
 void setConnectionDefFactory(CustomObjectFactory newFactory)
          Sets the ConnectionDef factory to use when creating an ImportDef.
 void setDelimiterParserFactory(CustomObjectFactory newFactory)
          Sets the DelimiterParser factory to use when creating EntityDef(s).
 void setRowTranslatorFactory(CustomObjectFactory newFactory)
          Sets the RowTranslatorFactory to use when creating EntityDef(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPORT_TAG

public static final java.lang.String IMPORT_TAG
The element name that contains the ImportDef.

See Also:
Constant Field Values

CONNECTION_TAG

public static final java.lang.String CONNECTION_TAG
The element name that contains the ConnectionDef.

See Also:
Constant Field Values

CONNECTION_TYPE_ATTR

public static final java.lang.String CONNECTION_TYPE_ATTR
The attribute name in the CONNECTION_TAG element that contains the connection type.

See Also:
Constant Field Values

PROPERTY_TAG

public static final java.lang.String PROPERTY_TAG
The element name that contains a custom property.

See Also:
Constant Field Values

PROPERTY_NAME_ATTR

public static final java.lang.String PROPERTY_NAME_ATTR
The attribute name in the PROPERTY_TAG element that contains the name of the custom property.

See Also:
Constant Field Values

PROPERTY_VALUE_ATTR

public static final java.lang.String PROPERTY_VALUE_ATTR
The attribute name in the PROPERTY_TAG element that contains the value of the custom property.

See Also:
Constant Field Values

LOG_FILE_ATTR

public static final java.lang.String LOG_FILE_ATTR
The attribute name in the IMPORT_TAG element that contains the filename of the log file.

See Also:
Constant Field Values

LOG_BAD_ATTR

public static final java.lang.String LOG_BAD_ATTR
The attribute name in the IMPORT_TAG element that contains the filename of the log file to write bad data.

See Also:
Constant Field Values

PRE_SQL_FILE_ATTR

public static final java.lang.String PRE_SQL_FILE_ATTR
The attribute name in the IMPORT_TAG element that contains the filename of the sql script file that will be executed before the import.

See Also:
Constant Field Values

POST_SQL_FILE_ATTR

public static final java.lang.String POST_SQL_FILE_ATTR
The attribute name in the IMPORT_TAG element that contains the filename of the sql script file that will be executed after the import.

See Also:
Constant Field Values

TRIM_VALUES_ATTR

public static final java.lang.String TRIM_VALUES_ATTR
The attribute name in the IMPORT_TAG element that contains the flag indicating that values should be trimmed after being read with the delimiter parser.

See Also:
Constant Field Values

ENTITY_TAG

public static final java.lang.String ENTITY_TAG
The element name that contains the EntityDef.

See Also:
Constant Field Values

BATCH_COUNT_ATTR

public static final java.lang.String BATCH_COUNT_ATTR
The attribute name in the IMPORT_TAG element that contains the number of records to import before executing batch update.

See Also:
Constant Field Values

COMMIT_COUNT_ATTR

public static final java.lang.String COMMIT_COUNT_ATTR
The attribute name in the IMPORT_TAG element that contains the number of records to import before commiting.

See Also:
Constant Field Values

connectionDefFactory

protected CustomObjectFactory connectionDefFactory
Custom object factory that creates connection definitions.


entityConfig

protected EntityConfig entityConfig
The entity config used to create entity definitions from XML nodes.


entityConfigDelegate

protected ImportEntityConfigDelegate entityConfigDelegate
The entity config delegate.

Constructor Detail

ImportConfig

public ImportConfig()
Constructs an ImportConfig.

Method Detail

setConnectionDefFactory

public void setConnectionDefFactory(CustomObjectFactory newFactory)
Sets the ConnectionDef factory to use when creating an ImportDef.

Parameters:
newFactory - the connection definition factory

setDelimiterParserFactory

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

Parameters:
newFactory - the delimiter parser factory

setBinaryDelimiterParserFactory

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

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

setColumnTranslatorFactory

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

Parameters:
newFactory - the column translator factory

setColumnValueGeneratorFactory

public void setColumnValueGeneratorFactory(CustomObjectFactory newFactory)
Sets the ColumnValueGeneratorFactory to use when creating ColumnDef(s).

Parameters:
newFactory - the column value generator factory

setRowTranslatorFactory

public void setRowTranslatorFactory(CustomObjectFactory newFactory)
Sets the RowTranslatorFactory to use when creating EntityDef(s).

Parameters:
newFactory - the row translator factory
Since:
0.72

getImport

public ImportDef getImport(org.w3c.dom.Node node)
                    throws org.w3c.dom.DOMException,
                           InvalidCustomObjectDefException
Returns the ImportDef defined in the given Node.

Parameters:
node - the Node
Returns:
the import definition
Throws:
org.w3c.dom.DOMException - if the Node has missing or invalid attributes/elements
InvalidCustomObjectDefException - if a custom object could not be created from their respective factories

assertNodeName

public static void assertNodeName(java.lang.String nodeName,
                                  org.w3c.dom.Node node)
                           throws org.w3c.dom.DOMException
Asserts that the given node has the given name. If the node is null or does not have the given name then a DOMException is thrown.

Parameters:
nodeName - the name of node expected
node - the node
Throws:
org.w3c.dom.DOMException - if the node is null or doesn't have the given name

getFirstElementChild

public static org.w3c.dom.Node getFirstElementChild(org.w3c.dom.Node parent)
Returns the first element child of the given node. If there is not element child then null is returned.

Parameters:
parent - the node
Returns:
the first element child

getNextElementSibling

public static org.w3c.dom.Node getNextElementSibling(org.w3c.dom.Node sibling)
Returns the next element sibling of the given node. If there is no element sibling then null is returned.

Parameters:
sibling - the node
Returns:
the next element sibling

getFirstElementChild

public static org.w3c.dom.Node getFirstElementChild(org.w3c.dom.Node parent,
                                                    java.lang.String name)
Returns the first element child of the given node with the given name. If there is not element child then null is returned.

Parameters:
parent - the node
name - the child node name
Returns:
the first element child

getNodeValue

public static java.lang.String getNodeValue(org.w3c.dom.Node node)
                                     throws org.w3c.dom.DOMException
Returns the first child's value of the given node. If the node does not have a child or the first child's value is "" then a DOMException is thrown.

Parameters:
node - the node
Returns:
the first child's value
Throws:
org.w3c.dom.DOMException - if the node does not have a child or the first child's value is "".

initConnection

protected void initConnection(ImportDef importDef,
                              org.w3c.dom.Node connection)
                       throws org.w3c.dom.DOMException,
                              InvalidCustomObjectDefException
Initializes the connection definition from the XML node.

Parameters:
importDef - the import definition to add the connection
connection - the node
Throws:
org.w3c.dom.DOMException - if the node has missing attributes/elements
InvalidCustomObjectDefException - if the connection definition could not be created from the connection definition factory

getProperties

public static java.util.Map getProperties(org.w3c.dom.NodeList properties)
Returns a map of all the property elements found in the given node list.

Parameters:
properties - the node list containing property elements
Returns:
the map