de.ispsoft.jaxme
Class JMManagerImpl

java.lang.Object
  extended byde.ispsoft.jaxme.JMManagerImpl
All Implemented Interfaces:
JMManager
Direct Known Subclasses:
InoManager, JMFileManager, JMJdbcManager, XmlDbManager

public class JMManagerImpl
extends java.lang.Object
implements JMManager

A default implementation for managers.

Author:
Jochen Wiedmann

Nested Class Summary
protected  class JMManagerImpl.MyObserver
           
 
Field Summary
static java.lang.String ELEMENT_CLASS_NAME
          The local name of the ElementClass element.
static java.lang.String HANDLER_CLASS_NAME
          The local name of the HandlerClass element.
protected  java.lang.Class jmAnyElementClass
           
protected  java.lang.Class 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
JMManagerImpl()
          Creates a new instance of JMManagerImpl.
 
Method Summary
 JMAnyElement create()
          Creates a new, empty element.
 void delete(JMAnyElement pElement)
          Deletes the given document from the database.
 java.lang.Class getJMAnyElementClass()
          Returns the JMAnyElement class handled by this Manager.
 JMContentHandler getJMContentHandler()
          Returns a JMContentHandler that can be used for parsing documents.
 java.lang.String getLocalName()
          Returns the managers local name.
 NamespaceSupport getNamespaceSupport()
          Returns a NamespaceSupport object initialized with the URI's and prefixes from the "Namespaces" configuration.
 java.lang.String getNamespaceURI()
          Returns the managers namespace URI.
 void init(JMManagerFactory pFactory, java.lang.String pNamespaceURI, java.lang.String pLocalName)
          Initializes the manager.
 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)
          Reads documents matching the given query.
 void select(Observer pObserver, java.lang.String pQuery, int pStart, int pMax)
          Reads documents matching the given query.
 void select(Observer pObserver, java.lang.String pQuery, java.lang.Object[] pPlaceHolderArgs)
          Reads documents matching the given query.
 void select(Observer pObserver, java.lang.String pQuery, java.lang.Object[] pPlaceHolders, int pStart, int pMax)
          Reads documents matching the given query.
 java.util.Iterator select(java.lang.String pQuery)
          Returns an iterator to all documents matching the given query.
 java.util.Iterator select(java.lang.String pQuery, int pStart, int pMax)
          Returns an iterator to all documents matching the given query.
 java.util.Iterator select(java.lang.String pQuery, java.lang.Object[] pPlaceHolderArgs)
          Returns an iterator to all documents matching the given query.
 java.util.Iterator select(java.lang.String pQuery, java.lang.Object[] pPlaceHolderArgs, int pStart, int pMax)
          Returns an iterator to all documents matching the given query.
 void toSAX(JMAnyElement pElement, org.xml.sax.ContentHandler pContentHandler)
          Serializes an element to a SAX ContentHandler using the configured prefix settings.
 void toWriter(JMAnyElement pElement, java.io.Writer pWriter)
          Serializes an element to a SAX ContentHandler using the configured prefix settings.
 java.lang.String toXML(JMAnyElement pElement)
          Serializes an element to a String using the configured prefix settings.
 void update(JMAnyElement pElement)
          Updates the given document in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT_CLASS_NAME

public static final java.lang.String ELEMENT_CLASS_NAME

The local name of the ElementClass element.

See Also:
Constant Field Values

HANDLER_CLASS_NAME

public static final java.lang.String HANDLER_CLASS_NAME

The local name of the HandlerClass element.

See Also:
Constant Field Values

jmAnyElementClass

protected java.lang.Class jmAnyElementClass

jmContentHandlerClass

protected java.lang.Class jmContentHandlerClass
Constructor Detail

JMManagerImpl

public JMManagerImpl()
Creates a new instance of JMManagerImpl.

Method Detail

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.


init

public void init(JMManagerFactory pFactory,
                 java.lang.String pNamespaceURI,
                 java.lang.String pLocalName)
          throws org.xml.sax.SAXException
Initializes the manager.

Specified by:
init in interface JMManager
Throws:
org.xml.sax.SAXException

getNamespaceURI

public java.lang.String getNamespaceURI()

Returns the managers namespace URI.

Specified by:
getNamespaceURI in interface JMManager

getLocalName

