SchemaObject
Keywords: uk.ac.ic.doc.automed.reps.SchemaObject class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.ac.ic.doc.automed.reps
Class SchemaObject

    java.lang.Object
      uk.ac.ic.doc.automed.reps.SchemaObject

All Implemented Interfaces:
  java.lang.Comparable, java.util.Comparator, Positionable, PersistentObject

    public class SchemaObject

extends java.lang.Object
implements java.util.Comparator, java.lang.Comparable, Positionable, PersistentObject

The SchemaObject class

Author:
  Michael Boyd (mboyd@doc.ic.ac.uk), Peter McBrien (pjm@doc.ic.ac.uk), Nerissa Tong (nnyt98@doc.ic.ac.uk)
See Also:
  `Schema`, `Scheme`, `Construct`

Method Summary
`boolean` | `appearsInSchemeOf(SchemaObject so)` Determines whether or not the schema object appears anywhere in the scheme of another schema object.
`int` | `compare(java.lang.Object o1, java.lang.Object o2)`
`int` | `compareTo(java.lang.Object o)`
`protected static SchemaObject` | `createSchemaObject(Schema ownerSchema, Construct cType, AutoMedType amtype, java.lang.Object[] schemeObjects)`
`protected static SchemaObject` | `createSchemaObject(Schema ownerSchema, Construct cType, java.lang.Object[] schemeObjects)` All schemaobjects belong to schemas Creates a new schema object.
`protected static SchemaObject` | `createSchemaObjectFromDB(int obid, Schema schema)` Instantiates a `SchemaObject` whose record already exists in the STR.
`java.lang.String` | `debugString()` A String representation of this object useful for debugging code
`boolean` | `equals(java.lang.Object o)`
`java.awt.Point` | `getAbsolutePosition()` Return the absolute coordinate of this .
`java.awt.Color` | `getBackgroundColor()`
`Construct` | `getConstruct()` Returns the construct type of the schema object.
`Construct` | `getConstructType()`
`SchemaObject[]` | `getDependentSchemaObjects()` Return all `SchemaObject`s which have a reference to this `SchemaObject` in their scheme.
`SchemaObject[]` | `getDependentSchemaObjects(Construct c)` Return those `SchemaObject`s of a particular `Construct` which have a reference to this `SchemaObject` in their scheme.
`java.awt.Color` | `getForegroundColor()`
`PersistentKey` | `getKey()`
`static SchemaObject` | `getKnownSchemaObject(int obid)` Similiar to `getSchemaObject(int)` except that it throws a runtime exception `InconsistentException` if the obid is not found.
`java.lang.String` | `getLabel()` Get the text used to label this SchemaObject.
`java.awt.Point` | `getLabelPosition()`
`int` | `getLabelXPos()`
`int` | `getLabelYPos()`
`int` | `getOBID()` Returns the schema object identifier (OBID) of a schema object.
`java.util.Map` | `getPersistentAttributes()`
`java.awt.Point` | `getPosition()` Return the `Point` that represents the position of this `Positionable` in a `Panel`.
`Positionable` | `getPositionedRelativeTo()` Return the `Positionable` this is relative to.
`SchemaObject[]` | `getReferencedSchemaObjects()` Returns the set of SchemaObjects that are referenced directly or indirectly by this SchemaObject.
`java.lang.Object` | `getRepObject()`
`Schema` | `getSchema()` Returns the `Schema` to which the SchemaObject belongs.
`static SchemaObject` | `getSchemaObject(int obid)` Returns the `SchemaObject` reference that has the given schema object identifier (OBID).
`static SchemaObject` | `getSchemaObjectByOBID(int obid)` Deprecated. use `getSchemaObject(int)` instead
`int` | `getSchemaObjectType()` Return the type id of this schema object - Note link objects will not have a type
`java.lang.String` | `getSchemaObjectTypeName()` Return the type name of this schema object - Note link objects will not have a type
`java.lang.Object[]` | `getSchemeDefinition()` All SchemaObjects when they are created by methods such as `Schema.createSchemaObject`, `Schema.applyAddTransformation` and `Transformation.createAddTransformation` require that an Object array be supplied that defines the scheme of the new SchemaObject.
`java.lang.Object[]` | `getSchemeNames()` A shorthand for `#getSchemeNames(false)`
`java.lang.Object[]` | `getSchemeNames(boolean keyOnly)` Return the names of all objects in the scheme of this SchemaObject.
`java.lang.Object[]` | `getSchemeNames(int idDepth, int typeDepth)`
`java.lang.Object[]` | `getSchemeNames(int idDepth, int typeDepth, boolean keyOnly)`
`java.lang.String` | `getSchemeNamesString()` Same as calling `#Schema.getSchemaNameString(false)`
`java.lang.String` | `getSchemeNamesString(boolean keyOnly)` Returns the scheme representation this `SchemaObject` using brackets as set by `Schema.setOpenCloseSchemeBracket`.
`java.lang.String` | `getSchemeNamesString(int idDepth, int typeDepth)`
`java.lang.String` | `getSchemeNamesString(int idDepth, int typeDepth, boolean keyOnly)`
`static java.lang.String` | `getSchemeNamesString(java.lang.Object[] schemeDef)` Return the scheme string that would return from creating a `SchemaObject` using the supplied array of `Object`s.
`Scheme[]` | `getSchemeObjects()` Returns an array of schema objects that are contained in the scheme of this schema object.
`java.lang.String` | `getSchemeString()`
`java.lang.String` | `getSchemeString(Schema context)`
`Schema` | `getSubnetSchema()` Find the extensional schema in the same subnetwork as this SchemaObject.
`java.awt.Color` | `getTextColor()`
`protected static SchemaObject` | `getTransformationObject(int objectID)`
`Transformation[]` | `getTransformations()` Find the set of `Transformation`s that involve this SchemaObject.
`java.lang.String` | `getValue()` Returns the name/value of the schema object.
`int` | `getXPos()`
`int` | `getYPos()`
`static SchemaObject` | `persist(java.util.Map persistentFields)`
`static java.lang.Object[]` | `readScheme(Schema schema, Construct construct, Syntax.Tokenizer in)`
`static java.lang.String` | `readSchemeRef(Syntax.Tokenizer in)`
`static java.lang.Object[]` | `readSchemeTokens(Syntax.Tokenizer in)`
`void` | `remove()` Remove the `SchemaObject` form the repository.
`void` | `retract()` Removes the SchemaObject from the repository, and all other objects which depend upon it.
`protected boolean` | `sameScheme(SchemaObject so)` Determines whether or not the scheme is the same as that of the given `SchemaObject`.
`void` | `setAbsolutePosition(int x, int y)`
`void` | `setBackgroundColor(java.awt.Color c)`
`void` | `setConstructType(Construct cType)` Sets the construct type of the schema object.
`void` | `setForegroundColor(java.awt.Color c)`
`void` | `setLabel(java.lang.String label)`
`void` | `setLabelPosition(int x, int y)`
`void` | `setLabelXPos(int x)`
`void` | `setLabelYPos(int y)`
`void` | `setPosition(int x, int y)`
`void` | `setSchemaObjectType(int tid)` Set type_id for schema object
`void` | `setTextColor(java.awt.Color c)`
`void` | `setValue(java.lang.String v)` Sets the name/value of the schema object.
`void` | `setXPos(int x)`
`void` | `setYPos(int y)`
`java.lang.String` | `toLaTeX()` Returns the `SchemaObject` in a form that may rendered by the hdm.sty LaTeX package.
`java.lang.String` | `toString()` Ensures that instances of this class print in the "correct" AutoMed scheme notation
`void` | `write(java.io.OutputStream os)`
`void` | `write(java.io.PrintWriter pw)`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### getSchemaObjectType

    public int getSchemaObjectType()
                            throws NotFoundException

  Return the type id of this schema object - Note link objects will not have a type

  Throws:
    `NotFoundException`

