com.caucho.amber.field
Class AbstractField

java.lang.Object
  extended by com.caucho.amber.field.AbstractField
All Implemented Interfaces:
AmberField
Direct Known Subclasses:
CascadableField, EntityEmbeddedField, EntityMapField, PropertyField

public abstract class AbstractField
extends java.lang.Object
implements AmberField

Configuration for a bean's property


Method Summary
 void childDelete(AmberConnection aConn, java.io.Serializable primaryKey)
          Deletes the children
 AmberExpr createExpr(QueryParser parser, PathExpr parent)
          Creates the expression for the field.
 java.lang.String generateCastFromObject(java.lang.String value)
          Generates code to convert to the type from the object.
 void generateCopyLoadObject(JavaWriter out, java.lang.String dst, java.lang.String src, int loadIndex)
          Updates the cached copy.
 void generateCopyUpdateObject(JavaWriter out, java.lang.String dst, java.lang.String src, int updateIndex)
          Updates the cached copy.
 java.lang.String generateCreateTableSQL(AmberPersistenceUnit manager)
          Generates the table create.
 void generateDetach(JavaWriter out)
          Generates the detachment code
 void generateDumpRelationships(JavaWriter out, int updateIndex)
          Checks entity-relationships from an object.
 java.lang.String generateEquals(java.lang.String leftBase, java.lang.String value)
          Generates code to test the equals.
 void generateExpire(JavaWriter out)
          Generates the expire code
 void generateGet(JavaWriter out, java.lang.String objThis)
          Generates the field getter.
 java.lang.String generateGet(java.lang.String objThis)
          Generates the field getter.
 void generateGetterMethod(JavaWriter out)
          Generates the getter method implementation.
 java.lang.String generateInsert()
          Generates the insert.
 void generateInsertColumns(java.util.ArrayList<java.lang.String> columns)
          Generates the insert.
 void generateInsertSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String obj)
          Generates the set clause for the insert clause.
 void generateInvalidateForeign(JavaWriter out)
          Generates code for foreign entity create/delete
 java.lang.String generateJavaSelect(java.lang.String id)
          Generates the JPA QL select clause.
 int generateLoad(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index)
          Generates loading code
 void generateLoadFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 int generateLoadNative(JavaWriter out, int index)
          Generates loading for a native query
 java.lang.String generateLoadSelect(AmberTable table, java.lang.String id)
          Generates the select clause for an entity load.
 void generateMergeFrom(JavaWriter out, java.lang.String dst, java.lang.String src)
          Updates the cached copy.
 void generateNativeColumnNames(java.util.ArrayList<java.lang.String> names)
          Generates loading for a native query
 java.lang.String generateNull()
          Returns the null value.
 void generatePostConstructor(JavaWriter out)
          Generates the post constructor initialization.
 void generatePostDelete(JavaWriter out)
          Generates the delete foreign
 int generatePostLoadSelect(JavaWriter out, int index)
          Generates loading code after the basic fields.
 void generatePreDelete(JavaWriter out)
          Generates the pre-delete code
 void generatePrePersist(JavaWriter out)
          Generates any code needed before a persist occurs
 void generatePrologue(JavaWriter out, java.util.HashSet<java.lang.Object> completedSet)
          Generates any prologue.
 java.lang.String generateSelect(java.lang.String id)
          Generates the select clause.
 void generateSet(JavaWriter out, java.lang.String obj, java.lang.String value)
          Generates set code, which goes through the active calls, i.e.
 java.lang.String generateSet(java.lang.String objThis, java.lang.String value)
          Generates the field setter.
 void generateSetterMethod(JavaWriter out)
          Generates the setter method implementation.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index)
          Generates the set clause.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String obj)
          Generates the set clause.
 java.lang.String generateSuperGetter(java.lang.String objThis)
          Returns the actual data.
 void generateSuperGetterMethod(JavaWriter out)
          Generates the super getter method implementation
 java.lang.String generateSuperSetter(java.lang.String objThis, java.lang.String value)
          Sets the actual data.
 void generateSuperSetterMethod(JavaWriter out)
          Generates the super setter method implementation
 void generateUpdate(CharBuffer sql)
          Generates the where clause.
 void generateUpdate(JavaWriter out, java.lang.String maskVar, java.lang.String pstmt, java.lang.String index)
          Generates loading cache
 void generateUpdateFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 void generateUpdateSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String obj)
          Generates the set clause for the insert clause.
 java.lang.String generateWhere(java.lang.String id)
          Generates the where clause.
 java.lang.Class getBeanClass()
          Returns the bean class.
 AmberColumn getColumn()
          Returns the column for the field
 long getCreateLoadMask(int group)
          Returns the load group mask.
 EntityType getEntitySourceType()
          Returns the source type as entity or mapped-superclass.
