uk.ac.bbk.dcs.automed.xml.wrappers
Class DOMWrapper

java.lang.Object
  |
  +--uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
        |
        +--uk.ac.bbk.dcs.automed.xml.wrappers.XMLWrapper
              |
              +--uk.ac.bbk.dcs.automed.xml.wrappers.DOMWrapper

public class DOMWrapper
extends XMLWrapper

A lower level wrapper that conforms to the XMLWrapper class. The DOMWrapper class uses XPath and DOM. The DOMWrapper holds both the schema and the instance documents in memory.

Author:
Lucas Zamboulis

Field Summary
 
Fields inherited from class uk.ac.bbk.dcs.automed.xml.wrappers.XMLWrapper
queryList, resultList, schemaDoc, schemaUIDDoc
 
Fields inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
am, awf, debug, driver, password, protocol, s, url, username
 
Constructor Summary
DOMWrapper(AccessMethod am, java.lang.String password)
           
 
Method Summary
protected  ASG elementAttributeQuery(java.lang.String searchNode1, java.lang.String searchNode2)
           
protected  ASG elementElementQuery(java.lang.String searchNode1, java.lang.String searchNode2)
           
protected  ASG elementElementQuery(java.lang.String searchNode1, java.lang.String searchNode2, int order)
          Nodes are compared based on elementName:count, not their whole UID
protected  ASG elementPCDataQuery(java.lang.String searchNode)
           
protected  ASG elementPCDataQuery(java.lang.String searchNode, int order)
           
protected  ASG elementQuery(java.lang.String searchNode)
           
 org.w3c.dom.Document getDoc()
           
 java.lang.String getProtocolName()
          The name of the Protocol that this wrapper uses
 org.w3c.dom.Document getUIDDoc()
           
 boolean insertIQL(ASG q)
          Execute an IQL insert on the datasource.
static AutoMedWrapper newAutoMedWrapper(java.lang.String username, java.lang.String password, java.lang.String driver, java.lang.String url, java.lang.String schemaName, AutoMedWrapperFactory awf)
           
 
Methods inherited from class uk.ac.bbk.dcs.automed.xml.wrappers.XMLWrapper
connect, executeIQL, executeLocalQuery, executeXMLQuery, getDefaultWrapperFactory, getSchemaDoc, getSchemaName, getSchemaUIDDoc, getURI, getXMLDSS, UIDGetAttNameFromAttUID, UIDGetElementName, UIDGetElementName, UIDGetElementNameFromAttUID, UIDGetSchemaUIDFromInstanceUID, UIDGetSchemaUIDFromInstanceUID, UIDRemoveSchemaName, UIDRemoveSchemaName
 
Methods inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
atDebugLevel, cacheWrapper, deleteIQL, getAccessMethod, getAutoMedWrapper, getAutoMedWrapper, getAutoMedWrapperFactory, getOption, getOptionKeys, getProtocol, getSchema, getSchema, newAutoMedSchema, newAutoMedWrapper, newAutoMedWrapper, registerWrapper, selectNewAutoMedWrapper, selectNewAutoMedWrapper, setDebugLevel, setOption
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMWrapper

public DOMWrapper(AccessMethod am,
                  java.lang.String password)
           throws DataSourceException
Method Detail

newAutoMedWrapper

public static AutoMedWrapper newAutoMedWrapper(java.lang.String username,
                                               java.lang.String password,
                                               java.lang.String driver,
                                               java.lang.String url,
                                               java.lang.String schemaName,
                                               AutoMedWrapperFactory awf)
                                        throws IntegrityException,
                                               DataSourceException
IntegrityException
DataSourceException

elementQuery

protected final ASG elementQuery(java.lang.String searchNode)
Specified by:
elementQuery in class XMLWrapper
Parameters:
searchNode - the tag of the element (not its UID)
Returns:
ASG with the result elements

elementElementQuery

protected final ASG elementElementQuery(java.lang.String searchNode1,
                                        java.lang.String searchNode2)
Specified by:
elementElementQuery in class XMLWrapper

elementPCDataQuery

protected final ASG elementPCDataQuery(java.lang.String searchNode)
Specified by:
elementPCDataQuery in class XMLWrapper

elementElementQuery

protected final ASG elementElementQuery(java.lang.String searchNode1,
                                        java.lang.String searchNode2,
                                        int order)
Nodes are compared based on elementName:count, not their whole UID

Specified by:
elementElementQuery in class XMLWrapper
Parameters:
searchNode1 - parent element
searchNode2 - child element
order - the order of the child element in its parent's nodelist, including PCData nodes. If -1 then order is unimportant
Returns:

elementPCDataQuery

protected final ASG elementPCDataQuery(java.lang.String searchNode,
                                       int order)
Specified by:
elementPCDataQuery in class XMLWrapper

elementAttributeQuery

protected final ASG elementAttributeQuery(java.lang.String searchNode1,
                                          java.lang.String searchNode2)
Specified by:
elementAttributeQuery in class XMLWrapper

insertIQL

public boolean insertIQL(ASG q)
Description copied from class: AutoMedWrapper
Execute an IQL insert on the datasource. Note that in later releases this method will become abstract, but at present no Wrapper implements this method.

Overrides:
insertIQL in class AutoMedWrapper
Parameters:
q - is the ASG representation of an IQL query of the form

sub [t1, ..., tn] s

where:
  • 'sub' is the sub-bag builtin function (this has the same semantics as sub-set if operating on sets, which is what the extents of schemes are)
  • [t1, ..., tn] are the tuples to be inserted/deleted
  • s is the scheme that they will be inserted into/deleted from

The semantics and execution of the insert request will depend on the data source e.g. for a relational database it could be translated into a series of INSERT requests within a single transaction, which may fail or succeeed as a whole (and thus return False or True respectively from the insertIQL method). For a non-transactional repository like the HDM or XML flat files, we may choose to allow partial updates e.g. some of a set of tuples are inserted, while some already exist or violate some constraint or another.


getDoc

public org.w3c.dom.Document getDoc()
Returns:
the instance XML data source, without UIDs

getUIDDoc

public org.w3c.dom.Document getUIDDoc()
Returns:
the instance XML data source, with UIDs

getProtocolName

public java.lang.String getProtocolName()
Description copied from class: AutoMedWrapper
The name of the Protocol that this wrapper uses

Specified by:
getProtocolName in class AutoMedWrapper
Returns:
the name of the Protocol in the repository used to represent XML DOM connections.