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

java.lang.Object
  extended by uk.ac.ic.doc.automed.wrappers.AutoMedWrapperFactory
Direct Known Subclasses:
CSVWrapperFactory, HdmWrapperFactory, HDMWrapperFactory, P2PWrapperFactory, SQLWrapperFactory, XMLSchemaWrapperFactory, XMLWrapperFactory, YattaWrapperFactory

public abstract class AutoMedWrapperFactory
extends java.lang.Object

An AutoMedWrapperFactory class able to produce AutoMedWrapper instances, together with any data that the wrapper requires to be present in the repository. Once created in this manner, new instances of the datasource wrapper may be created using the AccessMethod recorded in the repository.

Author:
Peter McBrien (pjm@doc.ic.ac.uk)

Field Summary
protected  java.lang.String automedModelName
           
protected  java.lang.String baseName
           
protected static java.lang.String[] empty
           
protected  boolean factoryInUse
           
protected  java.lang.String modelName
           
static java.lang.String SOURCE_PREFIX
          String prefixed to AutoMed oriented Model names in order to obtain source oriented Model names.
 
Constructor Summary
AutoMedWrapperFactory()
           
 
Method Summary
 void clearFeatures()
          Clear all the features for this factory.
abstract  Schema createAutoMedSchema(AutoMedWrapper wrapper, java.lang.String schemaName)
          Create an AutoMed oriented schema from the source oriented schema.
 java.util.List getAttributeDomains()
          Return the attribute domain specifications
abstract  Model getAutoMedModel()
          Return the AutoMed oriented Model used to represent the Schema of the datasource.
 java.lang.String getAutoMedModelName()
          Find the name of the Model that will be used to represent an AutoMed oriented view of the data source.
abstract  java.lang.String[] getFeatureNames()
          Return the list of feature names provided by the wrapper factory.
 int getFeatures()
          Return the bitwise or of all the features in use for a wrapper.
abstract  Model getModel()
          Return the source oriented Model used to represent the Schema of the datasource.
 java.lang.String getModelBaseName()
          Return text used as basis for generating Model names
 java.lang.String getModelName()
          Find the name of the Model that will be used when a new wrapper is generated
 boolean isFeatureInUse(int features)
          Test if a certain group of features is being implemented in the representation of the datasource model in the AutoMed repository
protected abstract  AutoMedWrapper newAutoMedWrapper()
          Create a new empty wrapper instance that this wrapper factory is then able to populate.
protected abstract  void populateSchema(AutoMedWrapper wrapper)
          Read the metadata from the wrapper connection, and store in existing Schema within the wrapper.
static java.lang.String safeIQL(java.lang.String unsafeIQL)
          Process an indentifier to make it safe to use in the IQL language.
 void setAttributeDomains(java.util.List domainSpec)
          Manually set the domain information for some attributes.
 void setFeatures(int features)
          Allows certain features of the Model used for Schemas generated by this wrapper factory.
 void setFeatures(int[] features)
          Allows certain features of the Model used for Schemas generated by this wrapper factory.
 void setModelBaseName(java.lang.String baseName)
          Each implementing class gives a name for the Models that will be generated for Schemas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factoryInUse

protected boolean factoryInUse

baseName

protected java.lang.String baseName

modelName

protected java.lang.String modelName

automedModelName

protected java.lang.String automedModelName

empty

protected static final java.lang.String[] empty

SOURCE_PREFIX

public static final java.lang.String SOURCE_PREFIX
String prefixed to AutoMed oriented Model names in order to obtain source oriented Model names. Note that some wrappers do not need cd * the source/AutoMed oriented distinction, and therefore do not use this prefix.

See Also:
Constant Field Values
Constructor Detail

AutoMedWrapperFactory

public AutoMedWrapperFactory()
Method Detail

setModelBaseName

public void setModelBaseName(java.lang.String baseName)
Each implementing class gives a name for the Models that will be generated for Schemas. This same will be suffixed by the value of getFeatures() (unless that is zero). Thus one may create different wrappers with different features set, and they obtain distinct Model names. Also for source oriented Models that differ from AutoMed oriented Models, it will be prefixed by SOURCE_PREFIX.

Parameters:
baseName - text that appears in the Model name

getModelBaseName

public java.lang.String getModelBaseName()
Return text used as basis for generating Model names


isFeatureInUse

public final boolean isFeatureInUse(int features)
Test if a certain group of features is being implemented in the representation of the datasource model in the AutoMed repository

Parameters:
features - is the bitwise `or' of feature flags to be tested
Returns:
true if all those features are being ignored

getAutoMedModelName

public final java.lang.String getAutoMedModelName()
Find the name of the Model that will be used to represent an AutoMed oriented view of the data source.

Returns:
name of Model used for the Schema of new wrappers.

getModelName

public final java.lang.String getModelName()
Find the name of the Model that will be used when a new wrapper is generated

Returns:
name of Model used for the Schema of new wrappers.

getFeatures

public final int getFeatures()
Return the bitwise or of all the features in use for a wrapper. Note that features are only defined in the implementing wrapper factory.


clearFeatures

public final void clearFeatures()
Clear all the features for this factory.


setFeatures

public void setFeatures(int features)
                 throws IntegrityException
Allows certain features of the Model used for Schemas generated by this wrapper factory.

Parameters:
features - a bitwise `or' of the feature flags. By default no features are used.
Throws:
IntegrityException - if the factory is already being used for producing wrappers. You should create a new wrapper factory for your settings.

getFeatureNames

public abstract java.lang.String[] getFeatureNames()
Return the list of feature names provided by the wrapper factory. The order to of feature names is the same as the bit position in the #setFeature methods. In particular you may use the list on javax.swing.JList#setListData()


setFeatures

public void setFeatures(int[] features)
                 throws IntegrityException
Allows certain features of the Model used for Schemas generated by this wrapper factory.

Parameters:
features - an array of integers containing the bit position of the feature to set. Note that is you create a JList from the featureNames of the factory, then you may called this method with the value of javax.swing.JList.getSelectedIndices()
Throws:
IntegrityException - if the factory is already being used for producing wrappers. You should create a new wrapper factory for your settings.

getModel

public abstract Model getModel()
Return the source oriented Model used to represent the Schema of the datasource. For some wrappers, this may be the same as AutoMed oriented Model returned by getAutoMedModel()


getAutoMedModel

public abstract Model getAutoMedModel()
Return the AutoMed oriented Model used to represent the Schema of the datasource.


populateSchema

protected abstract void populateSchema(AutoMedWrapper wrapper)
                                throws DataSourceException
Read the metadata from the wrapper connection, and store in existing Schema within the wrapper. To be called by AutoMedWrapper instances as part of the wrapper creation process.

Throws:
DataSourceException

createAutoMedSchema

public abstract Schema createAutoMedSchema(AutoMedWrapper wrapper,
                                           java.lang.String schemaName)
                                    throws IntegrityException,
                                           NotFoundException
Create an AutoMed oriented schema from the source oriented schema.

Parameters:
wrapper - A wrapper containing the source oriented Schema from which the AutoMed oriented Schema should be produced.
schemaName - name of the new AutoMed construct oriented schema that is to be created from the source oriented schema. This schema must not yet exist.
Throws:
IntegrityException - if schemaName already exists.
NotFoundException - if you have not previously wrapped the datasource as a source oriented schema, using either #AutoMedWrapper.getSchema(String) or #AutoMedWrapper.selectNewAutoMedWrapper

safeIQL

public static java.lang.String safeIQL(java.lang.String unsafeIQL)
Process an indentifier to make it safe to use in the IQL language. This will drop any characters that are illegal in the IQL.

Parameters:
unsafeIQL - String containing possibliy illegal characters (e.g. $xyz)
Returns:
String safe to use as an identifier in IQL (e.g. xyz)

newAutoMedWrapper

protected abstract AutoMedWrapper newAutoMedWrapper()
Create a new empty wrapper instance that this wrapper factory is then able to populate.


setAttributeDomains

public void setAttributeDomains(java.util.List domainSpec)
Manually set the domain information for some attributes.

Parameters:
domainSpec - is a list of AttributeDomain objects

getAttributeDomains

public java.util.List getAttributeDomains()
Return the attribute domain specifications