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.
-
COMMIT_AFTERDOCUMENT
- Call commit after the entire document has been stored.
-
COMMIT_AFTERINSERT
- Call commit after each INSERT statement is executed (default).
-
COMMIT_NONE
- Don't call commit.
-
DOMToDBMS()
- Construct a DOMToDBMS object.
-
DOMToDBMS(Map)
- Construct a DOMToDBMS object and set the Map object and commit mode.
-
DOMToDBMS(Map, KeyGenerator, NameQualifier)
- Construct a DOMToDBMS object and set the Map, KeyGenerator, and
NameQualifier objects.
-
getCommitMode()
- Get the current commit mode.
-
getKeyGenerator()
- Get the current KeyGenerator.
-
getMap()
- Get the current Map.
-
getNameQualifier()
- Get the current NameQualifier.
-
setCommitMode(int)
- Set the current commit mode.
-
setKeyGenerator(KeyGenerator)
- Set the current KeyGenerator.
-
setMap(Map)
- Set the current Map.
-
setNameQualifier(NameQualifier)
- Set the current NameQualifier.
-
storeDocument(Document)
- Store the data from a DOM tree in the database.
COMMIT_AFTERINSERT
public static final int COMMIT_AFTERINSERT
- Call commit after each INSERT statement is executed (default).
COMMIT_AFTERDOCUMENT
public static final int COMMIT_AFTERDOCUMENT
- Call commit after the entire document has been stored.
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.
DOMToDBMS
public DOMToDBMS()
- Construct a DOMToDBMS object.
DOMToDBMS
public DOMToDBMS(Map map)
- Construct a DOMToDBMS object and set the Map object and commit mode.
DOMToDBMS
public DOMToDBMS(Map map,
KeyGenerator keyGenerator,
NameQualifier qualifier)
- Construct a DOMToDBMS object and set the Map, KeyGenerator, and
NameQualifier objects.
getCommitMode
public int getCommitMode()
- Get the current commit mode.
- Returns:
- The current commit mode.
setCommitMode
public void setCommitMode(int commitMode)
- Set the current commit mode.
- Parameters:
- commitMode - COMMIT_AFTERINSERT, COMMIT_AFTERDOCUMENT, or COMMIT_NONE.
getMap
public Map getMap()
- Get the current Map.
- Returns:
- The current Map.
setMap
public void setMap(Map map)
- Set the current Map.
- Parameters:
- map - The Map.
getKeyGenerator
public KeyGenerator getKeyGenerator()
- Get the current KeyGenerator.
- Returns:
- The current KeyGenerator.
setKeyGenerator
public void setKeyGenerator(KeyGenerator keyGenerator)
- Set the current KeyGenerator.
- Parameters:
- keyGenerator - The KeyGenerator.
getNameQualifier
public NameQualifier getNameQualifier()
- Get the current NameQualifier.
- Returns:
- The current NameQualifier.
setNameQualifier
public void setNameQualifier(NameQualifier qualifier)
- Set the current NameQualifier.
- Parameters:
- qualifier - The NameQualifier.
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