|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--uk.ac.ic.doc.automed.reps.Construct
The Construct class
Each Construct represents a type of object in the language being modelled. The assumption is that each modelling language object can be represented by one of the first four classes in table 1. The other two are used to help build a Construct's scheme.
Each Construct has a scheme. If you think of a Construct as a Java
Class* and a SchemaObject as Java Object then a Construct's
scheme is it's constructor signiture and SchemaObjects are instances of a
Construct and are created by supplying arguments to
SchemaObject.createSchemaObject() as specified by the Construct's scheme.
*Not to be confused with the actual Class Construct or a
Construct's HDM class in table 1)
| Construct Class | Abbrev. | Description |
|---|---|---|
| Nodal | N | An object with extent (typically an entity type) that can exist independantly of anything else. Corresponds to an HDM node |
| Link | L | An association between at least 2 nodal or link objects - each tuple of the extent identifies one tuple from the extent of each of the associated objects. Corresponds to an HDM edge between at least two nodes or edges. |
| Link-Nodal | LN | A link which (like a normal link) associates some pre-existing nodes or links as well as some new nodes which are created along with the link. After construction, the HDM could just as easily have been created with a link construct and some nodal constucts, the point here is that the new nodes cannot exist independently of the pre-existing nodes and so must be created along with their association to them - e.g. relational fields can only exist in the context of a table. |
| Constraint | C | A sentence with holes in it which are filled by instances of the SchemaObject. Specifies some constraint in an appropriate language - e.g. a cardinality constraint on an attribute. Corresponds to an HDM constraint. The actual syntax for specifying the holes and what they get filled with has yet to be specified. |
| Alternation | A | This cannot be an object in the modelling language proper, it is used to specify a list of alternatives to a scheme argument of another Construct. An alternation object's scheme is the list of alternatives - No corresponding HDM. |
| Sequence | S | This cannot be an object in the modelling language proper, it is used to specify a sequence of constructs/labels as an argument to another construct's scheme. This is needed when a sequence of scheme aurumgents can be repeated. E.g. an n-ary relationship where each entity has an associated cardinality could be specified with the scheme argument 2..n of the sequence (entity, cardinality) - No corresponding HDM |
Each argument to the Construct scheme is either a name (String) or a
reference to another Construct. The first name argument is the actual
value of instances of the construct. Any other name arguments have
auxillary typeless objects created for them (on a per instance basis).
E.g. an er attribute might have the scheme <
In the MDR (the repository where models are stored) each scheme argument has an associated HDM type, these are
Table 2| HDM Type | Abbrev. | Scheme Argument Description |
|---|---|---|
| Node | N | The name of a new node. |
| Edge | E | The name of a new edge |
| Reference | R | A reference to another node or edge |
| Constraint | C | The constraint sentence of a constraint object (with holes) |
| Null | Z | Used for a scheme argument that has no correspondence with the HDM - e.g. a construct refence in an alternation |
There are only certain allowable combinations of scheme argument type (name | construct) and HDM type and each combination corresponded to a method call on a construct to add a new argument to its scheme.
Table 3| Argument Type : HDM Type | Method |
|---|---|
| Name:NodeName (N:N) | addNodeNameScheme() |
| Name:EdgeName (N:E) | addEdgeNameScheme() |
| Name:Constraint (N:C) | addConstraintScheme() |
| Construct:Reference (C:R) | addReferenceScheme() |
| Construct:Null (C:Z) | addReferenceScheme()** |
| Name:Null (N:Z) | addLabelScheme() |
Each allowable combination has a constraint on the cardinality that you can specify for that argument, the allowable combinations along with the class of Construct they are valid in and the allowable cardinalities are summarized in the table below.
Table 4| Construct Class | Argument Type : HDM Type | |||||
|---|---|---|---|---|---|---|
| N:N | N:E | N:C | C:R | C:Z | N:Z | |
| Nodal | 1:1 | 0..N | ||||
| Link | 1:1 | 2..N | 0..N | |||
| Link-Nodal | 1:N | 1:1 | 2..N | 0..N | ||
| Constraint | 1:1 | 0..N | 0..N | |||
| Alternation | 0..N | 0..N | ||||
| Sequence | 0..N | 0..N | ||||
Model,
ConstructScheme| Field Summary | |
static int |
CLASS_ALTERNATION
Class of construct which acts as a place holder for one of list of alternative constructs. |
static int |
CLASS_CONSTRAINT
Class of construct for constraints, i.e. |
static int |
CLASS_LINK
Class of construct for linking constructs, i.e. |
static int |
CLASS_LINK_NODAL
Class of construct for link-nodal constructs, i.e. |
static int |
CLASS_MAXIMUM
|
static int |
CLASS_MINIMUM
|
static int |
CLASS_NODAL
Class of construct for nodal constructs, i.e. |
static int |
CLASS_SEQUENCE
Class of construct which acts as a place holder for a list of constructs. |
static int |
CONSTRUCT_TYPE_ANY
|
static int |
CONSTRUCT_TYPE_ARRAY
|
static int |
CONSTRUCT_TYPE_REFERENCE
|
static Construct |
ConstructAny
|
static Construct |
ConstructArray
|
static Construct |
ConstructReference
|
| Constructor Summary | |
protected |
Construct(Model model,
int cid,
java.lang.String constructName,
int constructClass,
boolean constructIsRoot)
Instantiates a Construct. |
| Method Summary | |
ConstructScheme |
addConstraintScheme()
Constraint schemes can only be added to constructs of type Nodal, Link-Nodal, Link or Constraint Defaults to isKey = true, 1..1 |
ConstructScheme |
addConstraintScheme(boolean isKey)
|
ConstructScheme |
addConstraintScheme(int lower,
int upper)
|
ConstructScheme |
addConstraintScheme(int lower,
int upper,
boolean isKey)
|
ConstructScheme |
addEdgeNameScheme()
EdgeName schemes can only be added to LINK and LINK-NODAL construct types. |
ConstructScheme |
addEdgeNameScheme(boolean isKey)
|
ConstructScheme |
addLabelScheme()
Label schemes are scheme arguments that have no corresponding HDM (except maybe through automatic HDM node and edge names if the label is defined as key for its construct) Defaults to isKey = true, 1..1 |
ConstructScheme |
addLabelScheme(boolean isKey)
|
ConstructScheme |
addLabelScheme(int lower,
int upper)
|
ConstructScheme |
addLabelScheme(int lower,
int upper,
boolean isKey)
|
ConstructScheme |
addNodeNameScheme()
NodeName schemes can only be added to NODAL and LINK-NODAL construct types. |
ConstructScheme |
addNodeNameScheme(boolean isKey)
|
ConstructScheme |
addNodeNameScheme(int lower,
int upper)
|
ConstructScheme |
addNodeNameScheme(int lower,
int upper,
boolean isKey)
|
ConstructScheme |
addReferenceScheme(Construct type)
|
ConstructScheme |
addReferenceScheme(Construct type,
boolean isKey)
|
ConstructScheme |
addReferenceScheme(Construct type,
int lower,
int upper)
|
ConstructScheme |
addReferenceScheme(Construct type,
int lower,
int upper,
boolean isKey)
|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
ConstructScheme |
createConstructScheme(int schemeType,
Construct refCon,
boolean isKey,
int HDMType,
int lBound,
int uBound)
Deprecated. See the addXxxScheme() methods Creates a new ConstructScheme for the construct. |
boolean |
equals(java.lang.Object o)
|
void |
exportSchemes(java.io.OutputStream os)
|
void |
exportSchemes(java.io.PrintWriter pw)
|
int |
getCID()
Returns the construct identifier (CID) of the construct. |
static Construct |
getConstruct(int cid)
Returns the Construct identified by the given construct
identifier (CID). |
int |
getConstructClass()
Returns the class of the construct. |
static java.lang.String |
getConstructClassString(int conClass)
|
java.lang.String |
getConstructDescription()
Returns a printable description of the construct including all of its schemes. |
Model |
getModel()
Return the Model to which this Construct belongs |
java.lang.String |
getName()
Returns the name of the construct. |
SchemaObject[] |
getSchemaObjects()
Find all SchemaObjects that are instances of a
particular Construct. |
ConstructScheme[] |
getScheme()
Returns an array of ConstructScheme objects
representing the scheme of the construct. |
protected int |
getValuePosInScheme()
Returns the position in the construct's scheme where the construct's name is, i.e. |
void |
importSchemes(java.io.InputStream is)
|
boolean |
isRoot()
Returns whether or not the construct is a construct of its underlying model. |
void |
remove()
Removes the Construct from the repository if it is not being used, and removes all the construct's Scheme elements. |
protected static void |
removeConstructFromMap(Construct con)
Deprecated. Remove constructs using @link remove() which will also do the job of this method Removes from the HashMap that holds the CID and ref to all Construct objs. |
void |
retract()
Removes the Construct from the repository, and all other objects which depend upon it. |
void |
setConstructClass(int constructClass)
Sets the class of the construct. |
void |
setName(java.lang.String constructName)
Sets the name of the construct to the given string. |
void |
setRoot(boolean root)
Sets whether or not the construct is a construct type of its underlying data model. |
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, toString, wait, wait, wait |
| Field Detail |
public static final int CLASS_MINIMUM
public static final int CLASS_NODAL
public static final int CLASS_LINK_NODAL
public static final int CLASS_LINK
public static final int CLASS_CONSTRAINT
public static final int CLASS_ALTERNATION
SchemaObject can be an
instance of this class of construct.
public static final int CLASS_SEQUENCE
SchemaObject can be an instance of this
class of construct.
public static final int CLASS_MAXIMUM
public static final int CONSTRUCT_TYPE_ARRAY
public static final int CONSTRUCT_TYPE_ANY
public static final int CONSTRUCT_TYPE_REFERENCE
public static final Construct ConstructReference
public static final Construct ConstructAny
public static final Construct ConstructArray
| Constructor Detail |
protected Construct(Model model,
int cid,
java.lang.String constructName,
int constructClass,
boolean constructIsRoot)
Construct.
model - the model to which the construct belongs.cid - the construct identifier (CID) of the construct returned
by the MDR.constructName - name of the construct.constructClass - class of the construct.constructIsRoot - set to true if the construct is root
(i.e., it is itself a construct in its underlying model);
false otherwise.| Method Detail |
public int compare(java.lang.Object o1,
java.lang.Object o2)
compare in interface java.util.Comparatorpublic boolean equals(java.lang.Object o)
equals in interface java.util.Comparatorequals in class java.lang.Objectprotected static void removeConstructFromMap(Construct con)
public void remove()
ModelDefinitionsRepositoryException - if the Construct
is used to implement a SchemaObject.
public void retract()
throws InconsistentException
InconsistentException - if there is some unexpected
inconsistency in the repository.
public ConstructScheme createConstructScheme(int schemeType,
Construct refCon,
boolean isKey,
int HDMType,
int lBound,
int uBound)
throws java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructScheme for the construct.
schemeType - type of the scheme (one of
Scheme.TYPE_NAME,
Scheme.TYPE_CONSTRUCT,
Scheme.TYPE_ALTERNATION, and
Scheme.TYPE_SEQUENCE,
see Constants).refCon - the type of construct (of class Construct) that
is represented by the scheme position being created.isKey - set to true if the current scheme position
is (part of) the key of the whole scheme; false
otherwise.HDMType - the HDM type of the construct's scheme (one of
Scheme.HDM_TYPE_N1,
Scheme.HDM_TYPE_N2,
Scheme.HDM_TYPE_P1,
Scheme.HDM_TYPE_P1, and
Scheme.HDM_TYPE_C), see Constants.lBound - minimum occurence of the scheme.uBound - maximum occurence of the scheme.
ModelDefinitionsRepositoryException
java.sql.SQLException
DataSourceRepositoryException
java.io.IOExceptionConstructScheme
public ConstructScheme addNodeNameScheme()
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addNodeNameScheme(boolean isKey)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addNodeNameScheme(int lower,
int upper)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addNodeNameScheme(int lower,
int upper,
boolean isKey)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addEdgeNameScheme()
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addEdgeNameScheme(boolean isKey)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addReferenceScheme(Construct type)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
type - == null means any construct I guess, maybe not implementable.
construct type ?
NODAL : can't have a reference scheme
LINK or LINK-NODAL : reference is to an existing construct which has a
corresponding HDM node or edge (i.e. scheme) and
is used in the construction of this construct's
HDM scheme
CONSTRAINT : reference is to existing construct which has a corresponding
HDM node or edge (i.e. scheme) and is used in the
construction of this constraints HDM sentence through scheme
references in the construct's constraint schemes (this is
also true for constraint scheme arguments of constructs of
type NODAL, LINK or LINK-NODAL).
ALTERNATIOIN or SEQUENCE : Reference is to existing constructs, no
correlation to HDM, just syntax building.
Throws exception if construct type = NODAL
Defaults to isKey = true, 1..1
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addReferenceScheme(Construct type,
boolean isKey)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addReferenceScheme(Construct type,
int lower,
int upper)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addReferenceScheme(Construct type,
int lower,
int upper,
boolean isKey)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addConstraintScheme()
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addConstraintScheme(boolean isKey)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addConstraintScheme(int lower,
int upper)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addConstraintScheme(int lower,
int upper,
boolean isKey)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addLabelScheme()
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addLabelScheme(boolean isKey)
throws java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addLabelScheme(int lower,
int upper)
throws ConstructSchemeSyntaxException,
java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
ConstructSchemeSyntaxException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException
public ConstructScheme addLabelScheme(int lower,
int upper,
boolean isKey)
throws java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOExceptionpublic java.lang.String getName()
public int getConstructClass()
public boolean isRoot()
true if the construct is a construct of its
underlying model; false otherwise.public ConstructScheme[] getScheme()
ConstructScheme objects
representing the scheme of the construct.
ConstructScheme objects
representing the scheme of the construct.ConstructSchemepublic java.lang.String getConstructDescription()
public void setName(java.lang.String constructName)
throws ModelDefinitionsRepositoryException,
java.sql.SQLException,
DataSourceRepositoryException,
java.io.IOException
constructName - the string that is to be the construct's name.
ModelDefinitionsRepositoryException
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
public void setConstructClass(int constructClass)
throws ModelDefinitionsRepositoryException,
java.sql.SQLException,
DataSourceRepositoryException,
java.io.IOException
constructClass - the class of the construct.
ModelDefinitionsRepositoryException
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
public void setRoot(boolean root)
throws java.sql.SQLException,
DataSourceRepositoryException,
ModelDefinitionsRepositoryException,
java.io.IOException
root - set to true if the construct is a construct
type of its underlying model; false otherwise.
ModelDefinitionsRepositoryException
java.sql.SQLException
DataSourceRepositoryException
java.io.IOExceptionpublic int getCID()
public static Construct getConstruct(int cid)
throws AutoRepException
Construct identified by the given construct
identifier (CID).
Ordinarily one would usr Model.getConstruct(String) to get
a reference to Construct, i.e. against the Model to which it beongs.
Construct identified by the given construct
identifier (CID).
AutoRepException - if a reference to the construct identified
by the given construct identifier (CID) cannot be found.
protected int getValuePosInScheme()
throws AutoRepException
AutoRepException - if the position in the construct's scheme
where the construct's name is cannot be found.public static java.lang.String getConstructClassString(int conClass)
public Model getModel()
Model to which this Construct belongs
public SchemaObject[] getSchemaObjects()
throws InconsistentException,
IntegrityException
SchemaObjects that are instances of a
particular Construct. Useful when it is necessary to find
all occurances of a data modelling language in use, and to
find objects when deleting a data modelling language.
InconsistentException
IntegrityException
public void importSchemes(java.io.InputStream is)
throws java.io.IOException,
AutoRepException,
UnexpectedTokenException,
AutoMedException,
java.sql.SQLException
java.io.IOException
AutoRepException
UnexpectedTokenException
AutoMedException
java.sql.SQLExceptionpublic void exportSchemes(java.io.OutputStream os)
public void exportSchemes(java.io.PrintWriter pw)
public void write(java.io.OutputStream os)
public void write(java.io.PrintWriter pw)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||