public java.lang.String getLocalName()

Returns the managers local name.

Specified by:
getLocalName in interface JMManager

getJMAnyElementClass

public java.lang.Class getJMAnyElementClass()

Returns the JMAnyElement class handled by this Manager.


create

public JMAnyElement create()
                    throws org.xml.sax.SAXException

Creates a new, empty element.

Specified by:
create in interface JMManager
Throws:
org.xml.sax.SAXException

getJMContentHandler

public JMContentHandler getJMContentHandler()
                                     throws org.xml.sax.SAXException

Returns a JMContentHandler that can be used for parsing documents.

Specified by:
getJMContentHandler in interface JMManager
Throws:
org.xml.sax.SAXException

select

public void select(Observer pObserver,
                   java.lang.String pQuery)
            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.

Specified by:
select in interface JMManager
Parameters:
pObserver - This Observer is notified for any matching document. The document is added as an argument.
pQuery - The query to perform.
Throws:
org.xml.sax.SAXException

select

public void select(Observer pObserver,
                   java.lang.String pQuery,
                   java.lang.Object[] pPlaceHolderArgs)
            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});
 

Specified by:
select in interface JMManager
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.
Throws:
org.xml.sax.SAXException

select

public void select(Observer pObserver,
                   java.lang.String pQuery,
                   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.

Specified by:
select in interface JMManager
Parameters:
pObserver - This Observer is notified for any matching document. The document is added as an argument.
pQuery - The query to perform.
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

select

public java.util.Iterator select(java.lang.String pQuery,
                                 int pStart,
                                 int pMax)
                          throws org.xml.sax.SAXException

Returns an iterator to all documents matching the given query.

Specified by:
select in interface JMManager
Parameters:
pQuery - The query to perform.
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

select

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

Returns an iterator to all documents matching the given query. 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
Parameters:
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

select

public java.util.Iterator select(java.lang.String pQuery)
                          throws org.xml.sax.SAXException

Returns an iterator to all documents matching the given query.

Specified by:
select in interface JMManager
Parameters:
pQuery - The query to perform.
Throws:
org.xml.sax.SAXException

select

public java.util.Iterator select(java.lang.String pQuery,
                                 java.lang.Object[] pPlaceHolderArgs)
                          throws org.xml.sax.SAXException

Returns an iterator to all documents matching the given query. 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
Parameters:
pQuery - The query to perform. May contain placeholders.
pPlaceHolderArgs - An array of objects or null, if the query doesn't contain any placeholders.
Throws:
org.xml.sax.SAXException

getNamespaceSupport

public NamespaceSupport getNamespaceSupport()
                                     throws org.xml.sax.SAXException

Returns a NamespaceSupport object initialized with the URI's and prefixes from the "Namespaces" configuration.

Throws:
org.xml.sax.SAXException

toSAX

public void toSAX(JMAnyElement pElement,
                  org.xml.sax.ContentHandler pContentHandler)
           throws org.xml.sax.SAXException

Serializes an element to a SAX ContentHandler using the configured prefix settings.

Throws:
org.xml.sax.SAXException

toWriter

public void toWriter(JMAnyElement pElement,
                     java.io.Writer pWriter)
              throws org.xml.sax.SAXException,
                     java.io.IOException

Serializes an element to a SAX ContentHandler using the configured prefix settings.

Throws:
org.xml.sax.SAXException
java.io.IOException

toXML

public java.lang.String toXML(JMAnyElement pElement)
                       throws org.xml.sax.SAXException

Serializes an element to a String using the configured prefix settings.

Throws:
org.xml.sax.SAXException

select

public void select(Observer pObserver,
                   java.lang.String pQuery,
                   java.lang.Object[] pPlaceHolders,
                   int pStart,
                   int pMax)
            throws org.xml.sax.SAXException
Description copied from interface: JMManager

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

delete

public void delete(JMAnyElement pElement)
            throws org.xml.sax.SAXException
Description copied from interface: JMManager

Deletes the given document from the database.

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

update

public void update(JMAnyElement pElement)
            throws org.xml.sax.SAXException
Description copied from interface: JMManager

Updates the given document in the database.

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

insert

public void insert(JMAnyElement pElement)
            throws org.xml.sax.SAXException
Description copied from interface: JMManager

Inserts the given document into the database.

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