org.apache.jdo.impl.model.jdo
Class JDOAssociatedPropertyImplDynamic

java.lang.Object
  extended by org.apache.jdo.impl.model.jdo.JDOElementImpl
      extended by org.apache.jdo.impl.model.jdo.JDOMemberImpl
          extended by org.apache.jdo.impl.model.jdo.JDOAssociatedPropertyImplDynamic
All Implemented Interfaces:
java.lang.Comparable, JDOElement, JDOField, JDOMember, JDOProperty
Direct Known Subclasses:
JDOAssociatedPropertyImplCaching

public class JDOAssociatedPropertyImplDynamic
extends JDOMemberImpl
implements JDOProperty

An instance of this class represents the JDO metadata of a managed property of a persistence capable class. This JDOProperty implementation is used for persistent properties with an associated JDOField. All JDOField getter methods delegate to the associated JDOField, except methods getName, getDeclaringClass and getJavaField. All JDOField setter method throw a ModelException to avoid changing the associated JDOField through this JDOProperty instance. This dynamic implementation only stores values explicitly set by setter method.

Since:
2.0
Version:
2.0
Author:
Michael Bouschen

Field Summary
protected  JavaProperty javaProperty
          The corresponding JavaProperty instance.
protected static I18NHelper msg
          I18N support.
 
Constructor Summary
protected JDOAssociatedPropertyImplDynamic(java.lang.String name, JDOClass declaringClass, JDOField associatedJDOField)
          Constrcutor.
 
Method Summary
 JDOArray createJDOArray()
          Throws ModelException.
 JDOCollection createJDOCollection()
          Throws ModelException.
 JDOMap createJDOMap()
          Throws ModelException.
 JDOReference createJDOReference()
          Throws ModelException.
 JDOField getAssociatedJDOField()
          Return the JDOField instance associated with this property, if available.
 int getFieldNumber()
          Deletegate to associatedJDOField.
 JavaField getJavaField()
          Get the corresponding JavaProperty representation for this JDOProperty.
 java.lang.String getMappedByName()
          Deletegate to associatedJDOField.
 int getNullValueTreatment()
          Deletegate to associatedJDOField.
 int getPersistenceModifier()
          Deletegate to associatedJDOField.
 JDORelationship getRelationship()
          Deletegate to associatedJDOField.
 int getRelativeFieldNumber()
          Deletegate to associatedJDOField.
 JavaType getType()
          Deletegate to associatedJDOField.
 boolean isDefaultFetchGroup()
          Deletegate to associatedJDOField.
 boolean isEmbedded()
          Deletegate to associatedJDOField.
 boolean isManaged()
          Deletegate to associatedJDOField.
 boolean isPersistent()
          Deletegate to associatedJDOField.
 boolean isPrimaryKey()
          Deletegate to associatedJDOField.
 boolean isProperty()
          Convenience method to check whether this field represents a property.
 boolean isRelationship()
          Deletegate to associatedJDOField.
 boolean isSerializable()
          Deletegate to associatedJDOField.
 boolean isTransactional()
          Deletegate to associatedJDOField.
 void setDefaultFetchGroup(boolean defaultFetchGroup)
          Throws ModelException.
 void setEmbedded(boolean embedded)
          Throws ModelException.
 void setJavaField(JavaField javaField)
          Sets the corresponding JavaProperty representation for this JDOProperty.
 void setMappedByName(java.lang.String mappedByName)
          Throws ModelException.
 void setNullValueTreatment(int nullValueTreament)
          Throws ModelException.
 void setPersistenceModifier(int persistenceModifier)
          Throws ModelException.
 void setPrimaryKey(boolean primaryKey)
          Throws ModelException.
 void setRelationship(JDORelationship relationship)
          Throws ModelException.
 void setSerializable(boolean serializable)
          Throws ModelException.
 
Methods inherited from class org.apache.jdo.impl.model.jdo.JDOMemberImpl
compareTo, equals, getDeclaringClass, getName, hashCode, toString
 
Methods inherited from class org.apache.jdo.impl.model.jdo.JDOElementImpl
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, firePropertyChange, fireVetoableChange, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jdo.model.jdo.JDOMember
getDeclaringClass, getName
 