### getSchemaObjectTypeName

    public java.lang.String getSchemaObjectTypeName()
                                             throws NotFoundException

  Return the type name of this schema object - Note link objects will not have a type

  Throws:
    `NotFoundException`

### createSchemaObject

    protected static SchemaObject createSchemaObject(Schema ownerSchema,
                                                     Construct cType,
                                                     java.lang.Object[] schemeObjects)
                                              throws TypeMismatchException,
                                                     IntegrityException

  All schemaobjects belong to schemas Creates a new schema object.

  Parameters:
    `ownerSchema` - the schema in whose context the `SchemaObject` is being created. Set to `null` if the schema object being created does not exist in the context of a schema, i.e., it is a transformation object.
    `cType` - construct type (of class `Construct`) of the schema object. Set to `null` if the construct being constructed is not a proper `Construct` of its underlying model (e.g. cardinality constraints for ER relationships).
    `schemeObjects` - array of `String` and/or schema objects contained in the scheme of the new schema object. The first `String` value is used as the name/value of this object.
  Throws:
    `TypeMismatchException`
    `IntegrityException`

### createSchemaObject

    protected static SchemaObject createSchemaObject(Schema ownerSchema,
                                                     Construct cType,
                                                     AutoMedType amtype,
                                                     java.lang.Object[] schemeObjects)
                                              throws TypeMismatchException,
                                                     IntegrityException

  Throws:
    `TypeMismatchException`
    `IntegrityException`