protected  java.lang.String getFieldName()
          Returns the field name.
 java.lang.reflect.Method getGetterMethod()
          Returns the getter method.
 java.lang.String getGetterName()
          Returns the getter name.
 int getIndex()
          Returns the property index.
 java.lang.Class getJavaClass()
          Returns the field's class
 JType getJavaType()
          Returns the field's type
 java.lang.String getJavaTypeName()
          Returns the getter name.
 int getLoadGroupIndex()
          Returns the property's group index.
 java.lang.String getName()
          Returns the field name.
 AmberPersistenceUnit getPersistenceUnit()
          Returns the amber manager.
 java.lang.reflect.Method getSetterMethod()
          Returns the setter method.
 java.lang.String getSetterName()
          Returns the setter name.
 AmberBeanType getSourceType()
          Returns the owning entity class.
 AmberTable getTable()
          Returns the table containing the field's columns.
 boolean hasLoadGroup(int index)
          Generates loading code
 void init()
          Initialize the field.
 boolean isAbstract()
          Returns true if the methods are abstract.
 boolean isCascadable()
          Returns true if the field is cascadable.
 boolean isFieldAccess()
          Returns true if values are accessed by the fields.
 boolean isKey()
          Returns true for a key
 boolean isLazy()
          Returns true for a lazy field.
 boolean isOverride()
          Returns true for an override
 boolean isUpdateable()
          Returns true if the methods are abstract.
 void link()
          Links to the target.
 AmberField override(AmberBeanType table)
          Creates a copy of the field for a parent
 void setColumn(AmberColumn column)
          Returns the column for the field
 void setIndex(int index)
          Set the property index.
protected  void setJavaType(JType type)
          Sets the java type.
 void setLazy(boolean isLazy)
          Set true for a lazy field.
protected  void setLoadGroupIndex(int index)
          Returns the property's group index.
 void setName(java.lang.String name)
          Sets the name.
 void setOverride(boolean isOverride)
          Returns true for an override
 java.lang.String toObject(java.lang.String value)
          Converts to an object.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setName

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

Throws:
ConfigException

getName

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

Specified by:
getName in interface AmberField

setJavaType

protected void setJavaType(JType type)
Sets the java type.


getSourceType

public AmberBeanType getSourceType()
Returns the owning entity class.

Specified by:
getSourceType in interface AmberField

getPersistenceUnit

public AmberPersistenceUnit getPersistenceUnit()
Returns the amber manager.


getBeanClass

public java.lang.Class getBeanClass()
Returns the bean class.


getEntitySourceType

public EntityType getEntitySourceType()
Returns the source type as entity or mapped-superclass.


getTable

public AmberTable getTable()
Returns the table containing the field's columns.

Specified by:
getTable in interface AmberField

getColumn

public AmberColumn getColumn()
Returns the column for the field

Specified by:
getColumn in interface AmberField

setColumn

public void setColumn(AmberColumn column)
Returns the column for the field


getIndex

public int getIndex()
Returns the property index.

Specified by:
getIndex in interface AmberField

setIndex

public void setIndex(int index)
Set the property index.

Specified by:
setIndex in interface AmberField

getLoadGroupIndex

public int getLoadGroupIndex()
Returns the property's group index.

Specified by:
getLoadGroupIndex in interface AmberField

setLoadGroupIndex

protected void setLoadGroupIndex(int index)
Returns the property's group index.


getCreateLoadMask

public long getCreateLoadMask(int group)
Returns the load group mask.

Specified by:
getCreateLoadMask in interface AmberField

