uk.ac.ic.doc.automed.wrappers
Class XMLSchemaWrapper

java.lang.Object
  extended by uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
      extended by uk.ac.ic.doc.automed.wrappers.XMLSchemaWrapper

public class XMLSchemaWrapper
extends AutoMedWrapper

Author:
Andrew Charles Smith - acs203 This class provides methods to wrap an XML file constrained by an XML Schema in Automed.

Field Summary
static java.lang.String driverString
           
 
Fields inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
am, awf, debug, driver, emptyKeyProtection, emptyKeys, optionKeyProtection, optionKeys, password, protocol, s, url, username
 
Constructor Summary
XMLSchemaWrapper()
          Creates a new, empty instance of XMLSchemaWrapper
XMLSchemaWrapper(AccessMethod am, java.lang.String password)
          This constructor is used when querying the schema
 
Method Summary
protected  void connect()
          Check that the XML file exists
 void createXSDOMRepresentation(java.lang.String uri)
          Create an internal representation of the XML Schema.
 ASG executeIQL(ASG q)
          Execute an IQL query on the datasource.
 ASG executeXMLSchemaQuery(ASG ASGquery)
          Given an IQL query, this method queries the XML file, then returns the answer in ASG format.
 AutoMedWrapperFactory getAutoMedWrapperFactory()
          Return the AutoMedWrapperFactory currently associated with this wrapper.
protected  AutoMedWrapperFactory getDefaultWrapperFactory()
          Return the default AutoMedWrapperFactory that is used to generate Schema instances from information in a data sources
 Document getDoc()
          Return the XSDOM document
static java.lang.String getDriver()
          The name of the driver string that identifies this wrapper
 java.lang.String getProtocolName()
          The name of the Protocol that this wrapper uses
 void getSODefinition(QuerySubGoal qsg)
          Implement AutoMedWrapper abstract method This method should never be executed because the calling method should already know that the transformation leading to the schema object represented by qsg variable belongs to a source schema.
 java.lang.String getUri()
          Return the url for this wrapper
 uk.ac.ic.doc.automed.wrappers.XMLInfo getXMLInfo()
          Return the xmlInfo object for this schema instance
 boolean insertIQL(ASG aSG)
          Execute an IQL insert on the datasource.
 
Methods inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
atDebugLevel, cacheWrapper, deleteIQL, executeIQL, executeLocalQuery, getAccessMethod, getAutoMedWrapper, getAutoMedWrapper, getDrivers, getOption, getOptionKeyProtection, getOptionKeys, getProtocol, getQueryCache, getQueryCache, getQueryParser, getSchema, getSchema, getSODefinition, newAutoMedSchema, newAutoMedWrapper, newAutoMedWrapper, newAutoMedWrapper, registerWrapper, selectNewAutoMedWrapper, selectNewAutoMedWrapper, setDebugLevel, setOption, updateCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driverString

public static final java.lang.String driverString
See Also:
Constant Field Values
Constructor Detail

XMLSchemaWrapper

public XMLSchemaWrapper()
Creates a new, empty instance of XMLSchemaWrapper


XMLSchemaWrapper

public XMLSchemaWrapper(AccessMethod am,
                        java.lang.String password)
                 throws DataSourceException,
                        NotFoundException
This constructor is used when querying the schema

Throws:
DataSourceException
NotFoundException
Method Detail

getUri

public java.lang.String getUri()
Return the url for this wrapper

Returns:
the url

connect

protected void connect()
                throws DataSourceException
Check that the XML file exists

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

createXSDOMRepresentation

public void createXSDOMRepresentation(java.lang.String uri)
                               throws java.lang.Exception
Create an internal representation of the XML Schema. If we've loaded an XML document the schema will come from the PSVI of the XML document.

Throws:
java.lang.Exception

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

executeXMLSchemaQuery

public ASG executeXMLSchemaQuery(ASG ASGquery)
Given an IQL query, this method queries the XML file, 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

getDoc

public Document getDoc()
Return the XSDOM document


getXMLInfo

public uk.ac.ic.doc.automed.wrappers.XMLInfo getXMLInfo()
Return the xmlInfo object for this schema instance


getDriver

public static java.lang.String getDriver()
The name of the driver string that identifies this wrapper


getAutoMedWrapperFactory

public AutoMedWrapperFactory getAutoMedWrapperFactory()
Description copied from class: AutoMedWrapper
Return the AutoMedWrapperFactory currently associated with this wrapper.

Overrides:
getAutoMedWrapperFactory in class AutoMedWrapper

getDefaultWrapperFactory

protected AutoMedWrapperFactory getDefaultWrapperFactory()
Description copied from class: AutoMedWrapper
Return the default AutoMedWrapperFactory that is used to generate Schema instances from information in a data sources

Specified by:
getDefaultWrapperFactory in class AutoMedWrapper

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

insertIQL

public boolean insertIQL(ASG aSG)
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:
aSG - 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.


getSODefinition

public void getSODefinition(QuerySubGoal qsg)
                     throws DataSourceException
Implement AutoMedWrapper abstract method This method should never be executed because the calling method should already know that the transformation leading to the schema object represented by qsg variable belongs to a source schema.

Specified by:
getSODefinition in class AutoMedWrapper
Throws:
DataSourceException