de.fesenmeyer.dbnormalizer.core.configuration
Class ConfigurationWriter

java.lang.Object
  extended by de.fesenmeyer.dbnormalizer.core.configuration.ConfigurationWriter

public class ConfigurationWriter
extends Object

Class which writes a session configuration to a XML file.

Author:
DF
See Also:
ConfigurationReader, SessionConfig

Field Summary
private  Document doc
          The DOM-document used for creating nodes etc.
private  SessionConfig sessionConfig
          The session configuration to be written to file.
 
Constructor Summary
ConfigurationWriter(SessionConfig sessionConfig)
          Class constructor specifying the session configuration to be written.
 
Method Summary
private  Element getAttributesNode(String nodeName, Set<String> attributes)
          Creates an attributes node, which gets its name from the specified argument nodeName.
private  Node getConfigurationNode(SessionConfig sessionConfig)
          Creates a configuration node from the session configuration object.
private  Element getDBConfigNode(DBConfig dbConfig)
          Creates a dbConfig node.
private  Element getFDsNode(Collection<FDConfig> fdConfigs)
          Creates a fds node from FDConfig objects.
private  Element getTableContainerConfigNode(TableContainerConfig tableContainerConfig)
          Creates a node for a TableContainerConfig object.
private  Element getTableInfoNode(Collection<TableConfig> tableConfigs)
          Creates a tableInfo node from the TableConfig objects specified by the tableConfigs argument.
private  Element getTableNode(TableConfig tableConfig)
          Creates a table node from the TableConfig object specified by argument tableConfig.
 void write()
          Writes the session configuration to a XML-file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionConfig

private SessionConfig sessionConfig
The session configuration to be written to file.


doc

private Document doc
The DOM-document used for creating nodes etc.

Constructor Detail

ConfigurationWriter

public ConfigurationWriter(SessionConfig sessionConfig)
Class constructor specifying the session configuration to be written.

Parameters:
sessionConfig - the session configuration object
Method Detail

write

public void write()
           throws ConfigurationException
Writes the session configuration to a XML-file.

Throws:
ConfigurationException - if an exception occurs, such that the file can not be successfully written (e.g. an IOException)

getConfigurationNode

private Node getConfigurationNode(SessionConfig sessionConfig)
Creates a configuration node from the session configuration object.

Parameters:
sessionConfig - the session configuration object
Returns:
the configuration node

getDBConfigNode

private Element getDBConfigNode(DBConfig dbConfig)
Creates a dbConfig node.

Parameters:
dbConfig - the DB-Config object from which the node should be created
Returns:
the dbConfig node

getTableContainerConfigNode

private Element getTableContainerConfigNode(TableContainerConfig tableContainerConfig)
Creates a node for a TableContainerConfig object.

Parameters:
tableContainerConfig - the TableContainerConfig object
Returns:
an appropriate node for the TableContainerConfig object

getTableInfoNode

private Element getTableInfoNode(Collection<TableConfig> tableConfigs)
Creates a tableInfo node from the TableConfig objects specified by the tableConfigs argument.

Parameters:
tableConfigs - a collection of TableConfig objects
Returns:
the tableInfo node

getTableNode

private Element getTableNode(TableConfig tableConfig)
Creates a table node from the TableConfig object specified by argument tableConfig.

Parameters:
tableConfig - the tableConfig object
Returns:
the table node

getAttributesNode

private Element getAttributesNode(String nodeName,
                                  Set<String> attributes)
Creates an attributes node, which gets its name from the specified argument nodeName.

Parameters:
nodeName - the node's name to be set
attributes - a set of attribute names
Returns:
an attributes node as described above

getFDsNode

private Element getFDsNode(Collection<FDConfig> fdConfigs)
Creates a fds node from FDConfig objects.

Parameters:
fdConfigs - a collection of FDConfig objects
Returns:
the fds node