isLazy

public boolean isLazy()
Returns true for a lazy field.

Specified by:
isLazy in interface AmberField

setLazy

public void setLazy(boolean isLazy)
Set true for a lazy field.


isOverride

public boolean isOverride()
Returns true for an override


setOverride

public void setOverride(boolean isOverride)
Returns true for an override


isKey

public boolean isKey()
Returns true for a key


getJavaTypeName

public java.lang.String getJavaTypeName()
Returns the getter name.

Specified by:
getJavaTypeName in interface AmberField

getJavaType

public JType getJavaType()
Returns the field's type

Specified by:
getJavaType in interface AmberField

getJavaClass

public java.lang.Class getJavaClass()
Returns the field's class

Specified by:
getJavaClass in interface AmberField

isFieldAccess

public boolean isFieldAccess()
Returns true if values are accessed by the fields.


isAbstract

public boolean isAbstract()
Returns true if the methods are abstract.

Specified by:
isAbstract in interface AmberField

isCascadable

public boolean isCascadable()
Returns true if the field is cascadable.

Specified by:
isCascadable in interface AmberField

isUpdateable

public boolean isUpdateable()
Returns true if the methods are abstract.

Specified by:
isUpdateable in interface AmberField

override

public AmberField override(AmberBeanType table)
Creates a copy of the field for a parent

Specified by:
override in interface AmberField

init

public void init()
          throws ConfigException
Initialize the field.

Specified by:
init in interface AmberField
Throws:
ConfigException

generatePostConstructor

public void generatePostConstructor(JavaWriter out)
                             throws java.io.IOException
Generates the post constructor initialization.

Specified by:
generatePostConstructor in interface AmberField
Throws:
java.io.IOException

generatePrologue

public void generatePrologue(JavaWriter out,
                             java.util.HashSet<java.lang.Object> completedSet)
                      throws java.io.IOException
Generates any prologue.

Specified by:
generatePrologue in interface AmberField
Throws:
java.io.IOException

getGetterMethod

public java.lang.reflect.Method getGetterMethod()
Returns the getter method.

Specified by:
getGetterMethod in interface AmberField

getSetterMethod

public java.lang.reflect.Method getSetterMethod()
Returns the setter method.

Specified by:
getSetterMethod in interface AmberField

getGetterName

public java.lang.String getGetterName()
Returns the getter name.

Specified by:
getGetterName in interface AmberField

getSetterName

public java.lang.String getSetterName()
Returns the setter name.

Specified by:
getSetterName in interface AmberField

generateSuperGetter

public java.lang.String generateSuperGetter(java.lang.String objThis)
Returns the actual data.

Specified by:
generateSuperGetter in interface AmberField

generateSuperSetter

public java.lang.String generateSuperSetter(java.lang.String objThis,
                                            java.lang.String value)
Sets the actual data.

Specified by:
generateSuperSetter in interface AmberField

generateGet

public java.lang.String generateGet(java.lang.String objThis)
Generates the field getter.

Specified by:
generateGet in interface AmberField
Parameters:
value - the non-null value

generateSet

public java.lang.String generateSet(java.lang.String objThis,
                                    java.lang.String value)
Generates the field setter.

Specified by:
generateSet in interface AmberField
Parameters:
value - the non-null value

generateGet

public void generateGet(JavaWriter out,
                        java.lang.String objThis)
                 throws java.io.IOException
Generates the field getter.

Specified by:
generateGet in interface AmberField
Parameters:
value - the non-null value
Throws:
java.io.IOException

generateSet

public void generateSet(JavaWriter out,
                        java.lang.String obj,
                        java.lang.String value)
                 throws java.io.IOException
Generates set code, which goes through the active calls, i.e. not a direct call to the underlying field.

Specified by:
generateSet in interface AmberField
Throws:
java.io.IOException

generateSuperGetterMethod

public void generateSuperGetterMethod(JavaWriter out)
                               throws java.io.IOException
Generates the super getter method implementation

Specified by:
generateSuperGetterMethod in interface AmberField
Throws:
java.io.IOException

generateSuperSetterMethod

public void generateSuperSetterMethod(JavaWriter out)
                               throws java.io.IOException
