com.caucho.amber.type
Class AmberType

java.lang.Object
  extended by com.caucho.amber.type.AmberType
Direct Known Subclasses:
AbstractEnhancedType, AmberArrayType, BigDecimalType, BigIntegerType, BlobType, BooleanType, ByteType, CalendarType, CharacterType, ClassType, ClobType, DoubleType, EnumType, FloatType, GeneratorTableType, IntegerType, LongType, ObjectType, Primitive, PrimitiveByteArrayType, PrimitiveCharArrayType, PrimitiveType, ShortType, SqlDateType, SqlTimestampType, SqlTimeType, StringType, TrueFalseType, UtilDateType, YesNoType

public abstract class AmberType
extends java.lang.Object

The type of a property.


Constructor Summary
AmberType()
           
 
Method Summary
 EntityItem findItem(AmberConnection aConn, java.sql.ResultSet rs, int index)
          Finds the object
 java.lang.String fromObject(java.lang.String value)
          Converts from an object.
 java.lang.String generateCastFromObject(java.lang.String value)
          Converts the value.
 java.lang.String generateCreateColumnSQL(AmberPersistenceUnit manager, int length, int precision, int scale)
          Generates the type for the table.
 java.lang.String generateEquals(java.lang.String a, java.lang.String b)
          Returns a boolean equality.
 java.lang.String generateIncrementVersion(java.lang.String value)
          Generates the increment version.
 java.lang.String generateIsNull(java.lang.String value)
          Returns a test for null.
 int generateLoad(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index)
          Generates a string to load the type as a property.
 int generateLoad(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index, java.lang.Class targetType)
          Generates a string to load the type as a property.
 int generateLoadForeign(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index)
          Generates a string to load the type as a property.
 int generateLoadNative(JavaWriter out, int index)
          Generates a string to load the type as a property.
 java.lang.String generateNull()
          Returns a test for null.
 void generateSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value)
          Generates a string to set the type as a property.
 void generateSetNull(JavaWriter out, java.lang.String pstmt, java.lang.String index)
          Generates a string to set the property.
 void generateSetVersion(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value)
          Generates a string to set the type as a property.
 int getColumnCount()
          Returns the number of columns the type takes up.
 AmberType getForeignType()
          Returns the type as a foreign key.
 java.lang.String getForeignTypeName()
          Returns the java class of the type as a foreign key.
 java.lang.String getJavaTypeName()
          Returns the java type.
abstract  java.lang.String getName()
          Returns the type name.
 java.lang.Object getObject(AmberConnection aConn, java.sql.ResultSet rs, int index)
          Gets the value.
 java.lang.Object getObject(java.sql.ResultSet rs, int index)
          Gets the value.
 void init()
          Initialize the type.
 boolean isAssignableTo(java.lang.Class javaType)
          Returns true if the value is assignable to the Java type.
 boolean isAutoIncrement()
          Returns true for an auto-increment type.
 boolean isBoolean()
          Returns true for a boolean type.
 boolean isNumeric()
          Returns true for a numeric type.
 void setParameter(java.sql.PreparedStatement pstmt, int index, java.lang.Object value)
          Sets the value.
 java.lang.Object toObject(long value)
          Converts to an object.
 java.lang.String toObject(java.lang.String value)
          Converts to an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AmberType

public AmberType()
Method Detail

getName

public abstract java.lang.String getName()
Returns the type name.


isBoolean

public boolean isBoolean()
Returns true for a boolean type.


isNumeric

public boolean isNumeric()
Returns true for a numeric type.


getJavaTypeName

public java.lang.String getJavaTypeName()
Returns the java type.


getColumnCount

public int getColumnCount()
Returns the number of columns the type takes up.


init

public void init()
          throws ConfigException
Initialize the type.

Throws:
ConfigException

getForeignType

public AmberType getForeignType()
Returns the type as a foreign key.


getForeignTypeName

public java.lang.String getForeignTypeName()
Returns the java class of the type as a foreign key.


isAssignableTo

public boolean isAssignableTo(java.lang.Class javaType)
Returns true if the value is assignable to the Java type.


generateCreateColumnSQL

public java.lang.String generateCreateColumnSQL(AmberPersistenceUnit manager,
                                                int length,
                                                int precision,
                                                int scale)
Generates the type for the table.


generateLoad

public int generateLoad(JavaWriter out,
                        java.lang.String rs,
                        java.lang.String indexVar,
                        int index)
                 throws java.io.IOException
Generates a string to load the type as a property.

Throws:
java.io.IOException

generateLoadNative

public int generateLoadNative(JavaWriter out,
                              int index)
                       throws java.io.IOException
Generates a string to load the type as a property.

Throws:
java.io.IOException

generateLoad

public int generateLoad(JavaWriter out,
                        java.lang.String rs,
                        java.lang.String indexVar,
                        int index,
                        java.lang.Class targetType)
                 throws java.io.IOException
Generates a string to load the type as a property.

Throws:
java.io.IOException

generateLoadForeign

public int generateLoadForeign(JavaWriter out,
                               java.lang.String rs,
                               java.lang.String indexVar,
                               int index)
                        throws java.io.IOException
Generates a string to load the type as a property.

Throws:
java.io.IOException

generateSet

public void generateSet(JavaWriter out,
                        java.lang.String pstmt,
                        java.lang.String index,
                        java.lang.String value)
                 throws java.io.IOException
Generates a string to set the type as a property.

Throws:
java.io.IOException

generateSetVersion

public void generateSetVersion(JavaWriter out,
                               java.lang.String pstmt,
                               java.lang.String index,
                               java.lang.String value)
                        throws java.io.IOException
Generates a string to set the type as a property.

Throws:
java.io.IOException

generateIncrementVersion

public java.lang.String generateIncrementVersion(java.lang.String value)
                                          throws java.io.IOException
Generates the increment version.

Throws:
java.io.IOException

generateSetNull

public void generateSetNull(JavaWriter out,
                            java.lang.String pstmt,
                            java.lang.String index)
                     throws java.io.IOException
Generates a string to set the property.

Throws:
java.io.IOException

setParameter

public void setParameter(java.sql.PreparedStatement pstmt,
                         int index,
                         java.lang.Object value)
                  throws java.sql.SQLException
Sets the value.

Throws:
java.sql.SQLException

getObject

public java.lang.Object getObject(java.sql.ResultSet rs,
                                  int index)
                           throws java.sql.SQLException
Gets the value.

Throws:
java.sql.SQLException

findItem

public EntityItem findItem(AmberConnection aConn,
                           java.sql.ResultSet rs,
                           int index)
                    throws java.sql.SQLException
Finds the object

Throws:
java.sql.SQLException

getObject

public java.lang.Object getObject(AmberConnection aConn,
                                  java.sql.ResultSet rs,
                                  int index)
                           throws java.sql.SQLException
Gets the value.

Throws:
java.sql.SQLException

toObject

public java.lang.String toObject(java.lang.String value)
Converts to an object.


fromObject

public java.lang.String fromObject(java.lang.String value)
Converts from an object.


toObject

public java.lang.Object toObject(long value)
Converts to an object.


generateCastFromObject

public java.lang.String generateCastFromObject(java.lang.String value)
Converts the value.


generateEquals

public java.lang.String generateEquals(java.lang.String a,
                                       java.lang.String b)
Returns a boolean equality.


generateIsNull

public java.lang.String generateIsNull(java.lang.String value)
Returns a test for null.


generateNull

public java.lang.String generateNull()
Returns a test for null.


isAutoIncrement

public boolean isAutoIncrement()
Returns true for an auto-increment type.