com.caucho.amber.field
Class KeyPropertyField

java.lang.Object
  extended by com.caucho.amber.field.AbstractField
      extended by com.caucho.amber.field.PropertyField
          extended by com.caucho.amber.field.KeyPropertyField
All Implemented Interfaces:
AmberField, IdField
Direct Known Subclasses:
IdentifyingKeyPropertyField

public class KeyPropertyField
extends PropertyField
implements IdField

Configuration for a bean's field


Constructor Summary
KeyPropertyField(EntityType tableType)
           
KeyPropertyField(EntityType tableType, java.lang.String name)
           
KeyPropertyField(EntityType entityType, java.lang.String name, AmberColumn column)
           
 
Method Summary
 AmberExpr createExpr(QueryParser parser, PathExpr parent)
          Creates the expression for the field.
 void generateCheckCreateKey(JavaWriter out)
          Generates the set clause.
 void generateCopy(JavaWriter out, java.lang.String dest, java.lang.String source)
          Generates code to copy to an object.
 java.lang.String generateEquals(java.lang.String left, java.lang.String right)
          Generates code to test the equals.
 java.lang.String generateGet(java.lang.String objThis)
          Generates the field getter.
 java.lang.String generateGetKeyProperty(java.lang.String key)
          Generates the getter for a key property
 java.lang.String generateGetProxyProperty(java.lang.String value)
          Generates the property getter for an EJB proxy
 java.lang.String generateIsNull(java.lang.String value)
          Returns a test for null.
 java.lang.String generateJavaSelect(java.lang.String id)
          Returns the JPA QL select code
 int generateLoadForeign(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index)
          Returns the foreign type.
 int generateLoadForeign(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index, java.lang.String name)
          Returns the foreign type.
 void generateLoadFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 void generateMatch(JavaWriter out, java.lang.String key)
          Generates code for a match.
 java.lang.String generateMatchArgWhere(java.lang.String id)
          Returns the where code
 void generateMergeFrom(JavaWriter out, java.lang.String dst, java.lang.String src)
          Keys are not merged
 void generatePrologue(JavaWriter out, java.util.HashSet<java.lang.Object> completedSet)
          Generates any prologue.
 java.lang.String generateRawWhere(java.lang.String id)
          Returns the where code
 java.lang.String generateSelect(java.lang.String id)
          Returns the select code
 java.lang.String generateSet(java.lang.String objThis, java.lang.String value)
          Generates the field setter.
 void generateSetGeneratedKeys(JavaWriter out, java.lang.String pstmt)
          Generates the set clause.
 void generateSetInsert(JavaWriter out, java.lang.String pstmt, java.lang.String index)
          Generates the set clause.
 java.lang.String generateSetKeyProperty(java.lang.String key, java.lang.String value)
          Generates the setter for a key property
 java.lang.String generateSetNull(java.lang.String obj)
          Generates loading cache
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value)
          Generates the set clause.
 AmberColumn getColumn()
          Returns column
 java.util.ArrayList<AmberColumn> getColumns()
          Returns columns
 int getComponentCount()
          Returns the component count.
 java.lang.String getForeignTypeName()
          Returns the foreign type.
 java.lang.String getGenerator()
          Gets the generator.
 AmberType getType()
          Returns type
 boolean isAutoGenerate()
          Returns true for a generator.
 boolean isKey()
          Returns true for a key
 boolean isKeyField()
          Returns true if key fields are accessed through fields.
 AmberField override(AmberBeanType type)
          Creates a copy of the field for a parent
 void setColumn(AmberColumn column)
          Sets the column
 void setGenerator(java.lang.String generator)
          Sets the generator.
 void setKeyField(boolean isKeyField)
          Set true if key fields are accessed through fields.
 java.lang.String toObject(java.lang.String value)
          Converts to an object.
 java.lang.String toValue(java.lang.String value)
          Converts from an object.
 
Methods inherited from class com.caucho.amber.field.PropertyField
generateGetterMethod, generateInsertColumns, generateInsertSet, generateLoad, generateLoadNative, generateLoadSelect, generateNativeColumnNames, generateNull, generateSetterMethod, generateUpdate, generateUpdateSet, generateWhere, getFieldName, getRelatedSourceType, getTable, init, isInsert, isUpdate, setInsert, setType, setUpdate
 