Generates the super setter method implementation

Specified by:
generateSuperSetterMethod in interface AmberField
Throws:
java.io.IOException

generateGetterMethod

public void generateGetterMethod(JavaWriter out)
                          throws java.io.IOException
Generates the getter method implementation.

Specified by:
generateGetterMethod in interface AmberField
Throws:
java.io.IOException

generateSetterMethod

public void generateSetterMethod(JavaWriter out)
                          throws java.io.IOException
Generates the setter method implementation.

Specified by:
generateSetterMethod in interface AmberField
Throws:
java.io.IOException

generateDetach

public void generateDetach(JavaWriter out)
                    throws java.io.IOException
Generates the detachment code

Specified by:
generateDetach in interface AmberField
Throws:
java.io.IOException

generateLoadSelect

public java.lang.String generateLoadSelect(AmberTable table,
                                           java.lang.String id)
Generates the select clause for an entity load.

Specified by:
generateLoadSelect in interface AmberField

generateSelect

public java.lang.String generateSelect(java.lang.String id)
Generates the select clause.

Specified by:
generateSelect in interface AmberField

generateJavaSelect

public java.lang.String generateJavaSelect(java.lang.String id)
Generates the JPA QL select clause.

Specified by:
generateJavaSelect in interface AmberField

generateWhere

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

Specified by:
generateWhere in interface AmberField

generateUpdate

public void generateUpdate(CharBuffer sql)
Generates the where clause.

Specified by:
generateUpdate in interface AmberField

generateUpdate

public void generateUpdate(JavaWriter out,
                           java.lang.String maskVar,
                           java.lang.String pstmt,
                           java.lang.String index)
                    throws java.io.IOException
Generates loading cache

Specified by:
generateUpdate in interface AmberField
Throws:
java.io.IOException

hasLoadGroup

public boolean hasLoadGroup(int index)
Generates loading code

Specified by:
hasLoadGroup in interface AmberField

generateLoad

public int generateLoad(JavaWriter out,
                        java.lang.String rs,
                        java.lang.String indexVar,
                        int index)
                 throws java.io.IOException
Generates loading code

Specified by:
generateLoad in interface AmberField
Throws:
java.io.IOException

generatePostLoadSelect

public int generatePostLoadSelect(JavaWriter out,
                                  int index)
                           throws java.io.IOException
Generates loading code after the basic fields.

Specified by:
generatePostLoadSelect in interface AmberField
Throws:
java.io.IOException

generateLoadFromObject

public void generateLoadFromObject(JavaWriter out,
                                   java.lang.String obj)
                            throws java.io.IOException
Generates loading cache

Specified by:
generateLoadFromObject in interface AmberField
Throws:
java.io.IOException

generateLoadNative

public int generateLoadNative(JavaWriter out,
                              int index)
                       throws java.io.IOException
Generates loading for a native query

Specified by:
generateLoadNative in interface AmberField
Throws:
java.io.IOException

generateNativeColumnNames

public void generateNativeColumnNames(java.util.ArrayList<java.lang.String> names)
Generates loading for a native query

Specified by:
generateNativeColumnNames in interface AmberField

generateUpdateFromObject

public void generateUpdateFromObject(JavaWriter out,
                                     java.lang.String obj)
                              throws java.io.IOException
Generates loading cache

Specified by:
generateUpdateFromObject in interface AmberField
Throws:
java.io.IOException

generateNull

public java.lang.String generateNull()
Returns the null value.


getFieldName

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


generateInsert

public final java.lang.String generateInsert()
Generates the insert.


generateInsertColumns

public void generateInsertColumns(java.util.ArrayList<java.lang.String> columns)
Generates the insert.

Specified by:
generateInsertColumns in interface AmberField

generateCreateTableSQL

public java.lang.String generateCreateTableSQL(AmberPersistenceUnit manager)
Generates the table create.

Specified by:
generateCreateTableSQL in interface AmberField

generateStatementSet

public void generateStatementSet(JavaWriter out,
                                 java.lang.String pstmt,
                                 java.lang.String index)
                          throws java.io.IOException
Generates the set clause.

