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

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

public class CSVWrapper
extends AutoMedWrapper

Author:
Andrew Charles Smith - acs203 This class provides methods to wrap an CSV file

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
CSVWrapper()
          Creates a new, empty instance of XMLSchemaWrapper
CSVWrapper(AccessMethod am, java.lang.String password)
          This constructor is used when querying the schema
 
Method Summary
protected  void connect()
          Check that the CSV file exists
 ASG executeCSVQuery(ASG ASGquery)
          Given an IQL query, this method queries the CSV file, then returns the answer in ASG format.
 ASG executeIQL(ASG q)
          Execute an IQL query on the datasource.
 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
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
 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

CSVWrapper

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


CSVWrapper

public CSVWrapper(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 CSV file exists

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

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

executeCSVQuery

public ASG executeCSVQuery(ASG ASGquery)
                    throws DataSourceException
Given an IQL query, this method queries the CSV file, then returns the answer in ASG format.

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

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