org.apache.jdo.model.jdo
Interface JDOField

All Superinterfaces:
java.lang.Comparable, JDOElement, JDOMember
All Known Subinterfaces:
JDOProperty
All Known Implementing Classes:
JDOAssociatedPropertyImplDynamic, JDOFieldImplDynamic, JDOPropertyImplCaching, JDOPropertyImplDynamic

public interface JDOField
extends JDOMember

A JDOField instance represents the JDO metadata of a managed field of a persistence-capable class.

Author:
Michael Bouschen

Method Summary
 JDOArray createJDOArray()
          Creates and returns a new JDOArray instance.
 JDOCollection createJDOCollection()
          Creates and returns a new JDOCollection instance.
 JDOMap createJDOMap()
          Creates and returns a new JDOMap instance.
 JDOReference createJDOReference()
          Creates and returns a new JDOReference instance.
 int getFieldNumber()
          Returns the absolute field number of this JDOField.
 JavaField getJavaField()
          Get the corresponding Java field representation for this JDOField.
 java.lang.String getMappedByName()
          Get the name of the field specified in a mappedBy attribute in the metadata.
 int getNullValueTreatment()
          Gets the null value treatment indicator of this JDOField.
 int getPersistenceModifier()
          Get the persistence modifier of this JDOField.
 JDORelationship getRelationship()
          Get the relationship information for this JDOField.
 int getRelativeFieldNumber()
          Returns the relative field number of this JDOField.
 JavaType getType()
          Get the JavaType representation of the type of the field.
 boolean isDefaultFetchGroup()
          Determines whether this JDOField is part of the default fetch group or not.
 boolean isEmbedded()
          Determines whether the field should be stored if possible as part of the instance instead of as its own instance in the datastore.
 boolean isManaged()
          Convenience method to check the persistence modifier from this JDOField.
 boolean isPersistent()
          Convenience method to check the persistence modifier from this JDOField.
 boolean isPrimaryKey()
          Determines whether this JDOField is a key field or not.
 boolean isProperty()
          Convenience method to check whether this field represents a property.
 boolean isRelationship()
          Convenience method to check whether this field is a relationship field.
 boolean isSerializable()
          Determines whether this JDOField is serializable or not.
 boolean isTransactional()
          Convenience method to check the persistence modifier from this JDOField.
 void setDefaultFetchGroup(boolean defaultFetchGroup)
          Set whether this JDOField is part of the default fetch group or not.
 void setEmbedded(boolean embedded)
          Set whether the field should be stored if possible as part of the instance instead of as its own instance in the datastore.
 void setJavaField(JavaField javaField)
          Sets the corresponding Java field representation for this JDOField.
 void setMappedByName(java.lang.String mappedByName)
          Set the name of the field specified in a mappedBy attribute in the metadata.
 void setNullValueTreatment(int nullValueTreament)
          Sets the null value treatment indicator for this JDOField.
 void setPersistenceModifier(int persistenceModifier)
          Set the persistence modifier for this JDOField.
 void setPrimaryKey(boolean primaryKey)
          Set whether this JDOField is a key field or not.
 void setRelationship(JDORelationship relationship)
          Set the relationship information for this JDOField.
 void setSerializable(boolean serializable)
          Set whether this JDOField is serializable or not.
 
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
 

Method Detail

getPersistenceModifier

public int getPersistenceModifier()
Get the persistence modifier of this 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
Set the persistence modifier for this 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()
Determines whether this JDOField is a key field or not.

Returns:
true if the field is a key field, false otherwise

setPrimaryKey

public void setPrimaryKey(boolean primaryKey)
                   throws ModelException
Set whether this JDOField is a key field or not.

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

getNullValueTreatment

public int getNullValueTreatment()
Gets the null value treatment indicator of this 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
Sets the null value treatment indicator for this 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()
Determines whether this JDOField is part of the default fetch group or not.

Returns:
true if the field is part of the default fetch group, false otherwise

setDefaultFetchGroup

public void setDefaultFetchGroup(boolean defaultFetchGroup)
                          throws ModelException
Set whether this JDOField is part of the default fetch group or not.

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()
Determines whether the field should be stored if possible as part of the instance instead of as its own instance in the datastore.

Returns:
true if the field is stored as part of the instance; false otherwise

setEmbedded

public void setEmbedded(boolean embedded)
                 throws ModelException
Set whether the field should be stored if possible as part of the instance instead of as its own instance in the datastore.

Parameters:
embedded - true if the field is stored as part of the instance; false otherwise
Throws:
ModelException - if impossible

isSerializable