### getSubnetSchema

    public Schema getSubnetSchema()

  Find the extensional schema in the same subnetwork as this SchemaObject.

  Returns:
    the Schema that is the only extensional schema in this subnet.

### createSchemaObjectFromDB

    protected static SchemaObject createSchemaObjectFromDB(int obid,
                                                           Schema schema)
                                                    throws IntegrityException

  Instantiates a `SchemaObject` whose record already exists in the STR.

  Parameters:
    `obid` - the schema object identifier (OBID) found in the STR.
    `schema` - the schema in whose context the `SchemaObject` is being created. Set to `null` if the schema object being created does not exist in the context of a schema, i.e., it is a transformation object.
  Throws:
    `IntegrityException`

### getConstruct

    public Construct getConstruct()

  Returns the construct type of the schema object.

  Returns:
    the construct type of the schema object.

### getConstructType

    public Construct getConstructType()

### getSchema

    public Schema getSchema()

  Returns the `Schema` to which the SchemaObject belongs. This will either be an Extentional Schema, or a schema created by the transformation that created this SchemaObject.

  Returns:
    the schema to which the schema object belongs.

### getValue

    public java.lang.String getValue()

  Returns the name/value of the schema object.

  Returns:
    the name/value of the schema object.

### getSchemeNames

    public java.lang.Object[] getSchemeNames()

  A shorthand for `#getSchemeNames(false)`

### getSchemeNames

    public java.lang.Object[] getSchemeNames(boolean keyOnly)

  Return the names of all objects in the scheme of this SchemaObject. For example, for the scheme <<person,id,notnull>> in sql `Model` used by the `SQLWrapper`, this would be an object array containing 'person', 'id', and 'notnull'

  Parameters:
    `keyOnly` - when set true causes non-key names in the scheme to be ignored, In the example given above, this would reduce the array to only contain 'person' and 'id'
  Returns:
    an `Object` array contain the strings of the name. Note that where the schema name is nested, then so will the array be a nested array of objects.

### getSchemeNames

    public java.lang.Object[] getSchemeNames(int idDepth,
                                             int typeDepth)

### getSchemeNames

    public java.lang.Object[] getSchemeNames(int idDepth,
                                             int typeDepth,
                                             boolean keyOnly)

### getXPos

    public int getXPos()

  Specified by:
    `getXPos` in interface `Positionable`

### getYPos

    public int getYPos()

  Specified by:
    `getYPos` in interface `Positionable`

### setXPos

    public void setXPos(int x)

  Specified by:
    `setXPos` in interface `Positionable`

