|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.metadata.TypeRef
public final class TypeRef
A type which references a declaration of a type.
| Field Summary |
|---|
| Fields inherited from interface de.mguennewig.pobjects.metadata.Type |
|---|
CLASS_NAME, TYPE_NAME |
| Constructor Summary | |
|---|---|
TypeRef(TypeDecl typeDecl)
Creates a new type 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. |
void |
checkSyntax(java.lang.String value)
|
ClassDecl |
expand(ClassDecl classDecl,
Field field)
Expands this type to an extra table. |
java.lang.String |
format(java.lang.Object value)
Map value to its string representation. |
java.lang.String |
formatNative(java.lang.Object value)
Map value from its `native' string representation to its
internal representation based on the type. |
Description |
getDescription()
|
java.lang.Class<?> |
getJavaClass()
Returns the Java class instance that is being used for the values of this type. |
java.util.List<MapItem> |
getMap()
Returns the list of mappings. |
int |
getMaxFieldSize()
Returns the maximum field size required to enter a value of this type. |
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. |
Type |
getType()
Returns the type of the referenced type declaration. |
java.lang.String |
getTypeClass()
Returns the fully qualified class name of the type class that is used instead of this one. |
TypeDecl |
getTypeDecl()
Returns the referenced type declaration. |
boolean |
isScalar()
Tests whether this type is scalar. |
boolean |
labelToValue(java.lang.String label,
ObjectRef valueRef)
Maps label to its value if defined. |
java.lang.String |
name(int variant)
Returns different names depending on variant for the code
generator. |
java.lang.Object |
parse(java.lang.String value)
Map value to its internal representation. |
java.lang.Object |
parseNative(java.lang.String value)
Parse value according to the `native' string representation
of this type. |
static Type |
resolve(Type type)
Resolves any type references and returns the direct type. |
void |
setDescription(Description description)
|
void |
setParam(JdbcContainer db,
java.sql.PreparedStatement statm,
int pos,
java.lang.Object value)
Sets the parameter(s) starting at startPos. |
void |
setTypeClass(java.lang.String typeClass)
Sets the fully qualified class name of the type class that should be used instead of this one. |
boolean |
valueToLabel(java.lang.Object value,
ObjectRef labelRef)
Maps value to its label if defined. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TypeRef(TypeDecl typeDecl)
| Method Detail |
|---|
public TypeDecl getTypeDecl()
public Type getType()
public void addMap(MapItem item)
addMap in interface Typepublic java.util.List<MapItem> getMap()
getMap in interface TypeType.addMap(MapItem),
Type.labelToValue(String,ObjectRef),
Type.valueToLabel(Object,ObjectRef)public Description getDescription()
getDescription in interface Typepublic void setDescription(Description description)
setDescription in interface Type
public void checkConstraints(Record rec,
Column column)
throws PObjConstraintException
checkConstraints in interface Typerec - The record which contains column.column - The column of rec which has this type.
PObjConstraintException - when any constraint imposed on values of
this type is not fulfilled.
public ClassDecl expand(ClassDecl classDecl,
Field field)
Non-scalar types can not be saved directly in a field, so they will be
expanded to another table whose declaration will be
generated by this method.
expand in interface Typenull.Type.isScalar()public boolean isScalar()
isScalar in interface TypeType.expand(de.mguennewig.pobjects.metadata.ClassDecl, de.mguennewig.pobjects.metadata.Field)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 Type
public boolean labelToValue(java.lang.String label,
ObjectRef valueRef)
label to its value if defined.
labelToValue in interface Typelabel - The label for which the corresponding value should be
returned.valueRef - An optional reference which will be used to return the
corresponding value if it exists.
true if the label could mapped, otherwise
false.Type.valueToLabel(Object,ObjectRef),
Type.addMap(MapItem)
public boolean valueToLabel(java.lang.Object value,
ObjectRef labelRef)
value to its label if defined.
valueToLabel in interface Typevalue - The internal object in the type's set for which the
corresponding label should be returned.labelRef - An optional reference which will be used to return the
corresponding label if it exists.
true if the value could mapped, otherwise
false.Type.labelToValue(String,ObjectRef),
Type.addMap(MapItem)public 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 Typepublic java.lang.String format(java.lang.Object value)
value to its string representation.
If value matches one of the MapItem.getValue()s
associated with this type, then it return its associated label.
Otherwise, delegate the job to Type.formatNative(java.lang.Object).
format in interface TypeType.addMap(MapItem),
Type.formatNative(Object),
Type.valueToLabel(Object,ObjectRef)
public java.lang.Object parseNative(java.lang.String value)
throws PObjSyntaxException
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'.
parseNative in interface TypePObjSyntaxException - if value couldn't be parsed as a
string representation of this type.Type.addMap(MapItem),
Type.parse(String)
public java.lang.Object getResult(JdbcContainer db,
java.sql.ResultSet rs,
int column)
getResult in interface TypeType.getResultInc()public int getResultInc()
ResultSet.
getResultInc in interface TypeType.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 void checkSyntax(java.lang.String value)
throws PObjSyntaxException
checkSyntax in interface TypePObjSyntaxException
public java.lang.Object parse(java.lang.String value)
throws PObjSyntaxException
value to its internal representation.
If value matches one of the labels associated with this
type, then it returns its associated value. Otherwise, delegates the job
to Type.parseNative(java.lang.String).
Furthermore the syntax of the value is checked.
parse in interface TypePObjSyntaxException - if value couldn't be parsed as a
string representation of this type.Type.addMap(MapItem),
Type.labelToValue(String,ObjectRef),
Type.checkSyntax(String),
Type.parseNative(String)public java.lang.String getTypeClass()
getTypeClass in interface Typenull if this type class is used, otherwise the
fully qualified class name that should be used.public void setTypeClass(java.lang.String typeClass)
setTypeClass in interface Typepublic java.lang.String name(int variant)
variant for the code
generator.
NOTE: The variant Type.TYPE_NAME must be returned by the
sub-class.
name in interface Typepublic static Type resolve(Type type)
type - The type to resolve to the plain type.
TypeRef.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||