de.ispsoft.jaxme
Class XmlDbManager

java.lang.Object
  extended byde.ispsoft.jaxme.JMManagerImpl
      extended byde.ispsoft.jaxme.XmlDbManager
All Implemented Interfaces:
JMManager

public class XmlDbManager
extends JMManagerImpl

An implementation of a JMManager for a Tamino database.

Author:
Jochen Wiedmanns

Nested Class Summary
 
Nested classes inherited from class de.ispsoft.jaxme.JMManagerImpl
JMManagerImpl.MyObserver
 
Field Summary
static java.lang.String COLLECTION_NODE_NAME
          Name of the collection node.
static java.lang.String CONFIGURATION_NODE_NAME
          Name of our private configuration node (XmlDbManager in namespace JMManagerFactoryImpl.NAMESPACE_URI)
static java.lang.String DATABASE_PROPERTIES_NODE
          Name of the DatabaseProperties node.
static java.lang.String DATABASE_PROPERTY_NODE
          Name of the DatabaseProperty node.
static java.lang.String DRIVER_NODE_NAME
          Name of the driver node.
static java.lang.String ID_ATTRIBUTE_NODE
          Name of the IdAttribute node.
static java.lang.String ID_ELEMENT_NODE
          Name of the IdElement node.
static java.lang.String ID_NAMESPACE_NODE
          Name of the IdNamespace node.
static java.lang.String PASSWORD_NODE_NAME
          Name of the Password node
static java.lang.String USER_NODE_NAME
          Name of the User node
static java.lang.String XPATH_QUERY_SERVICE_NODE
          Name of the XPathQueryService node
static java.lang.String XPATH_QUERY_SERVICE_VERSION_NODE
          Name of the XPathQueryServiceVersion node
 
Fields inherited from class de.ispsoft.jaxme.JMManagerImpl
ELEMENT_CLASS_NAME, HANDLER_CLASS_NAME, jmAnyElementClass, jmContentHandlerClass
 
Fields inherited from interface de.ispsoft.jaxme.JMManager
BIGINT, BIT, BLOB, BOOLEAN, CLOB, DECIMAL, DOUBLE, FLOAT, INTEGER, SMALLINT, TIMESTAMP, TINYINT, VARBINARY, VARCHAR
 
Constructor Summary
XmlDbManager()
          Creates a new instance of InoManager
 
Method Summary
 void delete(JMAnyElement pElement)
          Deletes the given document from the database.
 java.lang.String getCollection()
           
 java.lang.String getDriver()
           
 java.lang.Class getDriverClass()
           
protected  java.lang.String getId(JMAnyElement pElement)
          Returns the elements ID.
 java.lang.String getIdAttribute()
           
 java.lang.String getIdElement()
           
 java.lang.String getIdNamespace()
           
 java.lang.String getPassword()
           
 java.lang.String getUser()
           
protected  org.xmldb.api.base.Collection getXmlDbCollection()
           
 java.lang.String getXPathQueryService()
           
 java.lang.String getXPathQueryServiceVersion()
           
 void insert(JMAnyElement pElement)
          Inserts the given document into the database.
 void parseConfiguration(org.w3c.dom.Element pElement)
          Parses a configuration element.
 void select(Observer pObserver, java.lang.String pQuery, java.lang.Object[] pPlaceHolderArgs, int pStart, int pMax)
          Reads documents matching the given XPath query.
 void setCollection(java.lang.String pCollection)
           
 void setDriver(java.lang.String pDriver)
           
 void setDriverClass(java.lang.Class pClass)
           
 void setIdAttribute(java.lang.String pIdAttribute)
           
 void setIdElement(java.lang.String pIdElement)
           
 void setIdNamespace(java.lang.String pIdNamespace)
           
 void setPassword(java.lang.String pPassword)
           
 void setUser(java.lang.String pUser)
           
 void setXPathQueryService(java.lang.String pService)
           
 void setXPathQueryServiceVersion(java.lang.String pVersion)
           
 void update(JMAnyElement pElement)
          Updates the given document in the database.
 
Methods inherited from class de.ispsoft.jaxme.JMManagerImpl
create, getJMAnyElementClass, getJMContentHandler, getLocalName, getNamespaceSupport, getNamespaceURI, init, select, select, select, select, select, select, select, toSAX, toWriter, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_NODE_NAME

public static final java.lang.String CONFIGURATION_NODE_NAME

Name of our private configuration node (XmlDbManager in namespace JMManagerFactoryImpl.NAMESPACE_URI)

See Also:
Constant Field Values

DRIVER_NODE_NAME

public static final java.lang.String DRIVER_NODE_NAME

Name of the driver node.

See Also:
Constant Field Values

COLLECTION_NODE_NAME

public static final java.lang.String COLLECTION_NODE_NAME

Name of the collection node.

See Also:
Constant Field Values

USER_NODE_NAME

public static final java.lang.String USER_NODE_NAME

Name of the User node

See Also:
Constant Field Values

PASSWORD_NODE_NAME

public static final java.lang.String PASSWORD_NODE_NAME

Name of the Password node

See Also:
Constant Field Values

XPATH_QUERY_SERVICE_NODE

public static final java.lang.String XPATH_QUERY_SERVICE_NODE

Name of the XPathQueryService node

See Also:
Constant Field Values

