Package simpleorm.dataset
Class SFieldMeta
java.lang.Object
simpleorm.dataset.SFieldMeta
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SFieldReference
,SFieldScalar
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.getObject
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 Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T extends SFieldMeta>
TaddFlag
(SFieldFlags flag) Add a FieldFlag as an afterthought.<T extends SFieldMeta>
TaddValidator
(SValidatorI val) Add a custom FieldValidator.protected abstract Object
Converts the parameter from the raw type parameter to the correct internal Object type that is stored in the data set.protected void
doValidate
(SRecordInstance instance) Called when individual field changed, or when record updated.boolean
protected EnumSet<SFieldFlags>
getFlags()
<T> T
getUserProperty
(Object key) Get the list of validators that are bound to this field.int
hashCode()
boolean
protected boolean
boolean
boolean
long
nextGeneratedValue
(long minimum) This is used to fudge generation of key values for in databases that do not properly suport them.<T extends SFieldMeta>
TputUserProperty
(Object key, Object value) 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.protected Object
Reflected into during de-serialization to return any pre-existing SFieldMeta object<T extends SFieldMeta>
TsetQuoted
(boolean quoted) Causes the generated sql to quote ("") the column name.abstract String
Lists all the details of the field.toString()
Lists the record and column name only.writeFieldValue
(Object value) Converts a single value from internal representation to database representation.void
writeFieldValue
(PreparedStatement ps, int sqlIndex, Object value) Places a value in a prepared statement in the database representation used during SRecordInstance.flush.
-
Field Details
-
quoteName
public boolean quoteName
-
-
Method Details
-
getFlags
-
isUnqueried
public boolean isUnqueried() -
isDescriptive
public boolean isDescriptive() -
setQuoted
Causes the generated sql to quote ("") the column name. Makes it case sensitive, allows reserved words and odd characters. Beware that Postgresql (only) defaults to lower case, not upper case. -
queryFieldValue
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.- Throws:
Exception
-
convertToDataSetFieldType
Converts the parameter from the raw type parameter to the correct internal Object type that is stored in the data set. Returns the object if no conversion necessary. Used bySRecordInstance.setObject
etc., Not getObject.- Throws:
Exception
-
writeFieldValue
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
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)
-
toString
Lists the record and column name only. Useful in traces. -
toLongerString
Lists all the details of the field. -
isForeignKey
protected boolean isForeignKey() -
nextGeneratedValue
public long nextGeneratedValue(long minimum) This is used to fudge generation of key values for 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. -
readResolve
Reflected into during de-serialization to return any pre-existing SFieldMeta object- Throws:
ObjectStreamException
-
getFieldName
-
equals
-
hashCode
public int hashCode() -
getRecordMeta
- Returns:
- the sRecordMeta
-
isMandatory
public boolean isMandatory() -
addValidator
Add a custom FieldValidator. Validator corresponding to data constaints (type, length, not null, ...) are added automatically. -
addFlag
Add a FieldFlag as an afterthought. Allows conditional flags in a constructor. -
getValidators
Get the list of validators that are bound to this field. Can be useful for UI to know allowed values, etc. -
doValidate
Called when individual field changed, or when record updated. (Default behaviour is to call all registered validators.) -
putUserProperty
-
getUserProperty
-
getUserProperties
-