com.cysols.iodef
Class DBHandler

java.lang.Object
  extended by com.cysols.iodef.DBHandler

public class DBHandler
extends Object

This class provides some methods accessing to the xml database.

Author:
cysol

Constructor Summary
DBHandler()
           
 
Method Summary
protected  org.xmldb.api.base.Collection createCollection()
          Returns a Collection instance from DatabaseManager.
 String[] getKeyList()
          Returns the all key stored to xml database.
 void insert(String key, Document doc)
          Inserts the specified incident document to xml database.
 Node[] select()
          Selects all Document node from xml database, returns the array of Document nodes.
 Node selectByKey(String key)
          Selects Document node with specified key from xml database.
 Node[] selectByXPath(String xpath)
          Selects the Document nodes with xpath from database, and returns the array of Node instance matched xpath.
 Node[] selectByXPath(String prefix, String namespace, String xpath)
          Selects the Document nodes with xpath from database, and returns the array of Node instance matched xpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBHandler

public DBHandler()
Method Detail

createCollection

protected org.xmldb.api.base.Collection createCollection()
                                                  throws org.xmldb.api.base.XMLDBException
Returns a Collection instance from DatabaseManager.

Returns:
a Collection instance
Throws:
org.xmldb.api.base.XMLDBException - If a DB error occurs

insert

public void insert(String key,
                   Document doc)
            throws org.xmldb.api.base.XMLDBException,
                   XMLWriteException
Inserts the specified incident document to xml database.

Parameters:
doc - - incident document
Throws:
org.xmldb.api.base.XMLDBException - If a DB error occurs
XMLWriteException - If unable to create Collection instance.

selectByXPath

public Node[] selectByXPath(String xpath)
                     throws org.xmldb.api.base.XMLDBException,
                            XMLReaderException
Selects the Document nodes with xpath from database, and returns the array of Node instance matched xpath.

Parameters:
xpath - a xpth to select the document object from xml database
Returns:
array of Node instance, null if matched contents doesn't exist.
Throws:
XMLReaderException - if unalbe to create Collection instance by url.
org.xmldb.api.base.XMLDBException - If a DB error occurs.

selectByXPath

public Node[] selectByXPath(String prefix,
                            String namespace,
                            String xpath)
                     throws org.xmldb.api.base.XMLDBException,
                            XMLReaderException
Selects the Document nodes with xpath from database, and returns the array of Node instance matched xpath.

Parameters:
xpath - a xpth to select the document object from xml database.
Returns:
array of Node instance, null if matched contents doesn't exist.
Throws:
XMLReaderException - if unalbe to create Collection instance by url.
org.xmldb.api.base.XMLDBException - If a DB error occurs

selectByKey

public Node selectByKey(String key)
                 throws XMLReaderException,
                        org.xmldb.api.base.XMLDBException
Selects Document node with specified key from xml database.

Parameters:
key - document key
Returns:
Document node, null if Docuemnt node had specified key doesn't exist.
Throws:
XMLReaderException - if unalbe to create Collection instance by url.
org.xmldb.api.base.XMLDBException - If a DB error occurs

select

public Node[] select()
              throws XMLReaderException,
                     org.xmldb.api.base.XMLDBException
Selects all Document node from xml database, returns the array of Document nodes.

Returns:
array of Document nodes
Throws:
XMLReaderException - if unalbe to create Collection instance by url.
org.xmldb.api.base.XMLDBException - If a DB error occurs

getKeyList

public String[] getKeyList()
                    throws XMLReaderException,
                           org.xmldb.api.base.XMLDBException
Returns the all key stored to xml database.

Returns:
the array of key name
Throws:
XMLReaderException - if unalbe to create Collection instance by url.
org.xmldb.api.base.XMLDBException - If a DB error occurs