XPATH_QUERY_SERVICE_VERSION_NODE

public static final java.lang.String XPATH_QUERY_SERVICE_VERSION_NODE

Name of the XPathQueryServiceVersion node

See Also:
Constant Field Values

ID_ATTRIBUTE_NODE

public static final java.lang.String ID_ATTRIBUTE_NODE

Name of the IdAttribute node.

See Also:
Constant Field Values

ID_ELEMENT_NODE

public static final java.lang.String ID_ELEMENT_NODE

Name of the IdElement node.

See Also:
Constant Field Values

ID_NAMESPACE_NODE

public static final java.lang.String ID_NAMESPACE_NODE

Name of the IdNamespace node.

See Also:
Constant Field Values

DATABASE_PROPERTIES_NODE

public static final java.lang.String DATABASE_PROPERTIES_NODE

Name of the DatabaseProperties node.

See Also:
Constant Field Values

DATABASE_PROPERTY_NODE

public static final java.lang.String DATABASE_PROPERTY_NODE

Name of the DatabaseProperty node.

See Also:
Constant Field Values
Constructor Detail

XmlDbManager

public XmlDbManager()
Creates a new instance of InoManager

Method Detail

getDriver

public java.lang.String getDriver()

setDriver

public void setDriver(java.lang.String pDriver)

setDriverClass

public void setDriverClass(java.lang.Class pClass)

getDriverClass

public java.lang.Class getDriverClass()

setCollection

public void setCollection(java.lang.String pCollection)

getCollection

public java.lang.String getCollection()

setUser

public void setUser(java.lang.String pUser)

getUser

public java.lang.String getUser()

setPassword

public void setPassword(java.lang.String pPassword)

getPassword

public java.lang.String getPassword()

setXPathQueryService

public void setXPathQueryService(java.lang.String pService)

getXPathQueryService

public java.lang.String getXPathQueryService()

setXPathQueryServiceVersion

public void setXPathQueryServiceVersion(java.lang.String pVersion)

getXPathQueryServiceVersion

public java.lang.String getXPathQueryServiceVersion()

setIdAttribute

public void setIdAttribute(java.lang.String pIdAttribute)

getIdAttribute

public java.lang.String getIdAttribute()

setIdElement

public void setIdElement(java.lang.String pIdElement)

getIdElement

public java.lang.String getIdElement()

setIdNamespace

public void setIdNamespace(java.lang.String pIdNamespace)

getIdNamespace

public java.lang.String getIdNamespace()

getId

protected java.lang.String getId(JMAnyElement pElement)

Returns the elements ID. The default implementation uses the attribute 'id' as an element ID. Another attribute can be used by setting the child element IdAttribute of the XmlDbManager configuration.

If using an attribute as the ID is not appropriate for your purposes, you need to create a subclass of XmlDbManager, which overwrites the getId() method.


parseConfiguration

public void parseConfiguration(org.w3c.dom.Element pElement)

Parses a configuration element. This method is called twice: Once for the default configuration and once for the specific configuration.

Overrides:
parseConfiguration in class JMManagerImpl

getXmlDbCollection

protected org.xmldb.api.base.Collection getXmlDbCollection()
                                                    throws org.xmldb.api.base.XMLDBException,
                                                           java.lang.IllegalAccessException,
                                                           java.lang.InstantiationException
Throws:
org.xmldb.api.base.XMLDBException
java.lang.IllegalAccessException
java.lang.InstantiationException

delete

public void delete(JMAnyElement pElement)
            throws org.xml.sax.SAXException

Deletes the given document from the database.

Specified by:
delete in interface JMManager
Overrides:
delete in class JMManagerImpl
Throws:
org.xml.sax.SAXException

insert

public void insert(JMAnyElement pElement)
            throws org.xml.sax.SAXException

Inserts the given document into the database.

Specified by:
insert in interface JMManager
Overrides:
insert in class JMManagerImpl
Throws:
org.xml.sax.SAXException

update

public void update(JMAnyElement pElement)
            throws org.xml.sax.SAXException

Updates the given document in the database.

Specified by:
update in interface JMManager
Overrides:
update in class JMManagerImpl
Throws:
org.xml.sax.SAXException

select

public void select(Observer pObserver,
                   java.lang.String pQuery,
                   java.lang.Object[] pPlaceHolderArgs,
                   int pStart,
                   int pMax)
            throws org.xml.sax.SAXException

Reads documents matching the given XPath query. For any document matching, the Observer's notify method is executed with the matching document as an argument.

The query may contain placeholders. If it does, you have to supply an object array with two elements per placeholder: An Integer with a java.sql.Types type and the actual placeholder value. Example:

   manager.select("Name = ? and Id = ?",
                  new Object[]{JMManager.VARCHAR,
                               "Someone",
                               JMManager.INTEGER,
                               4}, 0, 0);
 

Specified by:
select in interface JMManager
Overrides:
select in class JMManagerImpl
Parameters:
pObserver - This Observer is notified for any matching document. The document is added as an argument.
pQuery - The query to perform. May contain placeholders.
pPlaceHolderArgs - An array of objects or null, if the query doesn't contain any placeholders.
pStart - Ignore the given number of result documents at the beginning. A value of zero will return all documents.
pMax - Return at most the given number of documents. A value of zero will return all documents.
Throws:
org.xml.sax.SAXException