com.j256.ormlite.field.types
Class EnumIntegerType

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.BaseEnumType
              extended by com.j256.ormlite.field.types.EnumIntegerType
All Implemented Interfaces:
DataPersister, FieldConverter

public class EnumIntegerType
extends BaseEnumType

Persists an Enum Java class as its ordinal integer value. You can also specify the EnumStringType as the type.

Author:
graywatson

Constructor Summary
protected EnumIntegerType(SqlType sqlType, Class<?>[] classes)
           
 
Method Summary
static EnumIntegerType getSingleton()
           
 boolean isEscapedValue()
          Return whether we need to escape this value in SQL expressions.
 Object javaToSqlArg(FieldType fieldType, Object obj)
          Convert a Java object and return the appropriate argument to a SQL insert or update statement.
 Object makeConfigObject(FieldType fieldType)
          This makes a configuration object for the data-type or returns null if none.
 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.BaseEnumType
enumVal, isValidForField
 
Methods inherited from class com.j256.ormlite.field.types.BaseDataType
convertIdNumber, dataIsEqual, generateId, getAssociatedClasses, getAssociatedClassNames, getDefaultWidth, getSqlType, isAppropriateId, isArgumentHolderRequired, isComparable, isEscapedDefaultValue, isPrimitive, isSelfGeneratedId, isValidForVersion, isValidGeneratedType, moveToNextValue
 
Methods inherited from class com.j256.ormlite.field.BaseFieldConverter
isStreamType, 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
isStreamType, resultToJava
 

Constructor Detail

EnumIntegerType

protected EnumIntegerType(SqlType sqlType,
                          Class<?>[] classes)
Method Detail

getSingleton

public static EnumIntegerType getSingleton()

parseDefaultString

public Object parseDefaultString(FieldType fieldType,
                                 String defaultStr)
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

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)
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

isEscapedValue

public boolean isEscapedValue()
Description copied from interface: DataPersister
Return whether we need to escape this value in SQL expressions. Numbers _must_ not be escaped but most other values should be.

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

makeConfigObject

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

Specified by:
makeConfigObject in interface DataPersister
Overrides:
makeConfigObject in class BaseDataType
Throws:
SQLException - If there are problems creating the config object.

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


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