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

java.lang.Object
  extended by uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
      extended by uk.ac.bbk.dcs.automed.xml.wrappers.XMLWrapper
          extended by uk.ac.bbk.dcs.automed.xml.wrappers.DOMWrapper
All Implemented Interfaces:
CacheUser

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
(package private)  org.w3c.dom.Document inputDoc
           
 
Fields inherited from class uk.ac.bbk.dcs.automed.xml.wrappers.XMLWrapper
logger, protocol, resultList, schemaDoc, schemaUIDDoc, sid, sName
 
Fields inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
am, awf, debug, driver, emptyKeyProtection, emptyKeys, optionKeyProtection, optionKeys, password, s, url, username
 
Constructor Summary
DOMWrapper()
           
DOMWrapper(AccessMethod am, java.lang.String password)
           
 
Method Summary
protected  ASG compositeQuery(ASG query)
           
(package private)  java.util.ArrayList constructElementElementQueryResult(java.lang.String elem1CID, java.lang.String elem2CID, java.util.ArrayList resultNodeList)
           
protected  ASG elementAttributeQuery(java.lang.String elementCID, java.lang.String attributeName)
           
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 element, int order)
           
protected  ASG elementQuery(java.lang.String elemCID)
           
protected  AutoMedWrapperFactory getDefaultWrapperFactory()
          Returns a new instance of the default wrapper factory for this wrapper
 org.w3c.dom.Document getInputDoc()
           
 java.lang.String getProtocolName()
          The name of the Protocol that this wrapper uses
 QueryParser getQueryParser(ASG query)
          Return a parser that will accept queries for the wrapper.
 boolean insertIQL(ASG q)
          Execute an IQL insert on the datasource.
(package private)  void setInputDoc(org.w3c.dom.Document d)
           
protected  ASG textQuery()
           
 
Methods inherited from class uk.ac.bbk.dcs.automed.xml.wrappers.XMLWrapper
connect, constructElementAttributeQueryResult, constructElementPCDataQueryResult, constructElementQueryResult, constructTextQueryResult, elementElementQuery, elementPCDataQuery, executeIQL, executeIQL, executeLocalQuery, executeXMLQuery, getSchemaDoc, getSchemaName, getSchemaUIDDoc, getURI, getXMLDSS, initialiseWrapper, newAutoMedWrapper, selectNewAutoMedWrapper, setSchemaDoc, setSchemaUIDDoc, setSID, xpathForAttributeQuery, xpathForElementQuery, xpathForElementRelQuery, xpathForTextQuery
 
Methods inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
atDebugLevel, cacheWrapper, costIQL, deleteIQL, executeIQLIncrementally, executeSourceIQL, getAccessMethod, getAutoMedPeerInstance, getAutoMedWrapper, getAutoMedWrapper, getAutoMedWrapperFactory, getDrivers, getMetadata, getOption, getOptionKeyProtection, getOptionKeys, getProtocol, getRange, getSchema, getSchema, getURL, getUserName, newAutoMedSchema, newAutoMedWrapper, newAutoMedWrapper, newAutoMedWrapperInstance, registerWrapper, selectNewAutoMedWrapper, setDebugLevel, setOption
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputDoc

org.w3c.dom.Document inputDoc
Constructor Detail

DOMWrapper

DOMWrapper()

DOMWrapper

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

getQueryParser

public QueryParser getQueryParser(ASG query)
Description copied from class: AutoMedWrapper
Return a parser that will accept queries for the wrapper. The default parser is Schemes, which accepts only single schemes, with no other IQL operators supported. The SimpleComp parser will allow simple list comprehensions to be passed to the wrapper.

Overrides:
getQueryParser in class AutoMedWrapper

textQuery

protected final ASG textQuery()
                       throws TranslationException
Specified by:
textQuery in class XMLWrapper
Returns:
all PCData and CData nodes
Throws:
TranslationException

elementQuery

protected final ASG elementQuery(java.lang.String elemCID)
                          throws TranslationException
Specified by:
elementQuery in class XMLWrapper
Parameters:
searchNode - the tag of the element (not its UID)
Returns:
ASG with the result elements
Throws:
NotFoundException
XMLException
javax.xml.transform.TransformerException
TranslationException

elementElementQuery

protected final ASG elementElementQuery(java.lang.String searchNode1,
                                        java.lang.String searchNode2,
                                        int order)
                                 throws TranslationException
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:
Throws:
TranslationException
NotFoundException
XMLException

elementPCDataQuery

protected final ASG elementPCDataQuery(java.lang.String element,
                                       int order)
                                throws TranslationException
Specified by:
elementPCDataQuery in class XMLWrapper
Throws:
TranslationException

elementAttributeQuery

protected final ASG elementAttributeQuery(java.lang.String elementCID,
                                          java.lang.String attributeName)
                                   throws TranslationException
Specified by:
elementAttributeQuery in class XMLWrapper
Throws:
TranslationException

compositeQuery

protected ASG compositeQuery(ASG query)
                      throws TranslationException
Specified by:
compositeQuery in class XMLWrapper
Throws:
TranslationException

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.


getInputDoc

public org.w3c.dom.Document getInputDoc()
                                 throws XMLNotFoundException
Returns:
the instance XML data source
Throws:
XMLNotFoundException

setInputDoc

void setInputDoc(org.w3c.dom.Document d)

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 Protocolin the repository used to represent XML DOM connections.

getDefaultWrapperFactory

protected final AutoMedWrapperFactory getDefaultWrapperFactory()
Returns a new instance of the default wrapper factory for this wrapper

Specified by:
getDefaultWrapperFactory in class AutoMedWrapper

constructElementElementQueryResult

final java.util.ArrayList constructElementElementQueryResult(java.lang.String elem1CID,
                                                             java.lang.String elem2CID,
                                                             java.util.ArrayList resultNodeList)
Parameters:
elem1CID -
elem2CID -
resultNodeList - IMPORTANT: resultNodeList contains only the instances of CID2 found in the document!
Returns: