Class PersistenceClassElement
- java.lang.Object
-
- com.sun.jdo.api.persistence.model.jdo.PersistenceElement
-
- com.sun.jdo.api.persistence.model.jdo.PersistenceClassElement
-
- All Implemented Interfaces:
FieldElementHolder,PersistenceElementProperties,Comparable
public class PersistenceClassElement extends PersistenceElement implements FieldElementHolder
- Version:
- %I%
- Author:
- raccah
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePersistenceClassElement.ImplPluggable implementation of the storage of class element properties.
-
Field Summary
Fields Modifier and Type Field Description static intAPPLICATION_IDENTITYConstant representing jdo identity managed by the application.static intDATABASE_IDENTITYConstant representing jdo identity managed by the database.static intUNMANAGED_IDENTITYConstant representing unmanaged jdo identity.-
Fields inherited from interface com.sun.jdo.api.persistence.model.jdo.PersistenceElementProperties
PROP_CARDINALITY, PROP_COLLECTION_CLASS, PROP_DELETE_ACTION, PROP_ELEMENT_CLASS, PROP_FIELDS, PROP_GROUPS, PROP_IDENTITY, PROP_INVERSE_FIELD, PROP_KEY_CLASS, PROP_KEY_FIELD, PROP_MODIFIED, PROP_NAME, PROP_PERSISTENCE, PROP_PREFETCH, PROP_SENSITIVITY, PROP_UPDATE_ACTION
-
-
Constructor Summary
Constructors Constructor Description PersistenceClassElement()Create new PersistenceClassElement with no implementation.PersistenceClassElement(PersistenceClassElement.Impl impl)Create new PersistenceClassElement with the provided implementation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConcurrencyGroup(ConcurrencyGroupElement group)Add the supplied group to the collection of concurrency groups for this class.voidaddConcurrencyGroups(ConcurrencyGroupElement[] groups)Add the supplied groups to the collection of concurrency groups for this class.voidaddField(PersistenceFieldElement field)Add the supplied field to the collection of fields maintained by this holder.voidaddFields(PersistenceFieldElement[] fields)Add the supplied fields to the collection of fields maintained by this holder.booleancontainsConcurrencyGroup(ConcurrencyGroupElement group)Tests whether the supplied group is in the collection of groups maintained by this class.booleancontainsField(PersistenceFieldElement field)Tests whether the supplied field is in the collection of fields maintained by this holder.static PersistenceClassElementforName(String name, Model model)Returns the persistence class element associated with the class with the given string name, using the given model object to look it up.ConcurrencyGroupElementgetConcurrencyGroup(String name)Returns the concurrency group with the supplied name from the collection of groups maintained by this class.ConcurrencyGroupElement[]getConcurrencyGroups()Returns the collection of fields groups by this class in the form of an array.PersistenceFieldElementgetField(String name)Returns the field with the supplied name from the collection of fields maintained by this holder.PersistenceFieldElement[]getFields()Returns the collection of fields maintained by this holder in the form of an array.StringgetKeyClass()Get the fully qualified name of the primary key class for this class element.intgetObjectIdentityType()Get the object identity type of this class element.StringgetPackage()Get the package name of this class element.RelationshipElementgetRelationship(String name)Returns the relationship with the supplied name from the collection of relationships maintained by this holder.RelationshipElement[]getRelationships()Returns the subset of the collection of fields which are relationahips.booleanisModified()Gets the modified flag for this persistence class.voidremoveConcurrencyGroup(ConcurrencyGroupElement group)Remove the supplied group from the collection of concurrency groups for this class.voidremoveConcurrencyGroups(ConcurrencyGroupElement[] groups)Removed the supplied groups from the collection of concurrency groups for this class.voidremoveField(PersistenceFieldElement field)Remove the supplied field from the collection of fields maintained by this holder.voidremoveFields(PersistenceFieldElement[] fields)Removed the supplied fields from the collection of fields maintained by this holder.voidsetConcurrencyGroups(ConcurrencyGroupElement[] groups)Sets the collection of concurrency groups maintained by this class to the contents of the supplied array.voidsetFields(PersistenceFieldElement[] fields)Sets the collection of fields maintained by this holder to the contents of the supplied array.voidsetKeyClass(String name)Set the primary key class for this class element.voidsetModified(boolean flag)Set the modified flag for this persistence class to flag.voidsetName(String name)Set the name of this persistence element.voidsetObjectIdentityType(int type)Set the object identity type of this class element.-
Methods inherited from class com.sun.jdo.api.persistence.model.jdo.PersistenceElement
addPropertyChangeListener, addVetoableChangeListener, compareTo, equals, getImpl, getMessages, getName, hashCode, removePropertyChangeListener, removeVetoableChangeListener, setImpl, toString
-
-
-
-
Field Detail
-
APPLICATION_IDENTITY
public static final int APPLICATION_IDENTITY
Constant representing jdo identity managed by the application.- See Also:
- Constant Field Values
-
DATABASE_IDENTITY
public static final int DATABASE_IDENTITY
Constant representing jdo identity managed by the database.- See Also:
- Constant Field Values
-
UNMANAGED_IDENTITY
public static final int UNMANAGED_IDENTITY
Constant representing unmanaged jdo identity.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PersistenceClassElement
public PersistenceClassElement()
Create new PersistenceClassElement with no implementation. This constructor should only be used for cloning and archiving.
-
PersistenceClassElement
public PersistenceClassElement(PersistenceClassElement.Impl impl)
Create new PersistenceClassElement with the provided implementation. The implementation is responsible for storing all properties of the object.- Parameters:
impl- the implementation to use
-
-
Method Detail
-
forName
public static PersistenceClassElement forName(String name, Model model)
Returns the persistence class element associated with the class with the given string name, using the given model object to look it up.- Parameters:
name- the fully qualified name of the desired classmodel- the model object to be used to look it up- Returns:
- persistence class element representing the desired class
-
getPackage
public String getPackage()
Get the package name of this class element.- Returns:
- the package
- See Also:
PersistenceElement.getName()
-
isModified
public boolean isModified()
Gets the modified flag for this persistence class.- Returns:
trueif there have been (property) changes to this class,falseotherwise.
-
setModified
public void setModified(boolean flag)
Set the modified flag for this persistence class to flag. This is usually set totrueby property changes andfalseafter a save.- Parameters:
flag- iftrue, this class is marked as modified; iffalse, it is marked as unmodified.
-
getObjectIdentityType
public int getObjectIdentityType()
Get the object identity type of this class element.- Returns:
- the object identity type, one of
APPLICATION_IDENTITY,DATABASE_IDENTITY, orUNMANAGED_IDENTITY
-
setObjectIdentityType
public void setObjectIdentityType(int type) throws ModelExceptionSet the object identity type of this class element.- Parameters:
type- - an integer indicating the object identity type, one of:APPLICATION_IDENTITY,DATABASE_IDENTITY, orUNMANAGED_IDENTITY- Throws:
ModelException- if impossible
-
getKeyClass
public String getKeyClass()
Get the fully qualified name of the primary key class for this class element. This value is only used ifgetObjectIdentityTypereturnsAPPLICATION_IDENTITY- Returns:
- the fully qualified key class name,
nullif the identity type is not managed by the application - See Also:
setObjectIdentityType(int),APPLICATION_IDENTITY
-
setKeyClass
public void setKeyClass(String name) throws ModelException
Set the primary key class for this class element. For now the key class is required to be in the same package with the same name as this class and the suffix "Key" (any capitalization), or an inner class of this class with the name "OID" (any capitalization).- Parameters:
name- - the fully qualified name which represents the primary key class. This value is only used ifgetObjectIdentityTypereturnsAPPLICATION_IDENTITY- Throws:
ModelException- if impossible- See Also:
setObjectIdentityType(int),APPLICATION_IDENTITY
-
setName
public void setName(String name) throws ModelException
Set the name of this persistence element. This method overrides the one in PersistenceElement in order to keep thekey classin sync if possible.- Overrides:
setNamein classPersistenceElement- Parameters:
name- the name- Throws:
ModelException- if impossible
-
addField
public void addField(PersistenceFieldElement field) throws ModelException
Add the supplied field to the collection of fields maintained by this holder.- Specified by:
addFieldin interfaceFieldElementHolder- Parameters:
field- the field to be added- Throws:
ModelException- if impossible
-
addFields
public void addFields(PersistenceFieldElement[] fields) throws ModelException
Add the supplied fields to the collection of fields maintained by this holder.- Specified by:
addFieldsin interfaceFieldElementHolder- Parameters:
fields- the array of fields to be added- Throws:
ModelException- if impossible
-
removeField
public void removeField(PersistenceFieldElement field) throws ModelException
Remove the supplied field from the collection of fields maintained by this holder.- Specified by:
removeFieldin interfaceFieldElementHolder- Parameters:
field- the field to be removed- Throws:
ModelException- if impossible
-
removeFields
public void removeFields(PersistenceFieldElement[] fields) throws ModelException
Removed the supplied fields from the collection of fields maintained by this holder.- Specified by:
removeFieldsin interfaceFieldElementHolder- Parameters:
fields- the array of fields to be removed- Throws:
ModelException- if impossible
-
getFields
public PersistenceFieldElement[] getFields()
Returns the collection of fields maintained by this holder in the form of an array.- Specified by:
getFieldsin interfaceFieldElementHolder- Returns:
- the fields maintained by this holder
-
setFields
public void setFields(PersistenceFieldElement[] fields) throws ModelException
Sets the collection of fields maintained by this holder to the contents of the supplied array.- Specified by:
setFieldsin interfaceFieldElementHolder- Parameters:
fields- the fields maintained by this holder- Throws:
ModelException- if impossible
-
getField
public PersistenceFieldElement getField(String name)
Returns the field with the supplied name from the collection of fields maintained by this holder.- Specified by:
getFieldin interfaceFieldElementHolder- Parameters:
name- the name of the field to be found- Returns:
- the field with the supplied name,
nullif none exists
-
containsField
public boolean containsField(PersistenceFieldElement field)
Tests whether the supplied field is in the collection of fields maintained by this holder.- Specified by:
containsFieldin interfaceFieldElementHolder- Parameters:
field- the field to be tested
-
getRelationships
public RelationshipElement[] getRelationships()
Returns the subset of the collection of fields which are relationahips.- Returns:
- the relationship fields maintained by this holder
- See Also:
getFields()
-
getRelationship
public RelationshipElement getRelationship(String name)
Returns the relationship with the supplied name from the collection of relationships maintained by this holder.- Parameters:
name- the name of the relationship to be found- Returns:
- the relationship with the supplied name,
nullif none exists - See Also:
getRelationships(),getField(java.lang.String)
-
addConcurrencyGroup
public void addConcurrencyGroup(ConcurrencyGroupElement group) throws ModelException
Add the supplied group to the collection of concurrency groups for this class.- Parameters:
group- the concurrency group to be added- Throws:
ModelException- if impossible
-
addConcurrencyGroups
public void addConcurrencyGroups(ConcurrencyGroupElement[] groups) throws ModelException
Add the supplied groups to the collection of concurrency groups for this class.- Parameters:
groups- the array of concurrency groups to be added- Throws:
ModelException- if impossible
-
removeConcurrencyGroup
public void removeConcurrencyGroup(ConcurrencyGroupElement group) throws ModelException
Remove the supplied group from the collection of concurrency groups for this class.- Parameters:
group- the concurrency group to be removed- Throws:
ModelException- if impossible
-
removeConcurrencyGroups
public void removeConcurrencyGroups(ConcurrencyGroupElement[] groups) throws ModelException
Removed the supplied groups from the collection of concurrency groups for this class.- Parameters:
groups- the array of concurrency groups to be removed- Throws:
ModelException- if impossible
-
getConcurrencyGroups
public ConcurrencyGroupElement[] getConcurrencyGroups()
Returns the collection of fields groups by this class in the form of an array.- Returns:
- the concurrency groups maintained by this class
-
setConcurrencyGroups
public void setConcurrencyGroups(ConcurrencyGroupElement[] groups) throws ModelException
Sets the collection of concurrency groups maintained by this class to the contents of the supplied array.- Parameters:
groups- the concurrency groups maintained by this holder- Throws:
ModelException- if impossible
-
getConcurrencyGroup
public ConcurrencyGroupElement getConcurrencyGroup(String name)
Returns the concurrency group with the supplied name from the collection of groups maintained by this class.- Parameters:
name- the name of the concurrency group to be found- Returns:
- the concurrency group with the supplied name,
nullif none exists
-
containsConcurrencyGroup
public boolean containsConcurrencyGroup(ConcurrencyGroupElement group)
Tests whether the supplied group is in the collection of groups maintained by this class.- Parameters:
group- the concurrency group to be tested
-
-