Specified by:
generateStatementSet in interface AmberField
Throws:
java.io.IOException

generateInsertSet

public void generateInsertSet(JavaWriter out,
                              java.lang.String pstmt,
                              java.lang.String index,
                              java.lang.String obj)
                       throws java.io.IOException
Generates the set clause for the insert clause.

Specified by:
generateInsertSet in interface AmberField
Throws:
java.io.IOException

generateUpdateSet

public void generateUpdateSet(JavaWriter out,
                              java.lang.String pstmt,
                              java.lang.String index,
                              java.lang.String obj)
                       throws java.io.IOException
Generates the set clause for the insert clause.

Specified by:
generateUpdateSet in interface AmberField
Throws:
java.io.IOException

generatePrePersist

public void generatePrePersist(JavaWriter out)
                        throws java.io.IOException
Generates any code needed before a persist occurs

Specified by:
generatePrePersist in interface AmberField
Throws:
java.io.IOException

generateCopyUpdateObject

public void generateCopyUpdateObject(JavaWriter out,
                                     java.lang.String dst,
                                     java.lang.String src,
                                     int updateIndex)
                              throws java.io.IOException
Updates the cached copy.

Specified by:
generateCopyUpdateObject in interface AmberField
Throws:
java.io.IOException

generateCopyLoadObject

public void generateCopyLoadObject(JavaWriter out,
                                   java.lang.String dst,
                                   java.lang.String src,
                                   int loadIndex)
                            throws java.io.IOException
Updates the cached copy.

Specified by:
generateCopyLoadObject in interface AmberField
Throws:
java.io.IOException

generateMergeFrom

public void generateMergeFrom(JavaWriter out,
                              java.lang.String dst,
                              java.lang.String src)
                       throws java.io.IOException
Updates the cached copy.

Specified by:
generateMergeFrom in interface AmberField
Throws:
java.io.IOException

generateDumpRelationships

public void generateDumpRelationships(JavaWriter out,
                                      int updateIndex)
                               throws java.io.IOException
Checks entity-relationships from an object.

Specified by:
generateDumpRelationships in interface AmberField
Throws:
java.io.IOException

generateStatementSet

public void generateStatementSet(JavaWriter out,
                                 java.lang.String pstmt,
                                 java.lang.String index,
                                 java.lang.String obj)
                          throws java.io.IOException
Generates the set clause.

Specified by:
generateStatementSet in interface AmberField
Throws:
java.io.IOException

toObject

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

Specified by:
toObject in interface AmberField

link

public void link()
Links to the target.

Specified by:
link in interface AmberField

generatePreDelete

public void generatePreDelete(JavaWriter out)
                       throws java.io.IOException
Generates the pre-delete code

Specified by:
generatePreDelete in interface AmberField
Throws:
java.io.IOException

generatePostDelete

public void generatePostDelete(JavaWriter out)
                        throws java.io.IOException
Generates the delete foreign

Specified by:
generatePostDelete in interface AmberField
Throws:
java.io.IOException

generateExpire

public void generateExpire(JavaWriter out)
                    throws java.io.IOException
Generates the expire code

Specified by:
generateExpire in interface AmberField
Throws:
java.io.IOException

generateInvalidateForeign

public void generateInvalidateForeign(JavaWriter out)
                               throws java.io.IOException
Generates code for foreign entity create/delete

Specified by:
generateInvalidateForeign in interface AmberField
Throws:
java.io.IOException

childDelete

public void childDelete(AmberConnection aConn,
                        java.io.Serializable primaryKey)
                 throws java.sql.SQLException
Deletes the children

Specified by:
childDelete in interface AmberField
Throws:
java.sql.SQLException

generateCastFromObject

public java.lang.String generateCastFromObject(java.lang.String value)
Generates code to convert to the type from the object.

Specified by:
generateCastFromObject in interface AmberField

generateEquals

public java.lang.String generateEquals(java.lang.String leftBase,
                                       java.lang.String value)
Generates code to test the equals.

Specified by:
generateEquals in interface AmberField

createExpr

public AmberExpr createExpr(QueryParser parser,
                            PathExpr parent)
Creates the expression for the field.

Specified by:
createExpr in interface AmberField

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object