|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.metadata.Declaration
de.mguennewig.pobjects.metadata.TableExpr
de.mguennewig.pobjects.metadata.ClassDecl
public class ClassDecl
A class declaration describes both an application class and an SQL table.
There are three kinds of information:
CREATE TABLE' statement.unique' constraints are added to the `CREATE TABLE', but
have no counterpart in the program's definitions.visualField' identifies
the attribute that should be used to refer to an object of this class in
the user interface.
| Field Summary |
|---|
| Fields inherited from class de.mguennewig.pobjects.metadata.Declaration |
|---|
ARGUMENT_CONSTRUCTOR, CLASS_NAME, DESCRIPTOR, GENERATED_CLASS_NAME, POINTER_TYPE, SQL_ARG_COLON, SQL_ARG_DOLLAR, SQL_ARG_NONE, SQL_ARG_QUESTION_MARK |
| Constructor Summary | |
|---|---|
ClassDecl(java.lang.String name,
java.lang.String schemaName,
java.lang.String label,
IdField idField,
ClassDecl baseClass,
boolean extensible,
Field[] fields,
Join[] joins,
Constraint[] constraints,
Index[] indices,
Field visualField)
Creates a new class declaration. |
|
| Method Summary | |
|---|---|
void |
createImplicitConstraints()
Creates explicit constraints for structures that represent them only implicit. |
ClassDecl |
getBaseClass()
If the class is an extension, then this method returns the base class, otherwise null. |
ClassDecl |
getBottomClass()
|
Column |
getColumn(int index)
|
Column |
getColumnByName(java.lang.String name)
Return class field with name name. |
Constraint |
getConstraint(int n)
|
Constraint |
getConstraint(java.lang.String name)
Returns the Constraint with the given schema name. |
Field |
getField(int index)
Return class field for index. |
ForeignKeyConstraint |
getForeignKeyConstraint(Field field)
Returns the first found ForeignKeyConstraint that has the given
field as one of its source fields. |
IdField |
getIdField()
Returns the field which defines the sequence from which the primary keys of this table are taken. |
Index |
getIndex(int n)
|
Join |
getJoinByName(java.lang.String name)
|
java.lang.String |
getLabel()
Returns the string used to refer to this table in the user interface. |
Field[] |
getLocalFields(boolean includeIdField)
|
Join[] |
getLocalJoins()
|
int |
getNumColumns()
Returns number of fields local to this class. |
int |
getNumConstraints()
|
int |
getNumFields()
Returns number of fields of this class. |
int |
getNumIndices()
|
PrimaryKeyConstraint |
getPrimaryKeyConstraint()
Returns the PrimaryKeyConstraint of the class. |
java.lang.String |
getSchemaName()
Returns the table name within the database schema. |
Field |
getSortByField()
Returns the field which should be used to sort a list of objects of this class. |
java.lang.String |
getSqlFromClause(int sqlArgVariant)
|
Field |
getVisualField()
Returns the field which should be used by the application to render a reference to objects of this class. |
boolean |
isExtensible()
Returns true if this class can be used as another class's base
type. |
boolean |
isExtensionOf(TableExpr te)
Tests whether this table expression is an extension of te. |
boolean |
isMaterializedTable()
true iff this class is associated with an existing
database table. |
boolean |
isWritableClass()
Tests whether this table expression is an ClassDecl
that can also be updated. |
java.lang.String |
name(int variant)
Returns different names depending on variant for the code
generator. |
void |
setModule(Module module)
Sets the owning module and resolves the type name. |
| Methods inherited from class de.mguennewig.pobjects.metadata.TableExpr |
|---|
getClassName |
| Methods inherited from class de.mguennewig.pobjects.metadata.Declaration |
|---|
getDescription, getModule, getName, setDescription, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface de.mguennewig.pobjects.metadata.SqlEntity |
|---|
getModule |
| Constructor Detail |
|---|
public ClassDecl(java.lang.String name,
java.lang.String schemaName,
java.lang.String label,
IdField idField,
ClassDecl baseClass,
boolean extensible,
Field[] fields,
Join[] joins,
Constraint[] constraints,
Index[] indices,
Field visualField)
null in
fields, joins,
constraints, or indices is expanded
into an empty array.
name - The Java class name used for the table.schemaName - The database schema name used for the table.label - A label used to describe this class.idField - Optional ID field. This is required if this table is
extensible or a base class is given.baseClass - Optional base class for this class. If given implies
extensible.extensible - If true this class can be extended.fields - joins - constraints - indices - visualField - Optionally specifies a field used for visualizing
instances of the described class. If not given the one from the
baseClass is used if there is any or the idField. In case the class has
no ID field then this must be given.
java.lang.IllegalArgumentException - in case any of the following occurs:
null has been passed in constraints array| Method Detail |
|---|
public void setModule(Module module)
setModule in interface SqlEntitysetModule in class TableExprpublic boolean isExtensionOf(TableExpr te)
te.
isExtensionOf in class TableExprtrue if te either equals this, or is a
base table of this, otherwise false.public boolean isWritableClass()
ClassDecl
that can also be updated. Only these tables are mapped onto
PObject instances, all others are read-only and
retrieved as Record objects.
isWritableClass in class TableExprpublic final java.lang.String getSchemaName()
public final java.lang.String getLabel()
public final IdField getIdField()
If base class is set, then this field is a copy
of the base class's idField. Classes with an id field will
be derived from PObject.
If null, then the class cannot be extended and must have a
primary key declaration instead. Classes without an id field will be
derived from Record.
public final ClassDecl getBaseClass()
null.
The base class's extensible flag must be
true to support extensions. The base class relationship must
create a hierarchy. A cyclic dependency, where a class uses itself as a
base class, is invalid.
public final boolean isExtensible()
true if this class can be used as another class's base
type.
If base class is set, then this is always
true. On the SQL level, `extensible' means that the type of
rows of this table must be stored explicitly in a separate attribute.
public final int getNumConstraints()
public final Constraint getConstraint(int n)
public final Constraint getConstraint(java.lang.String name)
Constraint with the given schema name.
name - The schema name of the constraint which should be found.
null if no such exists.public ForeignKeyConstraint getForeignKeyConstraint(Field field)
ForeignKeyConstraint that has the given
field as one of its source fields.
field - The field for which a foreign key constraint should be found.
null if no such exists.
java.lang.IllegalArgumentException - if field == null.public final PrimaryKeyConstraint getPrimaryKeyConstraint()
PrimaryKeyConstraint of the class.
public final int getNumIndices()
public final Index getIndex(int n)
public final Field getVisualField()
The visual field may be null, to indicate that there is no
suitable field. In this case, the string representation is undefined.
It should be some combination of class name and internal address or
external id.
public final Field getSortByField()
This method returns by defaults the
visual field, if missing the
id field), or lacking that one null.
getPrimaryKeyConstraint()public int getNumColumns()
id field and also all fields from any base class.
getNumColumns in class TableExprgetNumFields()public Column getColumn(int index)
getColumn in class TableExprpublic final Column getColumnByName(java.lang.String name)
name.
If no such field exists, result is null.
getColumnByName in class TableExprpublic final int getNumFields()
id field, but includes all fields inherited from
any base classes.
getNumColumns()public final Field getField(int index)
index. If the class has no base class,
this is equivalent to getColumn(index).
public final Field[] getLocalFields(boolean includeIdField)
public final Join[] getLocalJoins()
public final Join getJoinByName(java.lang.String name)
public java.lang.String getSqlFromClause(int sqlArgVariant)
getSqlFromClause in class TableExprpublic final ClassDecl getBottomClass()
public boolean isMaterializedTable()
true iff this class is associated with an existing
database table.
public void createImplicitConstraints()
Currently only ForeignKeyConstraints will be generated for
Fields which refer to another table.
public java.lang.String name(int variant)
variant for the code
generator.
name in class TableExprvariant | return value |
|---|---|
Declaration.POINTER_TYPE |
< |
Declaration.CLASS_NAME |
< |
Declaration.GENERATED_CLASS_NAME |
PClass< |
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||