com.j256.ormlite.field
Interface DataPersister

All Superinterfaces:
FieldConverter
All Known Implementing Classes:
BaseDataType, BaseDateType, BaseEnumType, BigDecimalNumericType, BigDecimalStringType, BigIntegerType, BooleanObjectType, BooleanType, ByteArrayType, ByteObjectType, ByteType, CharacterObjectType, CharType, DateLongType, DateStringType, DateType, DoubleObjectType, DoubleType, EnumIntegerType, EnumStringType, FloatObjectType, FloatType, IntegerObjectType, IntType, LongObjectType, LongStringType, LongType, SerializableType, ShortObjectType, ShortType, StringBytesType, StringType, UuidType, VoidType

public interface DataPersister
extends FieldConverter

Data type that provide Java class to/from database mapping.

If you are defining your own custom persister, then chances are you should extend BaseDataType. See DatabaseField.persisterClass().

Author:
graywatson

Method Summary
 Object convertIdNumber(Number number)
          Convert a Number object to its primitive object suitable for assigning to an ID field.
 boolean dataIsEqual(Object obj1, Object obj2)
          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.
 int getDefaultWidth()
          Return the default width associated with this type or 0 if none.
 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.
 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.
 
Methods inherited from interface com.j256.ormlite.field.FieldConverter
getSqlType, isStreamType, javaToSqlArg, parseDefaultString, resultToJava, sqlArgToJava
 

Method Detail

getAssociatedClasses

Class<?>[] getAssociatedClasses()
Return the classes that should be associated with this.


makeConfigObject

Object makeConfigObject(FieldType fieldType)
                        throws SQLException
This makes a configuration object for the data-type or returns null if none. The object can be accessed later via FieldType.getDataTypeConfigObj().

Throws:
SQLException

convertIdNumber

Object convertIdNumber(Number number)
Convert a Number object to its primitive object suitable for assigning to an ID field.


isValidGeneratedType

boolean isValidGeneratedType()
Return true if this type can be auto-generated by the database. Probably only numbers will return true.


isValidForField

boolean isValidForField(Field field)
Return true if the field is appropriate for this persister.


isEscapedDefaultValue

boolean isEscapedDefaultValue()
Return whether this field's default value should be escaped in SQL.


isEscapedValue

boolean isEscapedValue()
Return whether we need to escape this value in SQL expressions. Numbers _must_ not be escaped but most other values should be.


isPrimitive

boolean isPrimitive()
Return whether this field is a primitive type or not. This is used to know if we should throw if the field value is null.


isComparable

boolean isComparable()
Return true if this data type be compared in SQL statements.


isAppropriateId

boolean isAppropriateId()
Return true if this data type can be an id column in a class.


isArgumentHolderRequired

boolean isArgumentHolderRequired()
Must use ArgumentHolder when querying for values of this type.


isSelfGeneratedId

boolean isSelfGeneratedId()
Return true if this type creates its own generated ids else false to have the database do it.


generateId

Object generateId()
Return a generated id if appropriate or null if none.


getDefaultWidth

int getDefaultWidth()
Return the default width associated with this type or 0 if none.


dataIsEqual

boolean dataIsEqual(Object obj1,
                    Object obj2)
Compare two fields of this type returning true if equals else false.


isValidForVersion

boolean isValidForVersion()
Return true if this is a valid field for the DatabaseField.version().


moveToNextValue

Object moveToNextValue(Object currentValue)
Move the current-value to the next value. Used for the version field.



This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.