Methods inherited from class com.caucho.amber.field.AbstractField
childDelete, generateCastFromObject, generateCopyLoadObject, generateCopyUpdateObject, generateCreateTableSQL, generateDetach, generateDumpRelationships, generateExpire, generateGet, generateInsert, generateInvalidateForeign, generatePostConstructor, generatePostDelete, generatePostLoadSelect, generatePreDelete, generatePrePersist, generateSet, generateStatementSet, generateSuperGetter, generateSuperGetterMethod, generateSuperSetter, generateSuperSetterMethod, generateUpdate, generateUpdateFromObject, getBeanClass, getCreateLoadMask, getEntitySourceType, getGetterMethod, getGetterName, getIndex, getJavaClass, getJavaType, getJavaTypeName, getLoadGroupIndex, getName, getPersistenceUnit, getSetterMethod, getSetterName, getSourceType, hasLoadGroup, isAbstract, isCascadable, isFieldAccess, isLazy, isOverride, isUpdateable, link, setIndex, setJavaType, setLazy, setLoadGroupIndex, setName, setOverride, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.caucho.amber.field.IdField
getJavaTypeName
 
Methods inherited from interface com.caucho.amber.field.AmberField
childDelete, generateCastFromObject, generateCopyLoadObject, generateCopyUpdateObject, generateCreateTableSQL, generateDetach, generateDumpRelationships, generateExpire, generateGet, generateGetterMethod, generateInsertColumns, generateInsertSet, generateInvalidateForeign, generateLoad, generateLoadNative, generateLoadSelect, generateNativeColumnNames, generatePostConstructor, generatePostDelete, generatePostLoadSelect, generatePreDelete, generatePrePersist, generateSet, generateSetterMethod, generateStatementSet, generateSuperGetter, generateSuperGetterMethod, generateSuperSetter, generateSuperSetterMethod, generateUpdate, generateUpdate, generateUpdateFromObject, generateUpdateSet, generateWhere, getCreateLoadMask, getGetterMethod, getGetterName, getIndex, getJavaClass, getJavaType, getLoadGroupIndex, getName, getSetterMethod, getSetterName, getSourceType, getTable, hasLoadGroup, init, isAbstract, isCascadable, isLazy, isUpdateable, link, setIndex
 

Constructor Detail

KeyPropertyField

public KeyPropertyField(EntityType tableType)

KeyPropertyField

public KeyPropertyField(EntityType tableType,
                        java.lang.String name)
                 throws ConfigException
Throws:
ConfigException

KeyPropertyField

public KeyPropertyField(EntityType entityType,
                        java.lang.String name,
                        AmberColumn column)
                 throws ConfigException
Throws:
ConfigException
Method Detail

isKey

public boolean isKey()
Returns true for a key

Overrides:
isKey in class AbstractField

isKeyField

public boolean isKeyField()
Returns true if key fields are accessed through fields.


setKeyField

public void setKeyField(boolean isKeyField)
Set true if key fields are accessed through fields.

Specified by:
setKeyField in interface IdField

setGenerator

public void setGenerator(java.lang.String generator)
Sets the generator.


getGenerator

public java.lang.String getGenerator()
Gets the generator.

Specified by:
getGenerator in interface IdField

isAutoGenerate

public boolean isAutoGenerate()
Returns true for a generator.

Specified by:
isAutoGenerate in interface IdField

setColumn

public void setColumn(AmberColumn column)
Sets the column

Overrides:
setColumn in class PropertyField

getColumn

public AmberColumn getColumn()
Returns column

Specified by:
getColumn in interface AmberField
Overrides:
getColumn in class PropertyField

getColumns

public java.util.ArrayList<AmberColumn> getColumns()
Returns columns

Specified by:
getColumns in interface IdField

getComponentCount

public int getComponentCount()
Returns the component count.

Specified by:
getComponentCount in interface IdField

getType

public AmberType getType()
Returns type

Specified by:
getType in interface IdField
Overrides:
getType in class PropertyField

getForeignTypeName

public java.lang.String getForeignTypeName()
Returns the foreign type.

Specified by:
getForeignTypeName in interface IdField

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
Overrides:
generatePrologue in class AbstractField
Throws:
java.io.IOException

