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

java.lang.Object
  extended by uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
      extended by uk.ac.bbk.dcs.automed.xml.wrappers.XMLWrapper
Direct Known Subclasses:
DOMWrapper, SAXWrapper

public abstract class XMLWrapper
extends AutoMedWrapper

XMLWrapper class is a wrapper class for the AutoMed Repository. It acts as a mediator between IQL and XML files in the AutoMed Repository. It queries the XML files by transforming the IQL queries it is given into XPath searches, then transforms the results back into IQL. Allowed queries:

NODE QUERIES:

Elements: <<elementUID>>, returns a list of element instance UIDs that correspond to the input element schema UID.

Attributes: <<elementUID:attributeName>>, returns a list of attribute instance UIDs that correspond to the input attribute schema UID

Get all text: <<AutoMedXMLPCData>>

EDGE QUERIES:

Element-element: <<order,element1UID,element2UID>> or <<element1UID,element2UID>>, returns 2-tuples of element instance UIDs that correspond to the pair of input element schema UIDs. If order is specified, only the 2-tuples having the same order are returned.

Element-text: <<elementUID,AutoMedXMLPCData>> (not <<elementUID,PCDATAUID>>), returns 2-tuples containing the instance UID corresponding to the input element schema UID and the element's text. If order is specified, only the 2-tuples having the same order are returned.

Element-attribute: <<elementUID,attributeName>> (not <<elementUID,attributeUID>>), returns 2-tuples containing the instance UIDs corresponding to the input element and attribute schema UIDs.

Attribute-text: <<attributeUID,AutoMedXMLPCData>>, returns 2-tuples containing the instance UID corresponding to the input attribute schema UID and the atribute's text.

Author:
Lucas Zamboulis

Field Summary
protected  java.util.ArrayList queryList
           
protected static java.util.ArrayList resultList
           
protected  org.w3c.dom.Document schemaDoc
           
protected  org.w3c.dom.Document schemaUIDDoc
           
 
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
XMLWrapper()
           
 
Method Summary
protected  void connect()
          Use the connection details held with this wrapper to connect to the data source.
protected abstract  ASG elementAttributeQuery(java.lang.String searchNode1, java.lang.String searchNode2)
           
protected abstract  ASG elementElementQuery(java.lang.String searchNode1, java.lang.String searchNode2)
           
protected abstract  ASG elementElementQuery(java.lang.String searchNode1, java.lang.String searchNode2, int order)
           
protected abstract  ASG elementPCDataQuery(java.lang.String searchNode1)
           
protected abstract  ASG elementPCDataQuery(java.lang.String searchNode1, int order)
           
protected abstract  ASG elementQuery(java.lang.String searchNode)
           
 ASG executeIQL(ASG q)
          Execute an IQL query on the datasource.
 AutoMedResult executeLocalQuery(AutoMedQuery amq)
          Execute a query in the datasource's native query language, and obtain a result in an AutoMedResult class
 ASG executeXMLQuery(ASG ASGquery)
          Given an IQL query, this method queries the XML file using DOM, then returns the answer in ASG format.
 org.w3c.dom.Document getSchemaDoc()
           
 java.lang.String getSchemaName()
           
 org.w3c.dom.Document getSchemaUIDDoc()
           
 java.lang.String getURI()
           
 Schema getXMLDSS()
           
protected abstract  ASG textQuery()
           
protected  java.lang.String UIDGetAttNameFromAttUID(java.lang.String attUID)
           
protected  java.lang.String UIDGetElementName(org.w3c.dom.Node elem)
           
protected  java.lang.String UIDGetElementName(java.lang.String uid)
           
protected  java.lang.String UIDGetElementNameFromAttUID(java.lang.String attUID)
           
protected  java.lang.String UIDGetSchemaUIDFromInstanceUID(org.w3c.dom.Node elem)
           
protected  java.lang.String UIDGetSchemaUIDFromInstanceUID(java.lang.String uid)
           
 
Methods inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
atDebugLevel, cacheWrapper, deleteIQL, getAccessMethod, getAutoMedWrapper, getAutoMedWrapper, getAutoMedWrapperFactory, getDefaultWrapperFactory, getDrivers, getOption, getOptionKeyProtection, getOptionKeys, getProtocol, getProtocolName, getQueryParser, getSchema, getSchema, insertIQL, newAutoMedSchema, newAutoMedWrapper, 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
 

Field Detail

schemaDoc

protected org.w3c.dom.Document schemaDoc

schemaUIDDoc

protected org.w3c.dom.Document schemaUIDDoc

queryList

protected java.util.ArrayList queryList

resultList

protected static java.util.ArrayList resultList
Constructor Detail

XMLWrapper

public XMLWrapper()
Method Detail

connect

protected void connect()
                throws DataSourceException
Description copied from class: AutoMedWrapper
Use the connection details held with this wrapper to connect to the data source.

Specified by:
connect in class AutoMedWrapper
Throws:
DataSourceException - if unable to connect to the data source

getXMLDSS

public final Schema getXMLDSS()
Returns:
the AutoMed XML DataSource Schema

getSchemaDoc

public final org.w3c.dom.Document getSchemaDoc()
                                        throws XMLNotFoundException
Returns:
the DOM schema of the XML data source, without UIDs
Throws:
XMLNotFoundException

getSchemaUIDDoc

public final org.w3c.dom.Document getSchemaUIDDoc()
                                           throws XMLNotFoundException
Returns:
the DOM schema of the XML data source, with UIDs
Throws:
XMLNotFoundException

executeLocalQuery

public AutoMedResult executeLocalQuery(AutoMedQuery amq)
Description copied from class: AutoMedWrapper
Execute a query in the datasource's native query language, and obtain a result in an AutoMedResult class

Overrides:
executeLocalQuery in class AutoMedWrapper

getSchemaName

public final java.lang.String getSchemaName()
                                     throws XMLNotFoundException
Returns:
the AutoMed schema name of the XML data source
Throws:
XMLNotFoundException

getURI

public final java.lang.String getURI()
                              throws XMLNotFoundException
Returns:
the URI of the XML data source
Throws:
XMLNotFoundException

executeIQL

public ASG executeIQL(ASG q)
               throws DataSourceException
Description copied from class: AutoMedWrapper
Execute an IQL query on the datasource.

Specified by:
executeIQL in class AutoMedWrapper
Parameters:
q - An IQL query held in an ASG which complies with the limitations of what this wrapper is able to process
Returns:
An ASG containing the results of the query
Throws:
DataSourceException

executeXMLQuery

public ASG executeXMLQuery(ASG ASGquery)
                    throws XMLException,
                           XMLNotFoundException
Given an IQL query, this method queries the XML file using DOM, then returns the answer in ASG format. Currently supports only schemes.

Parameters:
ASGquery - the IQL query in ASG format
Returns:
the answer to the IQL query in ASG format
Throws:
XMLException
XMLNotFoundException

textQuery

protected abstract ASG textQuery()
Returns:
all PCData and CData nodes

elementQuery

protected abstract ASG elementQuery(java.lang.String searchNode)

elementPCDataQuery

protected abstract ASG elementPCDataQuery(java.lang.String searchNode1)

elementPCDataQuery

protected abstract ASG elementPCDataQuery(java.lang.String searchNode1,
                                          int order)

elementAttributeQuery

protected abstract ASG elementAttributeQuery(java.lang.String searchNode1,
                                             java.lang.String searchNode2)

elementElementQuery

protected abstract ASG elementElementQuery(java.lang.String searchNode1,
                                           java.lang.String searchNode2)

elementElementQuery

protected abstract ASG elementElementQuery(java.lang.String searchNode1,
                                           java.lang.String searchNode2,
                                           int order)

UIDGetElementName

protected java.lang.String UIDGetElementName(java.lang.String uid)

UIDGetElementName

protected java.lang.String UIDGetElementName(org.w3c.dom.Node elem)

UIDGetElementNameFromAttUID

protected java.lang.String UIDGetElementNameFromAttUID(java.lang.String attUID)

UIDGetAttNameFromAttUID

protected java.lang.String UIDGetAttNameFromAttUID(java.lang.String attUID)

UIDGetSchemaUIDFromInstanceUID

protected java.lang.String UIDGetSchemaUIDFromInstanceUID(java.lang.String uid)

UIDGetSchemaUIDFromInstanceUID

protected java.lang.String UIDGetSchemaUIDFromInstanceUID(org.w3c.dom.Node elem)