### setYPos

    public void setYPos(int y)

  Specified by:
    `setYPos` in interface `Positionable`

### getPosition

    public java.awt.Point getPosition()

  Description copied from interface: `Positionable`
  Return the `Point` that represents the position of this `Positionable` in a `Panel`. Note that depending on the implementation of the interface, this might a coordinate relative to some other positionable

  Specified by:
    `getPosition` in interface `Positionable`

### getPositionedRelativeTo

    public Positionable getPositionedRelativeTo()

  Description copied from interface: `Positionable`
  Return the `Positionable` this is relative to. If not relative to some other `Positionable` then return null.

  Specified by:
    `getPositionedRelativeTo` in interface `Positionable`

### getAbsolutePosition

    public java.awt.Point getAbsolutePosition()

  Description copied from interface: `Positionable`
  Return the absolute coordinate of this .

  Specified by:
    `getAbsolutePosition` in interface `Positionable`

### setPosition

    public void setPosition(int x,
                            int y)

  Specified by:
    `setPosition` in interface `Positionable`

### setAbsolutePosition

    public void setAbsolutePosition(int x,
                                    int y)

  Specified by:
    `setAbsolutePosition` in interface `Positionable`

### getLabelXPos

    public int getLabelXPos()

  Specified by:
    `getLabelXPos` in interface `Positionable`

### getLabelYPos

    public int getLabelYPos()

  Specified by:
    `getLabelYPos` in interface `Positionable`

### setLabelXPos

    public void setLabelXPos(int x)

  Specified by:
    `setLabelXPos` in interface `Positionable`

### setLabelYPos

    public void setLabelYPos(int y)

  Specified by:
    `setLabelYPos` in interface `Positionable`

### setLabelPosition

    public void setLabelPosition(int x,
                                 int y)

  Specified by:
    `setLabelPosition` in interface `Positionable`

### getLabelPosition

    public java.awt.Point getLabelPosition()

  Specified by:
    `getLabelPosition` in interface `Positionable`

### getLabel

    public java.lang.String getLabel()

  Get the text used to label this SchemaObject. Note that this will only include key fields of the SchemaObject, the characters that need escaping for printing are escaped..

  Specified by:
    `getLabel` in interface `Positionable`
  Returns:
    Name of this schema used for writing on to the screen or file

### setLabel

    public void setLabel(java.lang.String label)

  Specified by:
    `setLabel` in interface `Positionable`

### getRepObject

    public java.lang.Object getRepObject()

  Specified by:
    `getRepObject` in interface `Positionable`

### getForegroundColor

    public java.awt.Color getForegroundColor()

  Specified by:
    `getForegroundColor` in interface `Positionable`

### setForegroundColor

    public void setForegroundColor(java.awt.Color c)

  Specified by:
    `setForegroundColor` in interface `Positionable`

### getBackgroundColor

    public java.awt.Color getBackgroundColor()

  Specified by:
    `getBackgroundColor` in interface `Positionable`

### setBackgroundColor

    public void setBackgroundColor(java.awt.Color c)

  Specified by:
    `setBackgroundColor` in interface `Positionable`

### getTextColor

    public java.awt.Color getTextColor()

  Specified by:
    `getTextColor` in interface `Positionable`

### setTextColor

    public void setTextColor(java.awt.Color c)

  Specified by:
    `setTextColor` in interface `Positionable`

### getSchemeObjects

    public Scheme[] getSchemeObjects()

  Returns an array of schema objects that are contained in the scheme of this schema object.

  Returns:
    an array of schema objects that are contained in the scheme of this schema object.

### getSchemeDefinition

    public java.lang.Object[] getSchemeDefinition()

  All SchemaObjects when they are created by methods such as `Schema.createSchemaObject`, `Schema.applyAddTransformation` and `Transformation.createAddTransformation` require that an Object array be supplied that defines the scheme of the new SchemaObject. This method reconstructs this Object array.

  Returns:
    an object array suited to define the scheme of this SchemaObject