generateGet

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

Specified by:
generateGet in interface AmberField
Overrides:
generateGet in class AbstractField
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
Overrides:
generateSet in class AbstractField
Parameters:
value - the non-null value

generateMergeFrom

public void generateMergeFrom(JavaWriter out,
                              java.lang.String dst,
                              java.lang.String src)
                       throws java.io.IOException
Keys are not merged

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

generateCopy

public void generateCopy(JavaWriter out,
                         java.lang.String dest,
                         java.lang.String source)
                  throws java.io.IOException
Generates code to copy to an object.

Specified by:
generateCopy in interface IdField
Throws:
java.io.IOException

override

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

Specified by:
override in interface AmberField
Overrides:
override in class PropertyField

generateSelect

public java.lang.String generateSelect(java.lang.String id)
Returns the select code

Specified by:
generateSelect in interface AmberField
Overrides:
generateSelect in class PropertyField

generateJavaSelect

public java.lang.String generateJavaSelect(java.lang.String id)
Returns the JPA QL select code

Specified by:
generateJavaSelect in interface AmberField
Overrides:
generateJavaSelect in class AbstractField

generateMatchArgWhere

public java.lang.String generateMatchArgWhere(java.lang.String id)
Returns the where code

Specified by:
generateMatchArgWhere in interface IdField

generateRawWhere

public java.lang.String generateRawWhere(java.lang.String id)
Returns the where code

Specified by:
generateRawWhere in interface IdField

generateLoadForeign

public int generateLoadForeign(JavaWriter out,
                               java.lang.String rs,
                               java.lang.String indexVar,
                               int index)
                        throws java.io.IOException
Returns the foreign type.

Specified by:
generateLoadForeign in interface IdField
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
Overrides:
generateLoadFromObject in class AbstractField
Throws:
java.io.IOException

generateSetNull

public java.lang.String generateSetNull(java.lang.String obj)
                                 throws java.io.IOException
Generates loading cache

Throws:
java.io.IOException

generateIsNull

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

Specified by:
generateIsNull in interface IdField

generateLoadForeign

public int generateLoadForeign(JavaWriter out,
                               java.lang.String rs,
                               java.lang.String indexVar,
                               int index,
                               java.lang.String name)
                        throws java.io.IOException
Returns the foreign type.

Specified by:
generateLoadForeign in interface IdField
Throws:
java.io.IOException

generateStatementSet

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

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

generateMatch

public void generateMatch(JavaWriter out,
                          java.lang.String key)
                   throws java.io.IOException
Generates code for a match.

Throws:
java.io.IOException

generateEquals

public java.lang.String generateEquals(java.lang.String left,
                                       java.lang.String right)
Generates code to test the equals.

Specified by:
generateEquals in interface AmberField
Overrides:
generateEquals in class AbstractField

generateSetInsert

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

Specified by:
generateSetInsert in interface IdField
Throws:
java.io.IOException

generateCheckCreateKey

public void generateCheckCreateKey(JavaWriter out)
                            throws java.io.IOException
Generates the set clause.

Specified by:
generateCheckCreateKey in interface IdField
Throws:
java.io.IOException

generateSetGeneratedKeys

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

Specified by:
generateSetGeneratedKeys in interface IdField
Throws:
java.io.IOException

generateSetKeyProperty

public java.lang.String generateSetKeyProperty(java.lang.String key,
                                               java.lang.String value)
                                        throws java.io.IOException
Generates the setter for a key property

Specified by:
generateSetKeyProperty in interface IdField
Throws:
java.io.IOException

generateGetKeyProperty

public java.lang.String generateGetKeyProperty(java.lang.String key)
Generates the getter for a key property

Specified by:
generateGetKeyProperty in interface IdField

generateGetProxyProperty

public java.lang.String generateGetProxyProperty(java.lang.String value)
Generates the property getter for an EJB proxy

Specified by:
generateGetProxyProperty in interface IdField
Parameters:
value - the non-null value

createExpr

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

Specified by:
createExpr in interface AmberField
Overrides:
createExpr in class PropertyField

toObject

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

Specified by:
toObject in interface AmberField
Overrides:
toObject in class AbstractField

toValue

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

Specified by:
toValue in interface IdField