Methods inherited from interface org.apache.jdo.model.jdo.JDOElement
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

javaProperty

protected JavaProperty javaProperty
The corresponding JavaProperty instance.


msg

protected static final I18NHelper msg
I18N support.

Constructor Detail

JDOAssociatedPropertyImplDynamic

protected JDOAssociatedPropertyImplDynamic(java.lang.String name,
                                           JDOClass declaringClass,
                                           JDOField associatedJDOField)
                                    throws ModelException
Constrcutor.

Throws:
ModelException
Method Detail

getJavaField

public JavaField getJavaField()
Get the corresponding JavaProperty representation for this JDOProperty.

Specified by:
getJavaField in interface JDOField
Returns:
the corresponding JavaProperty representation

setJavaField

public void setJavaField(JavaField javaField)
                  throws ModelException
Sets the corresponding JavaProperty representation for this JDOProperty.

Specified by:
setJavaField in interface JDOField
Parameters:
javaField - the corresponding JavaProperty representation
Throws:
ModelException - if impossible

isProperty

public boolean isProperty()
Convenience method to check whether this field represents a property.

Specified by:
isProperty in interface JDOField
Returns:
true if this field represents a property; false otherwise

getPersistenceModifier

public int getPersistenceModifier()
Deletegate to associatedJDOField.

Specified by:
getPersistenceModifier in interface JDOField
Returns:
the persistence modifier, one of PersistenceModifier.UNSPECIFIED, PersistenceModifier.NONE, PersistenceModifier.PERSISTENT, PersistenceModifier.TRANSACTIONAL, PersistenceModifier.POSSIBLY_PERSISTENT.

setPersistenceModifier

public void setPersistenceModifier(int persistenceModifier)
                            throws ModelException
Throws ModelException.

Specified by:
setPersistenceModifier in interface JDOField
Parameters:
persistenceModifier - an integer indicating the persistence modifier, one of: PersistenceModifier.UNSPECIFIED, PersistenceModifier.NONE, PersistenceModifier.PERSISTENT, PersistenceModifier.TRANSACTIONAL, PersistenceModifier.POSSIBLY_PERSISTENT.
Throws:
ModelException - if impossible

isPrimaryKey

public boolean isPrimaryKey()
Deletegate to associatedJDOField.

Specified by:
isPrimaryKey in interface JDOField
Returns:
true if the field is a key field, false otherwise

setPrimaryKey

public void setPrimaryKey(boolean primaryKey)
                   throws ModelException
Throws ModelException.

Specified by:
setPrimaryKey in interface JDOField
Parameters:
primaryKey - if true, the JDOField is marked as a key field; otherwise, it is not
Throws:
ModelException - if impossible

getNullValueTreatment

public int getNullValueTreatment()
Deletegate to associatedJDOField.

Specified by:
getNullValueTreatment in interface JDOField
Returns:
the null value treatment of this JDOField, one of NullValueTreatment.NONE, NullValueTreatment.EXCEPTION or NullValueTreatment.DEFAULT

setNullValueTreatment

public void setNullValueTreatment(int nullValueTreament)
                           throws ModelException
Throws ModelException.

Specified by:
setNullValueTreatment in interface JDOField
Parameters:
nullValueTreament - an integer indicating the null value treatment, one of: NullValueTreatment.NONE, NullValueTreatment.EXCEPTION or NullValueTreatment.DEFAULT
Throws:
ModelException - if impossible

isDefaultFetchGroup

public boolean isDefaultFetchGroup()
Deletegate to associatedJDOField.

Specified by:
isDefaultFetchGroup in interface JDOField
Returns:
true if the field is part of the default fetch group, false otherwise

setDefaultFetchGroup

public void setDefaultFetchGroup(boolean defaultFetchGroup)
                          throws ModelException
Throws ModelException.

Specified by:
setDefaultFetchGroup in interface JDOField
Parameters:
defaultFetchGroup - if true, the JDOField is marked as beeing part of the default fetch group; otherwise, it is not
Throws:
ModelException - if impossible

isEmbedded

public boolean isEmbedded()
Deletegate to associatedJDOField.

Specified by:
isEmbedded in interface JDOField
Returns:
true if the field is stored as part of the instance; false otherwise

setEmbedded

