All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class de.tudarmstadt.ito.xmldbms.DOMToDBMS

java.lang.Object
   |
   +----de.tudarmstadt.ito.xmldbms.DOMToDBMS

public class DOMToDBMS
extends Object
Transfers data from a DOM tree to the database.

DOMToDBMS transfers data from a DOM tree to the database according to a particular Map. The caller must always provide a Map object, a KeyGenerator (if any keys are to be generated), and a NameQualifier (if the XML document uses namespaces). It returns a DocumentInfo with information about the tables and keys needed to retrieve the data.

For example, the following code transfers data from the "sales_in.xml" document to the database. It does not use a KeyGenerator, but uses the NameQualifier for Oracle's implementation of the DOM:

    // Use a user-defined function to create a map.
    Map map = createMap("sales.map", conn1);
// Use a user-defined function to create a DOM tree over sales_in.xml doc = openDocument("sales_in.xml");
// Create a new DOMToDBMS object and store the data. domToDBMS = new DOMToDBMS(map, null, new NQ_Oracle()); domToDBMS.storeDocument(doc);

The default KeyGenerator is (KeyGeneratorImpl) can be found in de.tudarmstadt.ito.xmldbms.helpers. Many NameQualifiers can be found in de.tudarmstadt.ito.domutils.

WARNING! DOMToDBMS modifies the DOM tree in the process of transferring data to the database.

Version:
1.01
Author:
Ronald Bourret, Technical University of Darmstadt

Variable Index

 o COMMIT_AFTERDOCUMENT
Call commit after the entire document has been stored.
 o COMMIT_AFTERINSERT
Call commit after each INSERT statement is executed (default).
 o COMMIT_NONE
Don't call commit.

Constructor Index

 o DOMToDBMS()
Construct a DOMToDBMS object.
 o DOMToDBMS(Map)
Construct a DOMToDBMS object and set the Map object and commit mode.
 o DOMToDBMS(Map, KeyGenerator, NameQualifier)
Construct a DOMToDBMS object and set the Map, KeyGenerator, and NameQualifier objects.

Method Index

 o getCommitMode()
Get the current commit mode.
 o getKeyGenerator()
Get the current KeyGenerator.
 o getMap()
Get the current Map.
 o getNameQualifier()
Get the current NameQualifier.
 o setCommitMode(int)
Set the current commit mode.
 o setKeyGenerator(KeyGenerator)
Set the current KeyGenerator.
 o setMap(Map)
Set the current Map.
 o setNameQualifier(NameQualifier)
Set the current NameQualifier.
 o storeDocument(Document)
Store the data from a DOM tree in the database.

Variables

 o COMMIT_AFTERINSERT
 public static final int COMMIT_AFTERINSERT
Call commit after each INSERT statement is executed (default).

 o COMMIT_AFTERDOCUMENT
 public static final int COMMIT_AFTERDOCUMENT
Call commit after the entire document has been stored.

 o COMMIT_NONE
 public static final int COMMIT_NONE
Don't call commit. In this case, the application must call commit, such as when the data is part of a larger transaction.

Constructors

 o DOMToDBMS
 public DOMToDBMS()
Construct a DOMToDBMS object.

 o DOMToDBMS
 public DOMToDBMS(Map map)
Construct a DOMToDBMS object and set the Map object and commit mode.

 o DOMToDBMS
 public DOMToDBMS(Map map,
                  KeyGenerator keyGenerator,
                  NameQualifier qualifier)
Construct a DOMToDBMS object and set the Map, KeyGenerator, and NameQualifier objects.

Methods

 o getCommitMode
 public int getCommitMode()
Get the current commit mode.

Returns:
The current commit mode.
 o setCommitMode
 public void setCommitMode(int commitMode)
Set the current commit mode.

Parameters:
commitMode - COMMIT_AFTERINSERT, COMMIT_AFTERDOCUMENT, or COMMIT_NONE.
 o getMap
 public Map getMap()
Get the current Map.

Returns:
The current Map.
 o setMap
 public void setMap(Map map)
Set the current Map.

Parameters:
map - The Map.
 o getKeyGenerator
 public KeyGenerator getKeyGenerator()
Get the current KeyGenerator.

Returns:
The current KeyGenerator.
 o setKeyGenerator
 public void setKeyGenerator(KeyGenerator keyGenerator)
Set the current KeyGenerator.

Parameters:
keyGenerator - The KeyGenerator.
 o getNameQualifier
 public NameQualifier getNameQualifier()
Get the current NameQualifier.

Returns:
The current NameQualifier.
 o setNameQualifier
 public void setNameQualifier(NameQualifier qualifier)
Set the current NameQualifier.

Parameters:
qualifier - The NameQualifier.
 o storeDocument
 public DocumentInfo storeDocument(Document doc) throws SQLException, InvalidMapException, KeyException
Store the data from a DOM tree in the database.

Parameters:
doc - The DOM tree.
Returns:
A DocumentInfo object containing information that can be used to retrieve the data at a later time.
Throws: SQLException
Thrown if an error occurs storing data in the database.
Throws: InvalidMapException
Thrown if the Map contains invalid or incomplete information.
Throws: KeyException
Thrown if an error occurs generating a key or if keys are to be generated and no KeyGenerator has been specified.

All Packages  Class Hierarchy  This Package  Previous  Next  Index