public boolean isSerializable()
Determines whether this JDOField is serializable or not.

Returns:
true if the field is serializable, false otherwise

setSerializable

public void setSerializable(boolean serializable)
                     throws ModelException
Set whether this JDOField is serializable or not.

Parameters:
serializable - if true, the JDOField is serializable; otherwise, it is not
Throws:
ModelException - if impossible

getMappedByName

public java.lang.String getMappedByName()
Get the name of the field specified in a mappedBy attribute in the metadata. The method returns null if the metadata for this field does not specify the mappedBy attribute. Note that this can be provided at the field level to help population of the model, but should only be specified on a field that has a corresponding relationship.

Returns:
the mappedBy field name if available; null otherwise.

setMappedByName

public void setMappedByName(java.lang.String mappedByName)
                     throws ModelException
Set the name of the field specified in a mappedBy attribute in the metadata. Note that this can be provided at the field level to help population of the model, but should only be specified on a field that has a corresponding relationship.

Parameters:
mappedByName - the mappedBy field name.
Throws:
ModelException - if impossible

getJavaField

public JavaField getJavaField()
Get the corresponding Java field representation for this JDOField.

Returns:
the corresponding Java field representation

setJavaField

public void setJavaField(JavaField javaField)
                  throws ModelException
Sets the corresponding Java field representation for this JDOField.

Parameters:
javaField - the corresponding Java field representation
Throws:
ModelException - if impossible

getRelationship

public JDORelationship getRelationship()
Get the relationship information for this JDOField. The method returns null if the field is not part of a relationship (e.g. it is a primitive type field).

Returns:
relationship info of this JDOField or null if this JDOField is not a relationship

setRelationship

public void setRelationship(JDORelationship relationship)
                     throws ModelException
Set the relationship information for this JDOField.

Parameters:
relationship - the JDORelationship instance
Throws:
ModelException - if impossible

createJDOReference

public JDOReference createJDOReference()
                                throws ModelException
Creates and returns a new JDOReference instance. This method automatically binds the new JDOReference to this JDOField. It throws a ModelException, if this JDOField is already bound to another JDORelationship instance. Otherwise the following holds true:

Returns:
a new JDOReference instance bound to this JDOField
Throws:
ModelException - if impossible

createJDOCollection

public JDOCollection createJDOCollection()
                                  throws ModelException
Creates and returns a new JDOCollection instance. This method automatically binds the new JDOCollection to this JDOField. It throws a ModelException, if this JDOField is already bound to another JDORelationship instance. Otherwise the following holds true:

Returns:
a new JDOCollection instance bound to this JDOField
Throws:
ModelException - if impossible

createJDOArray

public JDOArray createJDOArray()
                        throws ModelException
Creates and returns a new JDOArray instance. This method automatically binds the new JDOArray to this JDOField. It throws a ModelException, if this JDOField is already bound to another JDORelationship instance. Otherwise the following holds true:

Returns:
a new JDOArray instance bound to this JDOField
Throws:
ModelException - if impossible

createJDOMap

public JDOMap createJDOMap()
                    throws ModelException
Creates and returns a new JDOMap instance. This method automatically binds the new JDOMap to this JDOField. It throws a ModelException, if this JDOField is already bound to another JDORelationship instance. Otherwise the following holds true:

Returns:
a new JDOMap instance bound to this JDOField
Throws:
ModelException - if impossible

isPersistent

public boolean isPersistent()
Convenience method to check the persistence modifier from this JDOField.

Returns:
true if this field has the PersistenceModifier.PERSISTENT modifier; false otherwise

isTransactional

public boolean isTransactional()
Convenience method to check the persistence modifier from this JDOField.

Returns:
true if this field has the PersistenceModifier.TRANSACTIONAL modifier; false otherwise

isManaged

public boolean isManaged()
Convenience method to check the persistence modifier from this JDOField. A field is a managed field, if it has the persistence-modifier PersistenceModifier.PERSISTENT or PersistenceModifier.TRANSACTIONAL.

Returns:
true if this field is a managed field; false otherwise

isRelationship

public boolean isRelationship()
Convenience method to check whether this field is a relationship field.

Returns:
true if this field is a relationship; false otherwise

isProperty

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

Returns:
true if this field represents a property; false otherwise

getType

public JavaType getType()
Get the JavaType representation of the type of the field.

Returns:
JavaType representation of the type of this field.

getFieldNumber

public int getFieldNumber()
Returns the absolute field number of this JDOField.

Returns:
the absolute field number

getRelativeFieldNumber

public int getRelativeFieldNumber()
Returns the relative field number of this JDOField.

Returns:
the relative field number