### getSchemeNamesString

    public java.lang.String getSchemeNamesString()
                                          throws InconsistentException

  Same as calling `#Schema.getSchemaNameString(false)`

  Throws:
    `InconsistentException`

### getSchemeNamesString

    public java.lang.String getSchemeNamesString(boolean keyOnly)

  Returns the scheme representation this `SchemaObject` using brackets as set by `Schema.setOpenCloseSchemeBracket`. Schemes are the standard way of identifying SchemaObjects in AutoMed in any user oriented presentation of a `Schema`. For example a key attribute might have the scheme <<person,id,key>>

  Parameters:
    `keyOnly` - set true causes only those elements of the scheme declared as key in the underlying `Construct` are to be included. For the key attribute example, this key scheme might be <<person,id,key>>. Which elements of a scheme are key is decided upon when the underlying `Construct` is created by calls on the `Model` to which it belongs.

### getSchemeNamesString

    public java.lang.String getSchemeNamesString(int idDepth,
                                                 int typeDepth)

### getSchemeNamesString

    public java.lang.String getSchemeNamesString(int idDepth,
                                                 int typeDepth,
                                                 boolean keyOnly)

### getSchemeNamesString

    public static java.lang.String getSchemeNamesString(java.lang.Object[] schemeDef)

  Return the scheme string that would return from creating a `SchemaObject` using the supplied array of `Object`s.

  Parameters:
    `schemeDef` - An array of `Object` instances that could be used as the scheme definition in `Schema.applyAddTransformation(uk.ac.ic.doc.automed.reps.Construct, java.lang.Object[], java.lang.String, java.lang.String)`
  Returns:
    A the scheme string that would result if a `SchemaObject` were to be created.

### toString

    public java.lang.String toString()

  Ensures that instances of this class print in the "correct" AutoMed scheme notation

  Overrides:
    `toString` in class `java.lang.Object`

### setConstructType

    public void setConstructType(Construct cType)

  Sets the construct type of the schema object.

  Parameters:
    `cType` - the construct type of the schema object.
  See Also:
    `Construct`

### setValue

    public void setValue(java.lang.String v)
                  throws InconsistentException

  Sets the name/value of the schema object.

  Parameters:
    `v` - the string that is to be the name/value of the schema object.
  Throws:
    ``
    `InconsistentException`

### setSchemaObjectType

    public void setSchemaObjectType(int tid)
                             throws InconsistentException

  Set type_id for schema object

  Throws:
    `InconsistentException`

### getOBID

    public int getOBID()

  Returns the schema object identifier (OBID) of a schema object.

  Returns:
    the schema object identifier (OBID) of a schema object.

### getSchemaObjectByOBID

    public static SchemaObject getSchemaObjectByOBID(int obid)

  Deprecated. use `getSchemaObject(int)` instead

### getSchemaObject

    public static SchemaObject getSchemaObject(int obid)
                                        throws NotFoundException

  Returns the `SchemaObject` reference that has the given schema object identifier (OBID).

  Parameters:
    `obid` - the object identifier (OBID) of a schema object that must already exist in the repository
  Returns:
    the `SchemaObject` reference that has the given schema object identifier (OBID).
  Throws:
    `NotFoundException` - if not object with obid found

### getKnownSchemaObject

    public static SchemaObject getKnownSchemaObject(int obid)

  Similiar to `getSchemaObject(int)` except that it throws a runtime exception `InconsistentException` if the obid is not found. Intended only for use with the AutoMed implementation, and not by user applications unless they are sure obid exists in the repository

### getTransformationObject

    protected static SchemaObject getTransformationObject(int objectID)
                                                   throws InconsistentException,
                                                          IntegrityException

  Throws:
    `InconsistentException`
    `IntegrityException`

### sameScheme

    protected boolean sameScheme(SchemaObject so)

  Determines whether or not the scheme is the same as that of the given `SchemaObject`.

  Parameters:
    `so` - the `SchemaObject` whose scheme is to be compared.
  Returns:
    `true` if the scheme is the same as that of the given `SchemaObject`; `false` otherwise.

