uk.ac.ic.doc.automed.matching
Class SchemaElement

java.lang.Object
  extended by uk.ac.ic.doc.automed.matching.SchemaElement

public class SchemaElement
extends java.lang.Object

The SchemaElement class to wrap schema objects in schema matching. The SchemaElement represents a schema object that can be used in the schema matching process. The SchemaElement is aware of the name of the schema object, its instances and the data type of its instances. A SchemaElement is "atomic" when it has unary tuples as instances, otherwise it is "non-atomic".

See Also:
SchemaObject

Field Summary
static java.lang.Integer CHAR
           
static java.lang.Integer ELSE
           
static char[] features
           
static int MAX_CHARS
           
static java.lang.Integer NUM
           
static java.lang.Integer NUMCHAR
           
 
Constructor Summary
SchemaElement(SchemaObject o, boolean isAtomic)
          Instantiates a schema element.
 
Method Summary
 void addAttachedElement(SchemaElement se)
           
 boolean containsInstance(java.lang.Object s)
          Returns true if the SchemaElement object contains the specified instance.
 boolean equals(java.lang.Object o)
          Compares this object against the specified object.
 SchemaElement[] getAttachedElements()
           
 Averages getAverages()
           
 int getDataType()
          Returns the data type of the schema element.
 java.lang.Integer getDtPattern()
           
static SchemaElement getElement(SchemaObject o, boolean isAtomic)
          Returns a SchemaElement object.
static SchemaElement getElement(java.lang.String hashCode, boolean isAtomic)
          Returns a SchemaElement object.
protected static int getGenericDataType(java.lang.String type)
           
 java.lang.String[] getInstances()
           
 Instance[] getInstancesSorted()
          Returns the sorted array of the instances of this SchemaElement object.
 Range getLengthRange()
           
 java.lang.String getName()
          Returns the name of the schema element.
 Range getNumCharRange()
           
 int getNumOfDistinctInstances()
           
 Range getNumRange()
           
 java.lang.String getQuery()
           
 java.lang.String getQueryVariables()
           
 java.lang.String getRandomInstance()
          Returns a random instance of the SchemaElement object.
static SchemaElement[] getSchemaElements(Schema s, int constructClass, boolean atomic)
          Returns an array of schema elements that belong to the schema.
static SchemaElement[] getSchemaElements(Schema s, SchemaObject[] sos, int constructClass, boolean atomic)
          Returns an array of schema elements based on the schema objects' array.
 SchemaObject getSchemaObject()
          Returns the SchemaObject wrapped by this SchemaElement object.
 int hashCode()
          Returns a hash code for this SchemaElement object.
 boolean isAtomic()
          Returns true if the schema element is "atomic", false otherwise.
 int numOfInstances()
          Returns the number of distinct instances of this object.
static void printElements()
           
 void setDataType(int type)
          Sets the data type of the schema element.
protected  void setFullPatterns()
           
 void setInstances(java.util.ArrayList insts)
           
 void setName(java.lang.String name)
          Sets the name of the schema element.
protected  void setPatterns()
           
 void setQuery(java.lang.String query)
           
 void setQueryVariables(java.lang.String variables)
           
 java.lang.String toString()
          Returns a string representation of this SchemaElement object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ELSE

public static final java.lang.Integer ELSE

NUM

public static final java.lang.Integer NUM

NUMCHAR

public static final java.lang.Integer NUMCHAR

CHAR

public static final java.lang.Integer CHAR

features

public static final char[] features

MAX_CHARS

public static int MAX_CHARS
Constructor Detail

SchemaElement

public SchemaElement(SchemaObject o,
                     boolean isAtomic)
Instantiates a schema element.

Parameters:
o - the schema object to be wrapped into a schema element
isAtomic - whether the create schema element is "atomic" or not. true if the element is "atomic", false otherwise.
Method Detail

setQuery

public void setQuery(java.lang.String query)

getQuery

public java.lang.String getQuery()

setQueryVariables

public void setQueryVariables(java.lang.String variables)

getQueryVariables

public java.lang.String getQueryVariables()

getDtPattern

public java.lang.Integer getDtPattern()

setFullPatterns

protected void setFullPatterns()
                        throws UninstantiatedException
Throws:
UninstantiatedException

setPatterns

protected void setPatterns()
                    throws UninstantiatedException
Throws:
UninstantiatedException

getAverages

public Averages getAverages()

getLengthRange

public Range getLengthRange()

getNumCharRange

public Range getNumCharRange()

getNumRange

public Range getNumRange()

isAtomic

public boolean isAtomic()
Returns true if the schema element is "atomic", false otherwise.

Returns:
true if the schema element is "atomic", false otherwise.i

equals

public boolean equals(java.lang.Object o)
Compares this object against the specified object. The result of this method depends on equivalence of the schema objects wrapped by the corresponding schema elements SchemaObject.equals(Object).

Overrides:
equals in class java.lang.Object
Returns:
true if the objects are the same, false otherwise.

hashCode