public void setEmbedded(boolean embedded)
                 throws ModelException
Throws ModelException.

Specified by:
setEmbedded in interface JDOField
Parameters:
embedded - true if the field is stored as part of the instance; false otherwise
Throws:
ModelException - if impossible

isSerializable

public boolean isSerializable()
Deletegate to associatedJDOField.

Specified by:
isSerializable in interface JDOField
Returns:
true if the field is serializable, false otherwise

setSerializable

public void setSerializable(boolean serializable)
                     throws ModelException
Throws ModelException.

Specified by:
setSerializable in interface JDOField
Parameters:
serializable - if true, the JDOField is serializable; otherwise, it is not
Throws:
ModelException - if impossible

getMappedByName

public java.lang.String getMappedByName()
Deletegate to associatedJDOField.

Specified by:
getMappedByName in interface JDOField
Returns:
the mappedBy field name if available; null otherwise.

setMappedByName

public void setMappedByName(java.lang.String mappedByName)
                     throws ModelException
Throws ModelException.

Specified by:
setMappedByName in interface JDOField
Parameters:
mappedByName - the mappedBy field name.
Throws:
ModelException - if impossible

getRelationship

public JDORelationship getRelationship()
Deletegate to associatedJDOField.

Specified by:
getRelationship in interface JDOField
Returns:
relationship info of this JDOField or null if this JDOField is not a relationship

setRelationship

public void setRelationship(JDORelationship relationship)
                     throws ModelException
Throws ModelException.

Specified by:
setRelationship in interface JDOField
Parameters:
relationship - the JDORelationship instance
Throws:
ModelException - if impossible

createJDOReference

public JDOReference createJDOReference()
                                throws ModelException
Throws ModelException.

Specified by:
createJDOReference in interface JDOField
Returns:
a new JDOReference instance bound to this JDOField
Throws:
ModelException - if impossible

createJDOCollection

public JDOCollection createJDOCollection()
                                  throws ModelException
Throws ModelException.

Specified by:
createJDOCollection in interface JDOField
Returns:
a new JDOCollection instance bound to this JDOField
Throws:
ModelException - if impossible

createJDOArray

public JDOArray createJDOArray()
                        throws ModelException
Throws ModelException.

Specified by:
createJDOArray in interface JDOField
Returns:
a new JDOArray instance bound to this JDOField
Throws:
ModelException - if impossible

createJDOMap

public JDOMap createJDOMap()
                    throws ModelException
Throws ModelException.

Specified by:
createJDOMap in interface JDOField
Returns:
a new JDOMap instance bound to this JDOField
Throws:
ModelException - if impossible

isPersistent

public boolean isPersistent()
Deletegate to associatedJDOField.

Specified by:
isPersistent in interface JDOField
Returns:
true if this field has the PersistenceModifier.PERSISTENT modifier; false otherwise

isTransactional

public boolean isTransactional()
Deletegate to associatedJDOField.

Specified by:
isTransactional in interface JDOField
Returns:
true if this field has the PersistenceModifier.TRANSACTIONAL modifier; false otherwise

isManaged

public boolean isManaged()
Deletegate to associatedJDOField.

Specified by:
isManaged in interface JDOField
Returns:
true if this field is a managed field; false otherwise

isRelationship

public boolean isRelationship()
Deletegate to associatedJDOField.

Specified by:
isRelationship in interface JDOField
Returns:
true if this field is a relationship; false otherwise

getType

public JavaType getType()
Deletegate to associatedJDOField.

Specified by:
getType in interface JDOField
Returns:
JavaType representation of the type of this field.

getFieldNumber

public int getFieldNumber()
Deletegate to associatedJDOField.

Specified by:
getFieldNumber in interface JDOField
Returns:
the absolute field number

getRelativeFieldNumber

public int getRelativeFieldNumber()
Deletegate to associatedJDOField.

Specified by:
getRelativeFieldNumber in interface JDOField
Returns:
the relative field number

getAssociatedJDOField

public JDOField getAssociatedJDOField()
Return the JDOField instance associated with this property, if available. If there is no JDOField instance associated, then the method returns null.

Specified by:
getAssociatedJDOField in interface JDOProperty
Returns:
associated JDOField instance or null if not available.


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.