|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.j256.ormlite.field.FieldType
public class FieldType
Per field information configured from the 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.
Field Summary | |
---|---|
static String |
FOREIGN_ID_FIELD_SUFFIX
default suffix added to fields that are id fields of foreign objects |
Constructor Summary | |
---|---|
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 . |
Method Summary | ||
---|---|---|
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. |
|
|
buildForeignCollection(FT parent,
FID id,
boolean forceEager)
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. |
|
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. |
|
|
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. |
|
|
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() . |
|
Field |
getField()
|
|
String |
getFieldName()
|
|
|
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 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. |
|
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()
|
|
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 |
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. |
|
|
resultToJava(DatabaseResults results,
Map<String,Integer> columnPositions)
Get the result object from the results. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String FOREIGN_ID_FIELD_SUFFIX
Constructor Detail |
---|
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
.
SQLException
Method Detail |
---|
public void configDaoInformation(ConnectionSource connectionSource, Class<?> parentClass) throws SQLException
SQLException
BaseDaoImpl.initialize()
public Field getField()
public String getFieldName()
public Class<?> getType()
public String getColumnName()
public DataPersister getDataPersister()
public Object getDataTypeConfigObj()
public SqlType getSqlType()
public Object getDefaultValue()
DatabaseFieldConfig.getDefaultValue()
.
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
SQLException
public Object assignIdValue(Object data, Number val, ObjectCache objectCache) throws SQLException
SQLException
public <FV> FV extractRawJavaFieldValue(Object object) throws SQLException
SQLException
public Object extractJavaFieldValue(Object object) throws SQLException
SQLException
public Object extractJavaFieldToSqlArgValue(Object object) throws SQLException
SQLException
public Object convertJavaFieldToSqlArgValue(Object fieldVal) throws SQLException
SQLException
public Object moveToNextValue(Object val)
public FieldType getForeignIdField()
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()
DataPersister.isComparable()
public boolean isArgumentHolderRequired()
DataPersister.isArgumentHolderRequired()
public boolean isForeignCollection()
DatabaseFieldConfig.isForeignCollection()
public <FT,FID> BaseForeignCollection<FT,FID> buildForeignCollection(FT parent, FID id, boolean forceEager) 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.forceEager
- Set to true to force this to be an eager collection.
SQLException
public <T> T resultToJava(DatabaseResults results, Map<String,Integer> columnPositions) throws SQLException
FieldConverter.resultToJava(com.j256.ormlite.field.FieldType, com.j256.ormlite.support.DatabaseResults, int)
.
SQLException
public 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 <FV> FV getFieldValueIfNotDefault(Object object) throws SQLException
SQLException
public boolean isObjectsFieldValueDefault(Object object) throws SQLException
SQLException
public Object getJavaDefaultValueDefault()
public <T> int createWithForeignDao(T foreignData) throws SQLException
Dao.create(Object)
method.
SQLException
public 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.
SQLException
public boolean equals(Object arg)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |