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 interface
PersistenceClassElement.Impl
Pluggable implementation of the storage of class element properties.
-
Field Summary
Fields Modifier and Type Field Description static int
APPLICATION_IDENTITY
Constant representing jdo identity managed by the application.static int
DATABASE_IDENTITY
Constant representing jdo identity managed by the database.static int
UNMANAGED_IDENTITY
Constant 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 void
addConcurrencyGroup(ConcurrencyGroupElement group)
Add the supplied group to the collection of concurrency groups for this class.void
addConcurrencyGroups(ConcurrencyGroupElement[] groups)
Add the supplied groups to the collection of concurrency groups for this class.void
addField(PersistenceFieldElement field)
Add the supplied field to the collection of fields maintained by this holder.void
addFields(PersistenceFieldElement[] fields)
Add the supplied fields to the collection of fields maintained by this holder.boolean
containsConcurrencyGroup(ConcurrencyGroupElement group)
Tests whether the supplied group is in the collection of groups maintained by this class.boolean
containsField(PersistenceFieldElement field)
Tests whether the supplied field is in the collection of fields maintained by this holder.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.ConcurrencyGroupElement
getConcurrencyGroup(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.PersistenceFieldElement
getField(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.String
getKeyClass()
Get the fully qualified name of the primary key class for this class element.int
getObjectIdentityType()
Get the object identity type of this class element.String
getPackage()
Get the package name of this class element.RelationshipElement
getRelationship(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.boolean
isModified()
Gets the modified flag for this persistence class.void
removeConcurrencyGroup(ConcurrencyGroupElement group)
Remove the supplied group from the collection of concurrency groups for this class.void
removeConcurrencyGroups(ConcurrencyGroupElement[] groups)
Removed the supplied groups from the collection of concurrency groups for this class.void
removeField(PersistenceFieldElement field)
Remove the supplied field from the collection of fields maintained by this holder.void
removeFields(PersistenceFieldElement[] fields)
Removed the supplied fields from the collection of fields maintained by this holder.void
setConcurrencyGroups(ConcurrencyGroupElement[] groups)
Sets the collection of concurrency groups maintained by this class to the contents of the supplied array.void
setFields(PersistenceFieldElement[] fields)
Sets the collection of fields maintained by this holder to the contents of the supplied array.void
setKeyClass(String name)
Set the primary key class for this class element.void
setModified(boolean flag)
Set the modified flag for this persistence class to flag.void
setName(String name)
Set the name of this persistence element.void
setObjectIdentityType(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:
true
if there have been (property) changes to this class,false
otherwise.
-
setModified
public void setModified(boolean flag)
Set the modified flag for this persistence class to flag. This is usually set totrue
by property changes andfalse
after 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 ModelException
Set 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 ifgetObjectIdentityType
returnsAPPLICATION_IDENTITY
- Returns:
- the fully qualified key class name,
null
if 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 ifgetObjectIdentityType
returnsAPPLICATION_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 class
in sync if possible.- Overrides:
setName
in 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:
addField
in 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:
addFields
in 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:
removeField
in 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:
removeFields
in 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:
getFields
in 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:
setFields
in 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:
getField
in interfaceFieldElementHolder
- Parameters:
name
- the name of the field to be found- Returns:
- the field with the supplied name,
null
if 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:
containsField
in 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,
null
if 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,
null
if 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
-
-