public int hashCode()
Returns a hash code for this SchemaElement object. This hash code is equivalent to the hash code of the wrapped SchemaObject.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code for this SchemaElement object.

toString

public java.lang.String toString()
Returns a string representation of this SchemaElement object. This string representation comes from the string representation of the wrapper SchemaObject.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this SchemaElement object.

getSchemaObject

public SchemaObject getSchemaObject()
Returns the SchemaObject wrapped by this SchemaElement object.

Returns:
the SchemaObject wrapped by this SchemaElement object.

setName

public void setName(java.lang.String name)
Sets the name of the schema element.

Parameters:
name - the name of the schema element.

getName

public java.lang.String getName()
Returns the name of the schema element.

Returns:
the name of the schema element.

setDataType

public void setDataType(int type)
Sets the data type of the schema element. The type should be one of the SQL types Types.

Parameters:
type - the type of the schema element.

getDataType

public int getDataType()
Returns the data type of the schema element.

Returns:
the data type of the schema element.

getRandomInstance

public java.lang.String getRandomInstance()
                                   throws UninstantiatedException,
                                          MatchException
Returns a random instance of the SchemaElement object.

Returns:
a random instance of the SchemaElement object.
Throws:
UnistantiatedException - if the schema element doens't contain any instances.
UninstantiatedException
MatchException

containsInstance

public boolean containsInstance(java.lang.Object s)
                         throws MatchException
Returns true if the SchemaElement object contains the specified instance.

Returns:
true if the SchemaElement object contains the specified instance, false otherwise.
Throws:
MatchException

numOfInstances

public int numOfInstances()
                   throws MatchException
Returns the number of distinct instances of this object.

Returns:
the number of distinct instances of this object.
Throws:
MatchException

setInstances

public void setInstances(java.util.ArrayList insts)

getInstances

public java.lang.String[] getInstances()

getNumOfDistinctInstances

public int getNumOfDistinctInstances()

addAttachedElement

public void addAttachedElement(SchemaElement se)

getAttachedElements

public SchemaElement[] getAttachedElements()

getInstancesSorted

public Instance[] getInstancesSorted()
                              throws MatchException
Returns the sorted array of the instances of this SchemaElement object. The array is made up of Instance objects. The array is sorted based on the number of appearances of each instance.

Returns:
the sorted array of the instances of this SchemaElement object.
Throws:
MatchException

printElements

public static void printElements()

getElement

public static SchemaElement getElement(java.lang.String hashCode,
                                       boolean isAtomic)
Returns a SchemaElement object. The returned object has the specified hashCode and it's either "atomic" or not, based on the isAtomic argument. Returns null if such an object doesn't exist.

Parameters:
hashCode - the hash code of the SchemaElement object.
isAtomic - true if the returned SchemaElement object is "atomic", false otherwise.
Returns:
a SchemaElement object.

getElement

public static SchemaElement getElement(SchemaObject o,
                                       boolean isAtomic)
Returns a SchemaElement object. The returned object wraps the specified SchemaObject and it's either "atomic" or not, based on the isAtomic argument.

Parameters:
o - the SchemaObject wrapped by the SchemaElement
isAtomic - true if the returned SchemaElement object is "atomic", false otherwise.
Returns:
a SchemaElement object.

getSchemaElements

public static SchemaElement[] getSchemaElements(Schema s,
                                                int constructClass,
                                                boolean atomic)
                                         throws IntegrityException,
                                                java.lang.Exception
Returns an array of schema elements that belong to the schema.

Parameters:
s - The schema which contains the schema objects that are going to be wrapped in schema elements.
constructClass - The construct class of the schema objects that are going to be wrapped to schema elements.
atomic - If true then the schema elements returned are going to be "atomic", otherwise "non-atomic".
Returns:
an array of schema elements that belong to the schema. For each SchemaObject of constructClass in schema s, a SchemaElement is constructed and returned.
Throws:
IntegrityException - if the extensional schemas attached to s cannot be found
java.lang.Exception - if the GAVQueryReformulationProvider cannot be instantiated for s and its attached extensional schemas.

getSchemaElements

public static SchemaElement[] getSchemaElements(Schema s,
                                                SchemaObject[] sos,
                                                int constructClass,
                                                boolean atomic)
                                         throws IntegrityException,
                                                java.lang.Exception
Returns an array of schema elements based on the schema objects' array.

Parameters:
s - The schema that the schema objects in sos should be part of.
sos - The array of schema objects.
constructClass - The construct class of the schema objects that are going to be wrapped to schema elements.
atomic - If true then the schema elements returned are going to be "atomic", otherwise "non-atomic".
Returns:
an array of schema elements. For each schema object of constructClass in array sos a SchemaElement is returned.
Throws:
IntegrityException - if the extensional schemas attached to s cannot be found
java.lang.Exception - if the GAVQueryReformulationProvider cannot be instantiated for s and its attached extensional schemas.

getGenericDataType

protected static int getGenericDataType(java.lang.String type)
                                 throws InvalidElementException
Throws:
InvalidElementException