### appearsInSchemeOf

    public boolean appearsInSchemeOf(SchemaObject so)
                              throws InconsistentException

  Determines whether or not the schema object appears anywhere in the scheme of another schema object.

  Parameters:
    `so` - the `SchemaObject` whose scheme is to be compared.
  Returns:
    `true` if the schema object appears anywhere in the scheme of the given `SchemaObject`; `false` otherwise.
  Throws:
    `InconsistentException`

### debugString

    public java.lang.String debugString()

  A String representation of this object useful for debugging code

### remove

    public void remove()
                throws IntegrityException

  Remove the `SchemaObject` form the repository. Note that this will only work if the SchemaObject is not used in any transformations

  Throws:
    `IntegrityException` - if the SchemaObject appears in any transformations

### retract

    public void retract()

  Removes the SchemaObject from the repository, and all other objects which depend upon it. In particular any Transformation that manipulates the SchemaObject will also be removed.

### getTransformations

    public Transformation[] getTransformations()
                                        throws InconsistentException

  Find the set of `Transformation`s that involve this SchemaObject.

  Throws:
    `InconsistentException` - if there is some unexpected inconsistency in the repository.

### getReferencedSchemaObjects

    public SchemaObject[] getReferencedSchemaObjects()

  Returns the set of SchemaObjects that are referenced directly or indirectly by this SchemaObject.

### getDependentSchemaObjects

    public SchemaObject[] getDependentSchemaObjects()

  Return all `SchemaObject`s which have a reference to this `SchemaObject` in their scheme.

### getDependentSchemaObjects

    public SchemaObject[] getDependentSchemaObjects(Construct c)

  Return those `SchemaObject`s of a particular `Construct` which have a reference to this `SchemaObject` in their scheme.

  Parameters:
    `c` - The `Construct` type of the `SchemaObject`s to return. If null, then all `SchemaObject`s are returned

### compareTo

    public int compareTo(java.lang.Object o)

  Specified by:
    `compareTo` in interface `java.lang.Comparable`

### compare

    public int compare(java.lang.Object o1,
                       java.lang.Object o2)

  Specified by:
    `compare` in interface `java.util.Comparator`

### equals

    public boolean equals(java.lang.Object o)

  Specified by:
    `equals` in interface `java.util.Comparator`
  Overrides:
    `equals` in class `java.lang.Object`

### readScheme

    public static java.lang.Object[] readScheme(Schema schema,
                                                Construct construct,
                                                Syntax.Tokenizer in)
                                         throws SyntaxException,
                                                NotFoundException

  Throws:
    `SyntaxException`
    `NotFoundException`

### readSchemeTokens

    public static java.lang.Object[] readSchemeTokens(Syntax.Tokenizer in)
                                               throws SyntaxException,
                                                      NotFoundException

  Throws:
    `SyntaxException`
    `NotFoundException`

### readSchemeRef

    public static java.lang.String readSchemeRef(Syntax.Tokenizer in)
                                          throws SyntaxException,
                                                 NotFoundException

  Throws:
    `SyntaxException`
    `NotFoundException`

### write

    public void write(java.io.OutputStream os)

### write

    public void write(java.io.PrintWriter pw)

### getSchemeString

    public java.lang.String getSchemeString()

### getSchemeString

    public java.lang.String getSchemeString(Schema context)

### getKey

    public PersistentKey getKey()

  Specified by:
    `getKey` in interface `PersistentObject`

### getPersistentAttributes

    public java.util.Map getPersistentAttributes()

  Specified by:
    `getPersistentAttributes` in interface `PersistentObject`

### persist

    public static SchemaObject persist(java.util.Map persistentFields)
                                throws AutoMedException

  Throws:
    `AutoMedException`

### toLaTeX

    public java.lang.String toLaTeX()

  Returns the `SchemaObject` in a form that may rendered by the hdm.sty LaTeX package.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD