|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.metadata.AbstractType
de.mguennewig.pobjects.metadata.ScalarType
de.mguennewig.pobjects.metadata.RefType
public class RefType
Reference to an object.
In SQL terms, this is a foreign key constraint on the id attribute of a table. In the application it is a pointer to an object.
A foreign key constraint will be added automatically to
class declarations.
ClassDecl.createImplicitConstraints(),
ForeignKeyConstraint| Field Summary | |
|---|---|
static int |
ON_DELETE_CASCADE
|
static int |
ON_DELETE_NO_ACTION
|
static int |
ON_DELETE_RESTRICT
|
static int |
ON_DELETE_SET_DEFAULT
|
static int |
ON_DELETE_SET_NULL
|
static int |
ON_UPDATE_NO_ACTION
|
static int |
ON_UPDATE_RESTRICT
|
static int |
ON_UPDATE_SET_DEFAULT
|
static int |
ON_UPDATE_SET_NULL
|
| Fields inherited from interface de.mguennewig.pobjects.metadata.Type |
|---|
CLASS_NAME, TYPE_NAME |
| Constructor Summary | |
|---|---|
RefType(java.lang.String targetModule,
java.lang.String targetName,
ClassDecl targetClass)
Creates a new reference with default actions for ON DELETE
and ON UPDATE. |
|
RefType(java.lang.String targetModule,
java.lang.String targetName,
ClassDecl targetClass,
int onDelete)
Creates a new reference with default action for ON UPDATE. |
|
RefType(java.lang.String targetModule,
java.lang.String targetName,
ClassDecl targetClass,
int onDelete,
int onUpdate)
Creates a new reference. |
|
| Method Summary | |
|---|---|
void |
addMap(MapItem item)
Adds a mapping to this type. |
void |
checkConstraints(Record rec,
Column column)
Checks all constraints imposed on values of this type. |
java.lang.String |
formatNative(java.lang.Object value)
Map value from its `native' string representation to its
internal representation based on the type. |
java.lang.Class<?> |
getJavaClass()
Returns the Java class instance that is being used for the values of this type. |
int |
getMaxFieldSize()
Returns the maximum field size required to enter a value of this type. |
int |
getOnDelete()
|
int |
getOnUpdate()
|
java.lang.Object |
getResult(JdbcContainer db,
java.sql.ResultSet rs,
int column)
Reads the value for this type from the result set. |
int |
getResultInc()
Returns the number of columns read from the ResultSet. |
ClassDecl |
getTargetClass()
Returns the class declaration of the referenced table. |
java.lang.String |
getTargetModule()
Returns the name of the module to which the referenced table belongs. |
java.lang.String |
getTargetName()
Returns the name of the class the pointer (or foreign key) refers to. |
java.lang.String |
name(int variant)
Returns different names depending on variant for the code
generator. |
java.lang.Object |
parseNative(java.lang.String value)
Parse value according to the `native' string representation
of this type. |
void |
setParam(JdbcContainer db,
java.sql.PreparedStatement statm,
int pos,
java.lang.Object value)
Sets the parameter(s) starting at startPos. |
void |
setTargetClass(ClassDecl cl)
Sets the class declaration of the referenced table. |
| Methods inherited from class de.mguennewig.pobjects.metadata.ScalarType |
|---|
checkSyntax, expand, getMap, isScalar, labelToValue, valueToLabel |
| Methods inherited from class de.mguennewig.pobjects.metadata.AbstractType |
|---|
format, getDescription, getTypeClass, parse, setDescription, setTypeClass |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ON_DELETE_NO_ACTION
public static final int ON_DELETE_RESTRICT
public static final int ON_DELETE_CASCADE
public static final int ON_DELETE_SET_NULL
public static final int ON_DELETE_SET_DEFAULT
public static final int ON_UPDATE_NO_ACTION
public static final int ON_UPDATE_RESTRICT
public static final int ON_UPDATE_SET_NULL
public static final int ON_UPDATE_SET_DEFAULT
| Constructor Detail |
|---|
public RefType(java.lang.String targetModule,
java.lang.String targetName,
ClassDecl targetClass)
ON DELETE
and ON UPDATE.
targetModule - The name of the module to which the referenced
table belongs.targetName - The name of the class the pointer (or foreign key)
refers to.targetClass - The class declaration of the referenced table. This
must be given or null with a later call to
setTargetClass(de.mguennewig.pobjects.metadata.ClassDecl) before any usage of this type.RefType(String,String,ClassDecl,int, int),
setTargetClass(de.mguennewig.pobjects.metadata.ClassDecl)
public RefType(java.lang.String targetModule,
java.lang.String targetName,
ClassDecl targetClass,
int onDelete)
ON UPDATE.
targetModule - The name of the module to which the referenced
table belongs.targetName - The name of the class the pointer (or foreign key)
refers to.targetClass - The class declaration of the referenced table. This
must be given or null with a later call to
setTargetClass(de.mguennewig.pobjects.metadata.ClassDecl) before any usage of this type.onDelete - Specifies what the DBMS should do if the referenced row
is deleted.RefType(String,String,ClassDecl,int, int),
setTargetClass(de.mguennewig.pobjects.metadata.ClassDecl)
public RefType(java.lang.String targetModule,
java.lang.String targetName,
ClassDecl targetClass,
int onDelete,
int onUpdate)
targetModule - The name of the module to which the referenced
table belongs.targetName - The name of the class the pointer (or foreign key)
refers to.targetClass - The class declaration of the referenced table. This
must be given or null with a later call to
setTargetClass(de.mguennewig.pobjects.metadata.ClassDecl) before any usage of this type.onDelete - Specifies what the DBMS should do if the referenced row
is deleted. Defaults to ON_DELETE_NO_ACTION.onUpdate - Specifies what the DBMS should do if the referenced row
is updated. Defaults to ON_UPDATE_NO_ACTION.setTargetClass(de.mguennewig.pobjects.metadata.ClassDecl)| Method Detail |
|---|
public final int getOnDelete()
public final int getOnUpdate()
public final java.lang.String getTargetModule()
getTargetModule in interface ReferenceToClassReferenceToClass.getTargetName(),
ReferenceToClass.getTargetClass()public final java.lang.String getTargetName()
getTargetName in interface ReferenceToClasspublic final ClassDecl getTargetClass()
class declaration of the referenced table.
getTargetClass in interface ReferenceToClassReferenceToClass.setTargetClass(ClassDecl),
ReferenceToClass.getTargetName()public final void setTargetClass(ClassDecl cl)
class declaration of the referenced table.
A call to this method is only necessary if the class declaration has not been passed to the constructor to solve circle problems.
setTargetClass in interface ReferenceToClasspublic void addMap(MapItem item)
addMap in interface TypeaddMap in class ScalarTypejava.lang.UnsupportedOperationException - always as the values of this type
can't be mapped.Type.getJavaClass()
public void checkConstraints(Record rec,
Column column)
This method does nothing in the current implementation.
checkConstraints in interface TypecheckConstraints in class ScalarTyperec - The record which contains column.column - The column of rec which has this type.public java.lang.Class<?> getJavaClass()
getJavaClass in interface Typepublic int getMaxFieldSize()
This is the maximum number of characters required to enter a string representation of all valid values of this type. The typical size of an input field may be much smaller.
getMaxFieldSize in interface TypegetMaxFieldSize in class ScalarTypepublic java.lang.String formatNative(java.lang.Object value)
value from its `native' string representation to its
internal representation based on the type.
This mapping is a one-to-one mapping of string values to the type's
value set, without any translation based on MapItems associated
with the type.
For example, an integer type's implementation would accept a value like `1' and translate it to the string `&dblquote;1&dblquote;', independent of any label associated with the value `1'.
The value null is always mapped to the empty string.
formatNative in interface TypeformatNative in class AbstractTypeType.getJavaClass()public java.lang.Object parseNative(java.lang.String value)
value according to the `native' string representation
of this type.
This representation is a one-to-one mapping of the type's value set to
strings, without any translation based on MapItems associated with
the type.
For example, an integer type's implementation would accept a value like `"1"' and translate it to an integer object, but would reject a label like `"Yes"' that may be associated with the value `1'.
This method only parses the null value and throws an error
for all other values, because the value can be an Id or the value of the
visual field or even a user defined value.
parseNative in interface Typejava.lang.UnsupportedOperationException - when the parameter does not
represent the null.Type.addMap(MapItem),
Type.parse(String)
public java.lang.Object getResult(JdbcContainer db,
java.sql.ResultSet rs,
int column)
getResult in interface TypegetResult in class ScalarTypeType.getResultInc()public int getResultInc()
ResultSet.
getResultInc in interface TypegetResultInc in class ScalarTypeType.getResult(JdbcContainer,ResultSet,int)
public void setParam(JdbcContainer db,
java.sql.PreparedStatement statm,
int pos,
java.lang.Object value)
throws java.sql.SQLException
startPos.
This method is the counterpart to
Type.getResult(JdbcContainer,ResultSet,int) and
Type.getResultInc().
setParam in interface Typejava.sql.SQLException - if any database error occurs.public java.lang.String name(int variant)
variant for the code
generator.
name in interface Typename in class AbstractType
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||