public class FieldType extends Object
DatabaseField annotation and the associated Field in the
class. Use the createFieldType(com.j256.ormlite.support.ConnectionSource, java.lang.String, java.lang.reflect.Field, java.lang.Class<?>) static method to instantiate the class.| Modifier and Type | Field and Description |
|---|---|
static String |
FOREIGN_ID_FIELD_SUFFIX
default suffix added to fields that are id fields of foreign objects
|
| Constructor and Description |
|---|
FieldType(ConnectionSource connectionSource,
String tableName,
Field field,
DatabaseFieldConfig fieldConfig,
Class<?> parentClass)
You should use
createFieldType(com.j256.ormlite.support.ConnectionSource, java.lang.String, java.lang.reflect.Field, java.lang.Class<?>) to instantiate one of these field if you have a Field. |
| Modifier and Type | Method and Description |
|---|---|
void |
assignField(Object data,
Object val,
boolean parentObject,
ObjectCache objectCache)
Assign to the data object the val corresponding to the fieldType.
|
Object |
assignIdValue(Object data,
Number val,
ObjectCache objectCache)
Assign an ID value to this field.
|
<FT,FID> BaseForeignCollection<FT,FID> |
buildForeignCollection(Object parent,
FID id)
Build and return a foreign collection based on the field settings that matches the id argument.
|
void |
configDaoInformation(ConnectionSource connectionSource,
Class<?> parentClass)
Because we go recursive in a lot of situations if we construct DAOs inside of the FieldType constructor, we have
to do this 2nd pass initialization so we can better use the DAO caches.
|
Object |
convertJavaFieldToSqlArgValue(Object fieldVal)
Convert a field value to something suitable to be stored in the database.
|
Object |
convertStringToJavaField(String value,
int columnPos)
Convert a string value into the appropriate Java field value.
|
static FieldType |
createFieldType(ConnectionSource connectionSource,
String tableName,
Field field,
Class<?> parentClass)
Return An instantiated
FieldType or null if the field does not have a DatabaseField annotation. |
<T> int |
createWithForeignDao(T foreignData)
Pass the foreign data argument to the foreign
Dao.create(Object) method. |
boolean |
equals(Object arg) |
Object |
extractJavaFieldToSqlArgValue(Object object)
Extract a field from an object and convert to something suitable to be passed to SQL as an argument.
|
Object |
extractJavaFieldValue(Object object)
Return the value from the field in the object that is defined by this FieldType.
|
<FV> FV |
extractRawJavaFieldValue(Object object)
Return the value from the field in the object that is defined by this FieldType.
|
Object |
generateId()
Call through to
DataPersister.generateId() |
String |
getColumnDefinition()
Call through to
DatabaseFieldConfig.getColumnDefinition() |
String |
getColumnName() |
DataPersister |
getDataPersister() |
Object |
getDataTypeConfigObj() |
Object |
getDefaultValue()
Return the default value as parsed from the
DatabaseFieldConfig.getDefaultValue() or null if no default
value. |
Field |
getField() |
String |
getFieldName() |
<FV> FV |
getFieldValueIfNotDefault(Object object)
Return the value of field in the data argument if it is not the default value for the class.
|
FieldType |
getForeignIdField()
Return the id of the associated foreign object or null if none.
|
FieldType |
getForeignRefField()
Return the field associated with the foreign object or null if none.
|
String |
getFormat()
Return the format of the field.
|
String |
getGeneratedIdSequence()
Return the generated-id-sequence associated with the field or null if
isGeneratedIdSequence() is false. |
Type |
getGenericType()
Return the generic type of the field associated with this field type.
|
String |
getIndexName() |
Object |
getJavaDefaultValueDefault()
Return whether or not the field value passed in is the default value for the type of the field.
|
SqlType |
getSqlType() |
String |
getTableName() |
Class<?> |
getType()
Return the class of the field associated with this field type.
|
String |
getUniqueIndexName() |
Enum<?> |
getUnknownEnumVal() |
int |
getWidth() |
int |
hashCode() |
boolean |
isAllowGeneratedIdInsert()
Call through to
DatabaseFieldConfig.isAllowGeneratedIdInsert() |
boolean |
isArgumentHolderRequired()
Call through to
DataPersister.isArgumentHolderRequired() |
boolean |
isCanBeNull() |
boolean |
isComparable()
Call through to
DataPersister.isComparable() |
boolean |
isEscapedDefaultValue()
Call through to
DataPersister.isEscapedDefaultValue() |
boolean |
isEscapedValue()
Call through to
DataPersister.isEscapedValue() |
boolean |
isForeign() |
boolean |
isForeignAutoCreate()
Call through to
DatabaseFieldConfig.isForeignAutoCreate() |
boolean |
isForeignCollection()
Call through to
DatabaseFieldConfig.isForeignCollection() |
boolean |
isGeneratedId()
Return whether the field is a generated-id field.
|
boolean |
isGeneratedIdSequence()
Return whether the field is a generated-id-sequence field.
|
boolean |
isId()
Return whether the field is an id field.
|
boolean |
isObjectsFieldValueDefault(Object object)
Return whether or not the data object has a default value passed for this field of this type.
|
boolean |
isReadOnly()
Call through to
DatabaseFieldConfig.isReadOnly() |
boolean |
isSelfGeneratedId()
Call through to
DataPersister.isSelfGeneratedId() |
boolean |
isUnique() |
boolean |
isUniqueCombo() |
boolean |
isVersion()
Call through to
DatabaseFieldConfig.isVersion() |
Object |
moveToNextValue(Object val)
Move the SQL value to the next one for version processing.
|
<T> T |
resultToJava(DatabaseResults results,
Map<String,Integer> columnPositions)
Get the result object from the results.
|
String |
toString() |
public static final String FOREIGN_ID_FIELD_SUFFIX
public FieldType(ConnectionSource connectionSource, String tableName, Field field, DatabaseFieldConfig fieldConfig, Class<?> parentClass) throws SQLException
createFieldType(com.j256.ormlite.support.ConnectionSource, java.lang.String, java.lang.reflect.Field, java.lang.Class<?>) to instantiate one of these field if you have a Field.SQLExceptionpublic void configDaoInformation(ConnectionSource connectionSource, Class<?> parentClass) throws SQLException
SQLExceptionBaseDaoImpl.initialize()public Field getField()
public String getTableName()
public String getFieldName()
public Class<?> getType()
public Type getGenericType()
public String getColumnName()
public DataPersister getDataPersister()
public Object getDataTypeConfigObj()
public SqlType getSqlType()
public Object getDefaultValue()
DatabaseFieldConfig.getDefaultValue() or null if no default
value.public int getWidth()
public boolean isCanBeNull()
public boolean isId()
DatabaseField.id(),
DatabaseField.generatedId(), OR DatabaseField.generatedIdSequence() are enabled.public boolean isGeneratedId()
DatabaseField.generatedId() OR
DatabaseField.generatedIdSequence() are enabled.public boolean isGeneratedIdSequence()
DatabaseField.generatedIdSequence() is specified OR if DatabaseField.generatedId() is enabled and the
DatabaseType.isIdSequenceNeeded() is enabled. If the latter is true then the sequence name will be
auto-generated.public String getGeneratedIdSequence()
isGeneratedIdSequence() is false.public boolean isForeign()
public void assignField(Object data, Object val, boolean parentObject, ObjectCache objectCache) throws SQLException
SQLExceptionpublic Object assignIdValue(Object data, Number val, ObjectCache objectCache) throws SQLException
SQLExceptionpublic <FV> FV extractRawJavaFieldValue(Object object) throws SQLException
SQLExceptionpublic Object extractJavaFieldValue(Object object) throws SQLException
SQLExceptionpublic Object extractJavaFieldToSqlArgValue(Object object) throws SQLException
SQLExceptionpublic Object convertJavaFieldToSqlArgValue(Object fieldVal) throws SQLException
SQLExceptionpublic Object convertStringToJavaField(String value, int columnPos) throws SQLException
SQLExceptionpublic Object moveToNextValue(Object val) throws SQLException
SQLExceptionpublic FieldType getForeignIdField()
public FieldType getForeignRefField()
public boolean isEscapedValue()
DataPersister.isEscapedValue()public Enum<?> getUnknownEnumVal()
public String getFormat()
public boolean isUnique()
public boolean isUniqueCombo()
public String getIndexName()
public String getUniqueIndexName()
public boolean isEscapedDefaultValue()
DataPersister.isEscapedDefaultValue()public boolean isComparable()
throws SQLException
DataPersister.isComparable()SQLExceptionpublic boolean isArgumentHolderRequired()
DataPersister.isArgumentHolderRequired()public boolean isForeignCollection()
DatabaseFieldConfig.isForeignCollection()public <FT,FID> BaseForeignCollection<FT,FID> buildForeignCollection(Object parent, FID id) throws SQLException
parent - The parent object that we will set on each item in the collection.id - The id of the foreign object we will look for. This can be null if we are creating an empty
collection.SQLExceptionpublic <T> T resultToJava(DatabaseResults results, Map<String,Integer> columnPositions) throws SQLException
FieldConverter.resultToJava(com.j256.ormlite.field.FieldType, com.j256.ormlite.support.DatabaseResults, int).SQLExceptionpublic boolean isSelfGeneratedId()
DataPersister.isSelfGeneratedId()public boolean isAllowGeneratedIdInsert()
DatabaseFieldConfig.isAllowGeneratedIdInsert()public String getColumnDefinition()
DatabaseFieldConfig.getColumnDefinition()public boolean isForeignAutoCreate()
DatabaseFieldConfig.isForeignAutoCreate()public boolean isVersion()
DatabaseFieldConfig.isVersion()public Object generateId()
DataPersister.generateId()public boolean isReadOnly()
DatabaseFieldConfig.isReadOnly()public <FV> FV getFieldValueIfNotDefault(Object object) throws SQLException
SQLExceptionpublic boolean isObjectsFieldValueDefault(Object object) throws SQLException
SQLExceptionpublic Object getJavaDefaultValueDefault()
public <T> int createWithForeignDao(T foreignData)
throws SQLException
Dao.create(Object) method.SQLExceptionpublic static FieldType createFieldType(ConnectionSource connectionSource, String tableName, Field field, Class<?> parentClass) throws SQLException
FieldType or null if the field does not have a DatabaseField annotation.SQLExceptionThis documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.