|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objects implementing this class are used to store XML data
into a database according to the parent mapping.
An object of this class cannot be used in multiple threads concurrently.
Different Mappers can be used concurrently by different threads.
A Mapper may be used multiple times, to store several documents based
on the same mapping.
A Mapper provides three different interfaces to store XML data: the most
efficient is based on SAX2, as the Mapper can be plugged directly as a
org.xml.sax.ContentHandler into any XML parser implementing the org.xml.sax.XMLReader
interface. Note that with this method the error handler must also be
plugged so that the mapper can have a consistent behavior in case of parsing
error due to a malformed XML document (perform a rollback).
For convenience, a DOM2-based and a string-based interfaces are also
provided.
A Mapper object must be explicitly closed after use, in order to free its associated database
resources.
XMLReader
Field Summary | |
static java.lang.String |
RCSName
|
static java.lang.String |
RCSRevision
|
Method Summary | |
void |
clearBuffer()
Discards the XML data buffered by the filer since the last call to flushBuffer() method. |
void |
close()
Closes the object and frees its associated resources. |
void |
flushBuffer()
Sends buffered XML data to the data source. |
boolean |
getAutoFlush()
Retrieves the current buffering mode. |
java.sql.Connection |
getConnection()
Return the JDBC connection used by this object. |
java.lang.String |
getDocumentBase()
Retrieves the current document base used by this object. |
XMLErrorHandler |
getErrorHandler()
Return the current error handler. |
Mapping |
getMapping()
Returns the mapping used by this object |
void |
insertDocument(org.w3c.dom.Document doc)
Inserts the XML data contained in the DOM2 document in the database. |
void |
insertDocument(org.xml.sax.InputSource input)
Inserts an XML document in the database using the SAX method. |
void |
insertDocument(java.lang.String doc)
Inserts the XML data contained in the string in the database. |
void |
insertDocument(org.xml.sax.XMLReader parser,
org.xml.sax.InputSource input)
Inserts an XML document in database using the SAX method. |
void |
setAutoFlush(boolean activated)
Turns on or off the automatic buffering mode. |
void |
setDocumentBase(java.lang.String URI)
This method is to be used when the document stored contains an 'xsi:schemaLocation' attribute (or any element or attribute with the XML Schema type 'anyURI') that uses relatives URIs and when the API used to store documents does not use an InputSource with the SystemID set (e.g. |
void |
setErrorHandler(XMLErrorHandler handler)
Allows an application to register an error event handler for non-fatal errors. |
Methods inherited from interface org.xml.sax.ContentHandler |
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping |
Methods inherited from interface org.xml.sax.ErrorHandler |
error, fatalError, warning |
Field Detail |
public static final java.lang.String RCSRevision
public static final java.lang.String RCSName
Method Detail |
public Mapping getMapping()
public void close() throws XMLDBCException
XMLDBCException
- if a data source access error occurs.public void insertDocument(org.xml.sax.InputSource input) throws XMLDBCException, org.xml.sax.SAXException
input
- the SAX InputSource.
XMLDBCException
- if a data source access error occurs.
SAXException
- if a parsing error occurs.public void insertDocument(org.xml.sax.XMLReader parser, org.xml.sax.InputSource input) throws XMLDBCException, org.xml.sax.SAXException
parser
- the SAX 2 XMLReader implementation.input
- the SAX InputSource.
XMLDBCException
- if a data source access error occurs.
SAXException
- if a parsing error occurs.public void insertDocument(org.w3c.dom.Document doc) throws XMLDBCException
doc
- the XML document as a DOM2 org.w3c.dom.Document.
XMLDBCException
- if a data source access error occurs.public void insertDocument(java.lang.String doc) throws XMLDBCException, org.xml.sax.SAXException
doc
- a string containing the XML document.
XMLDBCException
- if a data source access error occurs.
org.xml.sax.SAXException
- if a parse exception occurs.public java.sql.Connection getConnection()
public XMLErrorHandler getErrorHandler()
setErrorHandler(org.xquark.xml.xdbc.XMLErrorHandler)
public void setErrorHandler(XMLErrorHandler handler)
If the application does not register an error handler, all warning and non-fatal error events reported by the filer will be silently ignored and storage will continue.
Applications may register a new or different handler in the middle of a storage operation, and the filer must begin using the new handler immediately.
handler
- The error handler.
java.lang.NullPointerException
- If the handler
argument is null.getErrorHandler()
public void setDocumentBase(java.lang.String URI)
URI
- The URI to be used as base during document storage.getDocumentBase()
public java.lang.String getDocumentBase()
setDocumentBase(String)
public void setAutoFlush(boolean activated) throws XMLDBCException
Important note: The manual mode is only useful if the JDBC connection autoCommit mode is false (otherwise, a flushBuffer() and commit() are automatically called at the end of each document insertion, regardless of the autoFlush mode). When both autoCommit and autoFlush are turned off, the user MUST call flushBuffer() before committing the changes.
activated
- 'true' is the default and means that autoflush is on.
XMLDBCException
- if a data source access error occurs.public boolean getAutoFlush()
setAutoFlush(boolean)
public void flushBuffer() throws XMLDBCException
XMLDBCException
- if a data source access error occurs.setAutoFlush(boolean)
public void clearBuffer() throws XMLDBCException
XMLDBCException
- if a data source access error occurs.setAutoFlush(boolean)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |