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 SummaryFields
- 
Method SummaryModifier 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 ObjectConverts the parameter from the raw type parameter to the correct internal Object type that is stored in the data set.protected voiddoValidate(SRecordInstance instance) Called when individual field changed, or when record updated.booleanprotected EnumSet<SFieldFlags>getFlags()<T> TgetUserProperty(Object key) Get the list of validators that are bound to this field.inthashCode()booleanprotected booleanbooleanbooleanlongnextGeneratedValue(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 ObjectqueryFieldValue(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 ObjectReflected 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 StringLists 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.voidwriteFieldValue(PreparedStatement ps, int sqlIndex, Object value) Places a value in a prepared statement in the database representation used during SRecordInstance.flush.
- 
Field Details- 
quoteNamepublic boolean quoteName
 
- 
- 
Method Details- 
getFlags
- 
isUnqueriedpublic boolean isUnqueried()
- 
isDescriptivepublic boolean isDescriptive()
- 
setQuotedCauses 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.
- 
queryFieldValueIssues 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
 
- 
convertToDataSetFieldTypeConverts 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.setObjectetc., Not getObject.- Throws:
- Exception
 
- 
writeFieldValuePlaces 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)) 
- 
writeFieldValueConverts 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) 
- 
toStringLists the record and column name only. Useful in traces.
- 
toLongerStringLists all the details of the field.
- 
isForeignKeyprotected boolean isForeignKey()
- 
nextGeneratedValuepublic 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.
- 
readResolveReflected into during de-serialization to return any pre-existing SFieldMeta object- Throws:
- ObjectStreamException
 
- 
getFieldName
- 
equals
- 
hashCodepublic int hashCode()
- 
getRecordMeta- Returns:
- the sRecordMeta
 
- 
isMandatorypublic boolean isMandatory()
- 
addValidatorAdd a custom FieldValidator. Validator corresponding to data constaints (type, length, not null, ...) are added automatically.
- 
addFlagAdd a FieldFlag as an afterthought. Allows conditional flags in a constructor.
- 
getValidatorsGet the list of validators that are bound to this field. Can be useful for UI to know allowed values, etc.
- 
doValidateCalled when individual field changed, or when record updated. (Default behaviour is to call all registered validators.)
- 
putUserProperty
- 
getUserProperty
- 
getUserProperties
 
-