|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.j256.ormlite.field.BaseFieldConverter
com.j256.ormlite.field.types.BaseDataType
public abstract class BaseDataType
Base data type that defines the default persistance methods for the various data types.
Here's a good page about the mapping for a number of database types:
NOTE: If you are creating your own custom database persister, you probably will need to override the
BaseFieldConverter.sqlArgToJava(FieldType, Object, int) method as well which converts from a SQL data to
java.
| Constructor Summary | |
|---|---|
BaseDataType(SqlType sqlType,
Class<?>[] classes)
|
|
| Method Summary | |
|---|---|
Object |
convertIdNumber(Number number)
Convert a Number object to its primitive object suitable for assigning to an ID field. |
boolean |
dataIsEqual(Object fieldObj1,
Object fieldObj2)
Compare two fields of this type returning true if equals else false. |
Object |
generateId()
Return a generated id if appropriate or null if none. |
Class<?>[] |
getAssociatedClasses()
Return the classes that should be associated with this. |
String[] |
getAssociatedClassNames()
Return the class names that should be associated with this or null. |
int |
getDefaultWidth()
Return the default width associated with this type or 0 if none. |
Class<?> |
getPrimaryClass()
Return the class most associated with this persister or null if none. |
SqlType |
getSqlType()
Return the SQL type that is stored in the database for this argument. |
boolean |
isAppropriateId()
Return true if this data type can be an id column in a class. |
boolean |
isArgumentHolderRequired()
Must use ArgumentHolder when querying for values of this type. |
boolean |
isComparable()
Return true if this data type be compared in SQL statements. |
boolean |
isEscapedDefaultValue()
Return whether this field's default value should be escaped in SQL. |
boolean |
isEscapedValue()
Return whether we need to escape this value in SQL expressions. |
boolean |
isPrimitive()
Return whether this field is a primitive type or not. |
boolean |
isSelfGeneratedId()
Return true if this type creates its own generated ids else false to have the database do it. |
boolean |
isValidForField(Field field)
Return true if the field is appropriate for this persister otherwise false. |
boolean |
isValidForVersion()
Return true if this is a valid field for the DatabaseField.version(). |
boolean |
isValidGeneratedType()
Return true if this type can be auto-generated by the database. |
Object |
makeConfigObject(FieldType fieldType)
This makes a configuration object for the data-type or returns null if none. |
Object |
moveToNextValue(Object currentValue)
Move the current-value to the next value. |
abstract Object |
parseDefaultString(FieldType fieldType,
String defaultStr)
Convert a default string object and return the appropriate argument to a SQL insert or update statement. |
Object |
resultStringToJava(FieldType fieldType,
String stringValue,
int columnPos)
Convert a string result value to the related Java field. |
abstract Object |
resultToSqlArg(FieldType fieldType,
DatabaseResults results,
int columnPos)
Return the SQL argument object extracted from the results associated with column in position columnPos. |
| Methods inherited from class com.j256.ormlite.field.BaseFieldConverter |
|---|
isStreamType, javaToSqlArg, resultToJava, sqlArgToJava |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.j256.ormlite.field.FieldConverter |
|---|
isStreamType, javaToSqlArg, resultToJava, sqlArgToJava |
| Constructor Detail |
|---|
public BaseDataType(SqlType sqlType,
Class<?>[] classes)
sqlType - Type of the class as it is persisted in the databases.classes - Associated classes for this type. These should be specified if you want this type to be always used
for these Java classes. If this is a custom persister then this array should be empty.| Method Detail |
|---|
public abstract Object parseDefaultString(FieldType fieldType,
String defaultStr)
throws SQLException
FieldConverter
parseDefaultString in interface FieldConverterSQLException
public abstract Object resultToSqlArg(FieldType fieldType,
DatabaseResults results,
int columnPos)
throws SQLException
FieldConverter
resultToSqlArg in interface FieldConverterfieldType - Associated FieldType which may be null.
SQLException - If there is a problem accessing the results data.public boolean isValidForField(Field field)
DataPersister
isValidForField in interface DataPersisterpublic Class<?> getPrimaryClass()
DataPersister
getPrimaryClass in interface DataPersister
public Object makeConfigObject(FieldType fieldType)
throws SQLException
DataPersisterFieldType.getDataTypeConfigObj().
makeConfigObject in interface DataPersisterSQLException - If there are problems creating the config object. Needed for subclasses.public SqlType getSqlType()
FieldConverter
getSqlType in interface FieldConverterpublic Class<?>[] getAssociatedClasses()
DataPersister
getAssociatedClasses in interface DataPersisterpublic String[] getAssociatedClassNames()
DataPersister
getAssociatedClassNames in interface DataPersisterpublic Object convertIdNumber(Number number)
DataPersisterNumber object to its primitive object suitable for assigning to an ID field.
convertIdNumber in interface DataPersisterpublic boolean isValidGeneratedType()
DataPersister
isValidGeneratedType in interface DataPersisterpublic boolean isEscapedDefaultValue()
DataPersister
isEscapedDefaultValue in interface DataPersisterpublic boolean isEscapedValue()
DataPersister
isEscapedValue in interface DataPersisterpublic boolean isPrimitive()
DataPersister
isPrimitive in interface DataPersisterpublic boolean isComparable()
DataPersister
isComparable in interface DataPersisterpublic boolean isAppropriateId()
DataPersister
isAppropriateId in interface DataPersisterpublic boolean isArgumentHolderRequired()
DataPersisterArgumentHolder when querying for values of this type.
isArgumentHolderRequired in interface DataPersisterpublic boolean isSelfGeneratedId()
DataPersister
isSelfGeneratedId in interface DataPersisterpublic Object generateId()
DataPersister
generateId in interface DataPersisterpublic int getDefaultWidth()
DataPersister
getDefaultWidth in interface DataPersister
public boolean dataIsEqual(Object fieldObj1,
Object fieldObj2)
DataPersister
dataIsEqual in interface DataPersisterpublic boolean isValidForVersion()
DataPersisterDatabaseField.version().
isValidForVersion in interface DataPersisterpublic Object moveToNextValue(Object currentValue)
DataPersister
moveToNextValue in interface DataPersister
public Object resultStringToJava(FieldType fieldType,
String stringValue,
int columnPos)
throws SQLException
FieldConverter
resultStringToJava in interface FieldConverterSQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||