FileDocCategorySizeDatePackage
RelationshipElementImpl.javaAPI DocGlassfish v2 API12924Fri May 04 22:34:44 BST 2007com.sun.jdo.api.persistence.model.jdo.impl

RelationshipElementImpl

public class RelationshipElementImpl extends PersistenceFieldElementImpl implements RelationshipElement.Impl
author
raccah
version
%I%

Fields Summary
private int
_updateAction
Update action of the relationship element.
private int
_deleteAction
Delete action of the relationship element.
private boolean
_isPrefetch
Flag indicating whether this relationship element should prefetch.
private int
_lowerBound
Lower cardinality bound of the relationship element.
private int
_upperBound
Upper cardinality bound of the relationship element.
private String
_collectionClass
Collection lass of the relationship element.
private String
_elementClass
Element class of the relationship element.
private String
_inverseRelationshipName
Relative name of the inverse relationship.
Constructors Summary
public RelationshipElementImpl()
Create new RelationshipElementImpl with no corresponding name. This constructor should only be used for cloning and archiving.

		this(null);
	
public RelationshipElementImpl(String name)
Creates new RelationshipElementImpl with the corresponding name

param
name the name of the element

		super(name);
		_updateAction = RelationshipElement.NONE_ACTION;
		_deleteAction = RelationshipElement.NONE_ACTION;
		_isPrefetch = false;
		_lowerBound = 0;
		_upperBound = Integer.MAX_VALUE;
	
Methods Summary
public voidchangeInverseRelationship(com.sun.jdo.api.persistence.model.jdo.RelationshipElement inverseRelationship)
Changes the inverse relationship element for this relationship element. This method is invoked for both sides from {@link RelationshipElement#setInverseRelationship} and should handle the vetoable change events, property change events, and setting the internal variable.

param
inverseRelationship - a relationship element to be used as the inverse for this relationship element or null if this relationship element does not participate in a two-way relationship.
exception
ModelException if impossible

		String newName = ((inverseRelationship != null) ?
			inverseRelationship.getName() : null);
		String oldName = getInverseRelationshipName();

		try
		{
			fireVetoableChange(PROP_INVERSE_FIELD, oldName, newName);
			_inverseRelationshipName = newName;
			firePropertyChange(PROP_INVERSE_FIELD, oldName, newName);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public java.lang.StringgetCollectionClass()
Get the collection class (for example Set, List, Vector, etc.) for this relationship element.

return
the collection class

 return _collectionClass; 
public intgetDeleteAction()
Get the delete action for this relationship element.

return
the delete action, one of {@link RelationshipElement#NONE_ACTION}, {@link RelationshipElement#NULLIFY_ACTION}, {@link RelationshipElement#RESTRICT_ACTION}, {@link RelationshipElement#CASCADE_ACTION}, or {@link RelationshipElement#AGGREGATE_ACTION}. The default is NONE_ACTION.

 return _deleteAction; 
public java.lang.StringgetElementClass()
Get the element class for this relationship element. If primitive types are supported, you can use wrapperclass.TYPE.toString() to specify them.

return
the element class

 return _elementClass; 
public java.lang.StringgetInverseRelationshipName()
Get the relative name of the inverse relationship field for this relationship element. In the case of two-way relationships, the two relationship elements involved are inverses of each other. If this relationship element does not participate in a two-way relationship, this returns null. Note that it is possible to have this method return a value, but because of the combination of related class and lookup, there may be no corresponding RelationshipElement which can be found.

return
the relative name of the inverse relationship element
see
#getInverseRelationship

		return _inverseRelationshipName;
	
public intgetLowerBound()
Get the lower cardinality bound for this relationship element. The default is 0.

return
the lower cardinality bound

 return _lowerBound; 
public intgetUpdateAction()
Get the update action for this relationship element.

return
the update action, one of {@link RelationshipElement#NONE_ACTION}, {@link RelationshipElement#NULLIFY_ACTION}, {@link RelationshipElement#RESTRICT_ACTION}, {@link RelationshipElement#CASCADE_ACTION}, or {@link RelationshipElement#AGGREGATE_ACTION}. The default is NONE_ACTION.

 return _updateAction; 
public intgetUpperBound()
Get the upper cardinality bound for this relationship element. The default is Integer.MAX_VALUE. Returns {@link java.lang.Integer#MAX_VALUE} for n

return
the upper cardinality bound

 return _upperBound; 
public booleanisPrefetch()
Determines whether this relationship element should prefetch or not.

return
true if the relationship should prefetch, false otherwise. The default is false.

 return _isPrefetch; 
public voidsetCollectionClass(java.lang.String collectionClass)
Set the collection class for this relationship element.

param
collectionClass - a string indicating the type of collection (for example Set, List, Vector, etc.)
exception
ModelException if impossible

		String old = getCollectionClass();

		try
		{
			fireVetoableChange(PROP_COLLECTION_CLASS, old, collectionClass);
			_collectionClass = collectionClass;
			firePropertyChange(PROP_COLLECTION_CLASS, old, collectionClass);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
 	
public voidsetDeleteAction(int action)
Set the delete action for this relationship element.

param
action - an integer indicating the delete action, one of: {@link RelationshipElement#NONE_ACTION}, {@link RelationshipElement#NULLIFY_ACTION}, {@link RelationshipElement#RESTRICT_ACTION}, {@link RelationshipElement#CASCADE_ACTION}, or {@link RelationshipElement#AGGREGATE_ACTION}
exception
ModelException if impossible

		Integer old = new Integer(getDeleteAction());
		Integer newAction = new Integer(action);

		try
		{
			fireVetoableChange(PROP_DELETE_ACTION, old, newAction);
			_deleteAction = action;
			firePropertyChange(PROP_DELETE_ACTION, old, newAction);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public voidsetElementClass(java.lang.String elementClass)
Set the element class for this relationship element.

param
elementClass - a string indicating the type of elements in the collection. If primitive types are supported, you can use wrapperclass.TYPE.toString() to specify them.
exception
ModelException if impossible

		String old = getElementClass();

		try
		{
			fireVetoableChange(PROP_ELEMENT_CLASS, old, elementClass);
			_elementClass = elementClass;
			firePropertyChange(PROP_ELEMENT_CLASS, old, elementClass);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
 	
public voidsetLowerBound(int lowerBound)
Set the lower cardinality bound for this relationship element.

param
lowerBound - an integer indicating the lower cardinality bound
exception
ModelException if impossible

		Integer old = new Integer(getLowerBound());
		Integer newBound = new Integer(lowerBound);

		try
		{
			fireVetoableChange(PROP_CARDINALITY, old, newBound);
			_lowerBound = lowerBound;
			firePropertyChange(PROP_CARDINALITY, old, newBound);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public voidsetPrefetch(boolean flag)
Set whether this relationship element should prefetch or not.

param
flag - if true, the relationship is set to prefetch; otherwise, it is not
exception
ModelException if impossible

		Boolean old = JavaTypeHelper.valueOf(isPrefetch());
		Boolean newFlag = JavaTypeHelper.valueOf(flag);

		try
		{
			fireVetoableChange(PROP_PREFETCH, old, newFlag);
			_isPrefetch = flag;
			firePropertyChange(PROP_PREFETCH, old, newFlag);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public voidsetUpdateAction(int action)
Set the update action for this relationship element.

param
action - an integer indicating the update action, one of: {@link RelationshipElement#NONE_ACTION}, {@link RelationshipElement#NULLIFY_ACTION}, {@link RelationshipElement#RESTRICT_ACTION}, {@link RelationshipElement#CASCADE_ACTION}, or {@link RelationshipElement#AGGREGATE_ACTION}
exception
ModelException if impossible

		Integer old = new Integer(getUpdateAction());
		Integer newAction = new Integer(action);

		try
		{
			fireVetoableChange(PROP_UPDATE_ACTION, old, newAction);
			_updateAction = action;
			firePropertyChange(PROP_UPDATE_ACTION, old, newAction);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public voidsetUpperBound(int upperBound)
Set the upper cardinality bound for this relationship element.

param
upperBound - an integer indicating the upper cardinality bound (use {@link java.lang.Integer#MAX_VALUE} for n)
exception
ModelException if impossible

		Integer old = new Integer(getUpperBound());
		Integer newBound = new Integer(upperBound);

		try
		{
			fireVetoableChange(PROP_CARDINALITY, old, newBound);
			_upperBound = upperBound;
			firePropertyChange(PROP_CARDINALITY, old, newBound);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}