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

PersistenceFieldElementImpl

public class PersistenceFieldElementImpl extends PersistenceMemberElementImpl implements PersistenceFieldElement.Impl
author
raccah
version
%I%

Fields Summary
private static final int
READ_SENSITIVE
Constant representing read sensitive.
private static final int
WRITE_SENSITIVE
Constant representing write sensitive.
private int
_persistenceType
Persistence type of the field element.
private int
_derivedModifier
Derived modifier of the field element.
private boolean
_isKey
Key field flag of the field element.
Constructors Summary
public PersistenceFieldElementImpl()
Create new PersistenceFieldElementImpl with no corresponding name. This constructor should only be used for cloning and archiving.


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

param
name the name of the element

		super(name);
		_persistenceType = PersistenceFieldElement.PERSISTENT;
	
Methods Summary
public intgetPersistenceType()
Get the persistence type of this field element.

return
the persistence type, one of {@link PersistenceFieldElement#PERSISTENT} or {@link PersistenceFieldElement#DERIVED}. The default is PERSISTENT.

 return _persistenceType; 
public booleanisKey()
Determines whether this field element is a key field or not.

return
true if the field is a key field, false otherwise
see
PersistenceClassElement#getKeyClass

 return _isKey; 
public booleanisReadSensitive()
Determines whether this field element is read sensitive or not. This value is only used if getPersistenceType returns DERIVED

return
true if the field is read sensitive, false if it is not or if the persistence type is not derived
see
#isWriteSensitive
see
#setPersistenceType
see
PersistenceFieldElement#DERIVED

		return ((PersistenceFieldElement.DERIVED == getPersistenceType()) ? 
			((_derivedModifier & READ_SENSITIVE) != 0) : false);
	
public booleanisWriteSensitive()
Determines whether this field element is write sensitive or not. This value is only used if getPersistenceType returns DERIVED

return
true if the field is write sensitive, false if it is not or if the persistence type is not derived
see
#isReadSensitive
see
#setPersistenceType
see
PersistenceFieldElement#DERIVED

		return ((PersistenceFieldElement.DERIVED == getPersistenceType()) ?
			((_derivedModifier & WRITE_SENSITIVE) != 0) : false);
	
public voidsetKey(boolean flag)
Set whether this field element is a key field or not.

param
flag - if true, the field element is marked as a key field; otherwise, it is not
exception
ModelException if impossible
see
PersistenceClassElement#getKeyClass

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

		try
		{
			fireVetoableChange(PROP_KEY_FIELD, old, newFlag);
			_isKey = flag;
			firePropertyChange(PROP_KEY_FIELD, old, newFlag);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public voidsetPersistenceType(int type)
Set the persistence type of this field element.

param
type - an integer indicating the persistence type, one of: {@link PersistenceFieldElement#PERSISTENT} or {@link PersistenceFieldElement#DERIVED}
exception
ModelException if impossible

		Integer old = new Integer(getPersistenceType());
		Integer newType = new Integer(type);
		
		try
		{
			fireVetoableChange(PROP_PERSISTENCE, old, newType);
			_persistenceType = type;
			firePropertyChange(PROP_PERSISTENCE, old, newType);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public voidsetReadSensitive(boolean flag)
Set whether this field element is read sensitive or not.

param
flag - if true and this is a derived field, the field element is marked as read sensitive; otherwise, it is not This value is only used if getPersistenceType returns DERIVED
exception
ModelException if impossible
see
#setWriteSensitive
see
#setPersistenceType
see
PersistenceFieldElement#DERIVED

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

		try
		{
			fireVetoableChange(PROP_SENSITIVITY, old, newFlag);

			if (flag)
				_derivedModifier |= READ_SENSITIVE;
			else
				_derivedModifier &= READ_SENSITIVE;

			firePropertyChange(PROP_SENSITIVITY, old, newFlag);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}
	
public voidsetWriteSensitive(boolean flag)
Set whether this field element is write sensitive or not.

param
flag - if true and this is a derived field, the field element is marked as write sensitive; otherwise, it is not This value is only used if getPersistenceType returns DERIVED
exception
ModelException if impossible
see
#setReadSensitive
see
#setPersistenceType
see
PersistenceFieldElement#DERIVED

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

		try
		{
			fireVetoableChange(PROP_SENSITIVITY, old, newFlag);

			if (flag)
				_derivedModifier |= WRITE_SENSITIVE;
			else
				_derivedModifier &= WRITE_SENSITIVE;

			firePropertyChange(PROP_SENSITIVITY, old, newFlag);
		}
		catch (PropertyVetoException e)
		{
			throw new ModelVetoException(e);
		}