com.j256.ormlite.field.types
Class SerializableType

java.lang.Object
  extended by com.j256.ormlite.field.BaseFieldConverter
      extended by com.j256.ormlite.field.types.BaseDataType
          extended by com.j256.ormlite.field.types.SerializableType
All Implemented Interfaces:
DataPersister, FieldConverter

public class SerializableType
extends BaseDataType

Persists an unknown Java Object that is Serializable.

Author:
graywatson

Constructor Summary
protected SerializableType(SqlType sqlType, Class<?>[] classes)
          Here for others to subclass.
 
Method Summary
 Class<?> getPrimaryClass()
          Return the class most associated with this persister or null if none.
static SerializableType getSingleton()
           
 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 isStreamType()
          Return whether or not this is a SQL "stream" object.
 boolean isValidForField(Field field)
          Return true if the field is appropriate for this persister otherwise false.
 Object javaToSqlArg(FieldType fieldType, Object obj)
          Convert a Java object and return the appropriate argument to a SQL insert or update statement.
 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.
 Object resultToSqlArg(FieldType fieldType, DatabaseResults results, int columnPos)
          Return the SQL argument object extracted from the results associated with column in position columnPos.
 Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos)
          Return the object converted from the SQL arg to java.
 
Methods inherited from class com.j256.ormlite.field.types.BaseDataType
convertIdNumber, dataIsEqual, generateId, getAssociatedClasses, getAssociatedClassNames, getDefaultWidth, getSqlType, isEscapedDefaultValue, isEscapedValue, isPrimitive, isSelfGeneratedId, isValidForVersion, isValidGeneratedType, makeConfigObject, moveToNextValue
 
Methods inherited from class com.j256.ormlite.field.BaseFieldConverter
resultToJava
 
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
resultToJava
 

Constructor Detail

SerializableType

protected SerializableType(SqlType sqlType,
                           Class<?>[] classes)
Here for others to subclass.

Method Detail

getSingleton

public static SerializableType getSingleton()

parseDefaultString

public Object parseDefaultString(FieldType fieldType,
                                 String defaultStr)
                          throws SQLException
Description copied from interface: FieldConverter
Convert a default string object and return the appropriate argument to a SQL insert or update statement.

Specified by:
parseDefaultString in interface FieldConverter
Specified by:
parseDefaultString in class BaseDataType
Throws:
SQLException

resultToSqlArg

public Object resultToSqlArg(FieldType fieldType,
                             DatabaseResults results,
                             int columnPos)
                      throws SQLException
Description copied from interface: FieldConverter
Return the SQL argument object extracted from the results associated with column in position columnPos.

Specified by:
resultToSqlArg in interface FieldConverter
Specified by:
resultToSqlArg in class BaseDataType
Parameters:
fieldType - Associated FieldType which may be null.
Throws:
SQLException - If there is a problem accessing the results data.

sqlArgToJava

public Object sqlArgToJava(FieldType fieldType,
                           Object sqlArg,
                           int columnPos)
                    throws SQLException
Description copied from interface: FieldConverter
Return the object converted from the SQL arg to java.

Specified by:
sqlArgToJava in interface FieldConverter
Overrides:
sqlArgToJava in class BaseFieldConverter
Parameters:
fieldType - Associated FieldType which may be null.
sqlArg - SQL argument converted with FieldConverter.resultToSqlArg(FieldType, DatabaseResults, int) which will not be null.
Throws:
SQLException - If there are problems with the conversion.

javaToSqlArg

public Object javaToSqlArg(FieldType fieldType,
                           Object obj)
                    throws SQLException
Description copied from interface: FieldConverter
Convert a Java object and return the appropriate argument to a SQL insert or update statement.

Specified by:
javaToSqlArg in interface FieldConverter
Overrides:
javaToSqlArg in class BaseFieldConverter
Throws:
SQLException - If there are problems with the conversion.

isValidForField

public boolean isValidForField(Field field)
Description copied from interface: DataPersister
Return true if the field is appropriate for this persister otherwise false.

Specified by:
isValidForField in interface DataPersister
Overrides:
isValidForField in class BaseDataType

isStreamType

public boolean isStreamType()
Description copied from interface: FieldConverter
Return whether or not this is a SQL "stream" object. Cannot get certain stream objects from the SQL results more than once. If true, the converter has to protect itself against null values.

Specified by:
isStreamType in interface FieldConverter
Overrides:
isStreamType in class BaseFieldConverter

isComparable

public boolean isComparable()
Description copied from interface: DataPersister
Return true if this data type be compared in SQL statements.

Specified by:
isComparable in interface DataPersister
Overrides:
isComparable in class BaseDataType

isAppropriateId

public boolean isAppropriateId()
Description copied from interface: DataPersister
Return true if this data type can be an id column in a class.

Specified by:
isAppropriateId in interface DataPersister
Overrides:
isAppropriateId in class BaseDataType

isArgumentHolderRequired

public boolean isArgumentHolderRequired()
Description copied from interface: DataPersister
Must use ArgumentHolder when querying for values of this type.

Specified by:
isArgumentHolderRequired in interface DataPersister
Overrides:
isArgumentHolderRequired in class BaseDataType

resultStringToJava

public Object resultStringToJava(FieldType fieldType,
                                 String stringValue,
                                 int columnPos)
                          throws SQLException
Description copied from interface: FieldConverter
Convert a string result value to the related Java field.

Specified by:
resultStringToJava in interface FieldConverter
Overrides:
resultStringToJava in class BaseDataType
Throws:
SQLException

getPrimaryClass

public Class<?> getPrimaryClass()
Description copied from interface: DataPersister
Return the class most associated with this persister or null if none.

Specified by:
getPrimaryClass in interface DataPersister
Overrides:
getPrimaryClass in class BaseDataType


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