com.caucho.amber.table
Class AmberColumn

java.lang.Object
  extended by com.caucho.amber.table.AmberColumn
Direct Known Subclasses:
ForeignColumn

public class AmberColumn
extends java.lang.Object

AmberColumn configuration.


Constructor Summary
AmberColumn(AmberTable table, java.lang.String name, AmberType type)
          Creates the column.
 
Method Summary
protected  ConfigException error(java.lang.String msg, java.lang.Throwable e)
           
 java.lang.String generateInsertName()
          Generates the insert name.
 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 generateLoadNative(JavaWriter out, int index)
          Generates a string to load the type as a property.
 java.lang.String generateMatchArgWhere(java.lang.String id)
          Generates the where clause.
 void generateNativeColumnNames(java.util.ArrayList<java.lang.String> names)
          Generates a string to load the type as a property.
 void generatePrologue(JavaWriter out)
          Generates the prologue.
 java.lang.String generateSelect(java.lang.String id)
          Generates the clause to load the column.
 void generateSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value)
          Generates a string to load the type as a property.
 void generateSetVersion(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value)
          Generates a string to load the type as a property.
 java.lang.String generateUpdateSet()
          Generates the update clause.
 java.lang.String generateUpdateSetNull()
          Generates the update clause setting to null.
 java.lang.String getFieldName()
          Returns the field name.
 int getLength()
          Gets the length property.
 java.lang.String getName()
          Gets the column name.
 int getPrecision()
          Gets the precision property.
 int getScale()
          Get the scale property
 java.lang.String getSQLType()
          Gets the sql type for the create table
 AmberTable getTable()
          Returns the owning table.
 AmberType getType()
          Returns the type.
 boolean isNotNull()
          Gets the not-null property.
 boolean isPrimaryKey()
          Return true for a primary key column.
 boolean isUnique()
          Gets the unique property.
 void setConfigLocation(java.lang.String location)
          Sets the config location.
 void setGeneratorType(java.lang.String type)
          Sets the generator type.
 void setLength(int length)
          Sets the length property.
 void setName(java.lang.String name)
          Sets the column name.
 void setNotNull(boolean isNotNull)
          Sets the not-null property.
 void setPrecision(int precision)
          Set the precision property.
 void setPrimaryKey(boolean isPrimaryKey)
          Sets the primary key property.
 void setScale(int scale)
          Set the scale property
 void setSQLType(java.lang.String sqlType)
          Sets the sql type for create table
 void setUnique(boolean isUnique)
          Sets the unique property.
 java.lang.Object toObjectKey(long value)
          Converts to the object key.
 java.lang.String toString()
          Returns the name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AmberColumn

public AmberColumn(AmberTable table,
                   java.lang.String name,
                   AmberType type)
Creates the column.

Parameters:
table - the owning table
name - the column sql name
type - the column's type
Method Detail

getTable

public AmberTable getTable()
Returns the owning table.


getName

public java.lang.String getName()
Gets the column name.


setName

public void setName(java.lang.String name)
Sets the column name.


setConfigLocation

public void setConfigLocation(java.lang.String location)
Sets the config location.


getType

public AmberType getType()
Returns the type.


setPrimaryKey

public void setPrimaryKey(boolean isPrimaryKey)
Sets the primary key property.


isPrimaryKey

public boolean isPrimaryKey()
Return true for a primary key column.


setGeneratorType

public void setGeneratorType(java.lang.String type)
Sets the generator type.


generateInsertName

public java.lang.String generateInsertName()
Generates the insert name.


setSQLType

public void setSQLType(java.lang.String sqlType)
Sets the sql type for create table


getSQLType

public java.lang.String getSQLType()
Gets the sql type for the create table


setLength

public void setLength(int length)
Sets the length property.


getLength

public int getLength()
Gets the length property.


setNotNull

public void setNotNull(boolean isNotNull)
Sets the not-null property.


isNotNull

public boolean isNotNull()
Gets the not-null property.


setPrecision

public void setPrecision(int precision)
Set the precision property.


getPrecision

public int getPrecision()
Gets the precision property.


setScale

public void setScale(int scale)
Set the scale property


getScale

public int getScale()
Get the scale property


setUnique

public void setUnique(boolean isUnique)
Sets the unique property.


isUnique

public boolean isUnique()
Gets the unique property.


generateSelect

public java.lang.String generateSelect(java.lang.String id)
Generates the clause to load the column.


generateMatchArgWhere

public java.lang.String generateMatchArgWhere(java.lang.String id)
Generates the where clause.


generateUpdateSet

public java.lang.String generateUpdateSet()
Generates the update clause.


generateUpdateSetNull

public java.lang.String generateUpdateSetNull()
Generates the update clause setting to null.


generatePrologue

public void generatePrologue(JavaWriter out)
                      throws java.io.IOException
Generates the prologue.

Throws:
java.io.IOException

getFieldName

public java.lang.String getFieldName()
Returns the field name.


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

generateNativeColumnNames

public void generateNativeColumnNames(java.util.ArrayList<java.lang.String> names)
Generates a string to load the type as a property.


toObjectKey

public java.lang.Object toObjectKey(long value)
Converts to the object key.


error

protected ConfigException error(java.lang.String msg,
                                java.lang.Throwable e)

toString

public java.lang.String toString()
Returns the name.

Overrides:
toString in class java.lang.Object