de.ispsoft.jaxme.tamino
Class InoManager

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

public class InoManager
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 CONFIGURATION_NODE_NAME
          Name of our private configuration node (InoManager in namespace JMManagerFactoryImpl.NAMESPACE_URI)
static java.lang.String DBURL_NODE_NAME
          Name of the database URL node, including the collection name.
static java.lang.String METHOD_NODE_NAME
          Name of the property for forcing an HTTP GET.
static java.lang.String PASSWORD_NODE_NAME
          Name of the Password node
static java.lang.String USER_NODE_NAME
          Name of the User 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
InoManager()
          Creates a new instance of InoManager
 
Method Summary
 void define(java.lang.String pSchema)
          Defines the given schema in the database.
 void delete(JMAnyElement pElement)
          Deletes the given document from the database.
protected  java.lang.String getDeleteQuery(JMAnyElement pElement)
          Returns a query suited for deleting the element.
protected  java.lang.String getElementId(JMAnyElement pElement)
          Returns the element ID.
protected  java.lang.String getInsertQuery(JMAnyElement pElement)
          Returns a query suited for inserting the element.
protected  java.net.HttpURLConnection getResponse(java.lang.String pQuery)
          Performs a single database query.
protected  java.lang.String getUpdateQuery(JMAnyElement pElement)
          Returns a query suited for updating the element.
 void insert(JMAnyElement pElement)
          Inserts the given document into the database.
 void parseConfiguration(org.w3c.dom.Element pElement)
          Parses a configuration element.
protected  void performQuery(java.lang.String pQuery, InoResponseHandler pHandler)
          Parses a single INO response document.
protected  InoResponseHandler performQuery(java.lang.String pQuery, java.util.List pList)
          Performs a single database query.
 void select(Observer pObserver, java.lang.String pQuery, java.lang.Object[] pPlaceHolderArgs, int pStart, int pMax)
          Reads documents matching the given query.
protected  void setElementId(JMAnyElement pElement, java.lang.String pId)
          After an insert, sets the elements ID.
 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 (InoManager in namespace JMManagerFactoryImpl.NAMESPACE_URI)

See Also:
Constant Field Values

DBURL_NODE_NAME

public static final java.lang.String DBURL_NODE_NAME

Name of the database URL node, including the collection name.

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

METHOD_NODE_NAME

public static final java.lang.String METHOD_NODE_NAME

Name of the property for forcing an HTTP GET. By default a HTTP POST is used.

See Also:
Constant Field Values
Constructor Detail

InoManager

public InoManager()
Creates a new instance of InoManager

Method Detail

getElementId

protected java.lang.String getElementId(JMAnyElement pElement)
                                 throws org.xml.sax.SAXException

Returns the element ID. The default implementation returns getAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id"). If you use another element as the ID, change this.

Throws:
org.xml.sax.SAXException

setElementId

protected void setElementId(JMAnyElement pElement,
                            java.lang.String pId)
                     throws org.xml.sax.SAXException

After an insert, sets the elements ID. The default implementation performs setAttribute(InoResponseHandler.INO_RESPONSE2_URI, "id", pId). If you use another element as the ID, change this. You probably need to read the inserted document by using the supplied ino:id.

Throws:
org.xml.sax.SAXException

getDeleteQuery

protected java.lang.String getDeleteQuery(JMAnyElement pElement)
                                   throws org.xml.sax.SAXException

Returns a query suited for deleting the element.

Throws:
org.xml.sax.SAXException

getUpdateQuery

protected java.lang.String getUpdateQuery(JMAnyElement pElement)
                                   throws org.xml.sax.SAXException

Returns a query suited for updating the element.

Throws:
org.xml.sax.SAXException

getInsertQuery

protected java.lang.String getInsertQuery(JMAnyElement pElement)
                                   throws org.xml.sax.SAXException

Returns a query suited for inserting the element.

Throws:
org.xml.sax.SAXException

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

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

define

public void define(java.lang.String pSchema)
            throws org.xml.sax.SAXException

Defines the given schema in the database.

Throws:
org.xml.sax.SAXException

getResponse

protected java.net.HttpURLConnection getResponse(java.lang.String pQuery)
                                          throws org.xml.sax.SAXException

Performs a single database query.

Throws:
org.xml.sax.SAXException

performQuery

protected InoResponseHandler performQuery(java.lang.String pQuery,
                                          java.util.List pList)
                                   throws org.xml.sax.SAXException

Performs a single database query.

Throws:
org.xml.sax.SAXException

performQuery

protected void performQuery(java.lang.String pQuery,
                            InoResponseHandler pHandler)
                     throws org.xml.sax.SAXException

Parses a single INO response document.

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 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