| java.lang.Object simpleorm.properties.SPropertyMap simpleorm.core.SFieldMeta
All known Subclasses: simpleorm.core.SFieldScalar, simpleorm.core.SFieldReference,
SFieldMeta | abstract public class SFieldMeta extends SPropertyMap implements Serializable(Code) | | Each instance defines the meta data for a field in an
SRecordMeta . Subclasses are used for specific data types, with
SFieldObject being the most generic. Like JDBC, type
conversions are made automatically.
Internally, the types are stored accurately. Ie. the
SRecordInstance.fieldValues objects are the exact
types as declared (String, Integer, Employee etc.) However,
generous automatic conversions are performed both when accessing
these from the application and when getting and setting columns in
the database.
See SSimpleORMProperties for a descripiton of how properties are
used with fields.
|
Method Summary | |
void | checkUpdatable(SRecordInstance instance) Specialized for SReferences. | abstract Object | convertToField(Object raw) Converts the parameter from the users type to the correct internal Object type for this
field. | abstract String | defaultDataType() Return default SDATA_TYPE property. | Object | getFieldValue(SRecordInstance instance, long sqy_flags) Dispatched from SRecordInstance.getObject(), this is specialized
for references etc. | Object | getRawFieldValue(SRecordInstance instance, long sqy_flags) | public SRecordMeta | getSRecordMeta() | abstract SFieldMeta | makeForeignKey(SRecordMeta rmeta, String prefix, SPropertyValue[] pvals) Clone this key field to be a foreign key to rmeta
of the same type. | synchronized long | nextGeneratedValue(long minimum) This is used to fudge version numbers in databases that do not
properly suport them. | abstract Object | queryFieldValue(ResultSet rs, int sqlIndex) Issues a JDBC get*() on the result set for the field and converts the database type
to the appropriate internal type, eg, Double for a double field. | void | rawSetFieldValue(SRecordInstance instance, Object value) Specialized for References. | protected Object | readResolve() Same purpose as corresponding method on SRecordMeta. | void | setFieldValue(SRecordInstance instance, Object rawValue) Does generic checks before calling field type specific handler.
See SRecordInstance.setObject for a description fo the full
flow.
The internal flow is:-
SRecordInstance.setString(field, value)
SRecordInstance.setObject(field, value)
SFieldMeta.setFieldValue(this)
- Generic validation incl. | public String | toLongerString() Lists all the details of the field. | public String | toString() Lists the record and column name only. | void | writeFieldValue(PreparedStatement ps, int sqlIndex, Object value) Places a value in a prepared statement in the database representation
used during SRecordInstance.flush. | Object | writeFieldValue(Object value) Converts a single value from internal representation to database representation.
Used primarily by the writeFieldValue above, but also used for converting optimistic lock
values in SRecordInstance.flush.
Overidden by SFieldBoolean. |
fieldIndex | int fieldIndex(Code) | | The indext into SRecordMeta.fields.
|
isPrimaryKey | transient boolean isPrimaryKey(Code) | | Is part of a primary key, may also be a foreign key. ### Propertyize.
|
isReadOnly | transient boolean isReadOnly(Code) | | Can only be read, not set. Mainly SCOLUMN_NAME
|
referencedKeyField | transient SFieldMeta referencedKeyField(Code) | | If sFieldRefrence != null, then this refers to the corresponding
key field in the referenced table.
|
sFieldReference | transient SFieldReference sFieldReference(Code) | | Not null means this field is a foreign key member of the
SFieldReference. Overlapping foreign keys are not supported so
this is a scalar. (The semantics of setField are vague
Overlapping keys.) Strict inverse of
SFieldReference.foreignKeyFields .
|
SFieldMeta | SFieldMeta(SRecordMeta sRecord, String columnName, String fieldName, SPropertyValue[] pvalues)(Code) | | Creates a new field for sRecord corresponding to
columnName . pvalues are an arbitrary
list of properties that can be associated with this
field. fieldName is only used for the fieldMap and
defaults to the columnName or prefix for
references.
|
convertToField | abstract Object convertToField(Object raw) throws Exception(Code) | | Converts the parameter from the users type to the correct internal Object type for this
field. Returns the object if no conversion necessary. Used by
SRecordInstance.setObject etc.
|
defaultDataType | abstract String defaultDataType()(Code) | | Return default SDATA_TYPE property.
|
getFieldValue | Object getFieldValue(SRecordInstance instance, long sqy_flags)(Code) | | Dispatched from SRecordInstance.getObject(), this is specialized
for references etc.
|
getSRecordMeta | public SRecordMeta getSRecordMeta()(Code) | | Accessor to get the SRecordMeta of this field
|
nextGeneratedValue | synchronized long nextGeneratedValue(long minimum)(Code) | | This is used to fudge version numbers in databases that do not
properly suport them. It is rough and fails if there are
multiple JVMs, or the user switches schemas in Oracle etc. (I
had used it as a backup of Oracle etc. but that was not a good
idea.)
|
queryFieldValue | abstract Object queryFieldValue(ResultSet rs, int sqlIndex) throws Exception(Code) | | Issues a JDBC get*() on the result set for the field and converts the database type
to the appropriate internal type, eg, Double for a double field. The first
column has sqlIndex==1.
|
rawSetFieldValue | void rawSetFieldValue(SRecordInstance instance, Object value)(Code) | | Specialized for References. Called from 1. setFieldValue(),
which sets the record dirty, 2. setPrimaryKey() for which we do
not want the record marked dirty,
3. SFieldReference.rawSetFieldValue() (recursively) in which
case setFieldValue() should have already marked the record
dirty.
|
readResolve | protected Object readResolve() throws ObjectStreamException(Code) | | Same purpose as corresponding method on SRecordMeta.
This method is implemented to return the pre-existing SFieldMeta object
|
setFieldValue | void setFieldValue(SRecordInstance instance, Object rawValue)(Code) | | Does generic checks before calling field type specific handler.
See SRecordInstance.setObject for a description fo the full
flow.
The internal flow is:-
SRecordInstance.setString(field, value)
SRecordInstance.setObject(field, value)
SFieldMeta.setFieldValue(this)
- Generic validation incl. Not primary key.
- Check if changed.
SField*.convertToField(value)
SFieldMeta|Reference.setRawFieldValue(instance, value)
Note that setRawFieldValue is also called directly for keys etc.
|
toLongerString | public String toLongerString()(Code) | | Lists all the details of the field.
|
toString | public String toString()(Code) | | Lists the record and column name only. Useful in traces.
|
writeFieldValue | void writeFieldValue(PreparedStatement ps, int sqlIndex, Object value)(Code) | | Places a value in a prepared statement in the database representation
used during SRecordInstance.flush.
Can convert between internal values and database values, eg. TRUE to "Y".
(This does NOT need to handle NULL values (those are handled seperately by SRecordInstance))
|
writeFieldValue | Object writeFieldValue(Object value)(Code) | | Converts a single value from internal representation to database representation.
Used primarily by the writeFieldValue above, but also used for converting optimistic lock
values in SRecordInstance.flush.
Overidden by SFieldBoolean. (not by SFieldString).
NOTE: This does NOT need to handle NULL values (those are handled seperately by SRecordInstance)
|
|
|