org.springframework.binding.form.support
Class DefaultFieldMetadata

java.lang.Object
  extended by org.springframework.binding.value.support.AbstractPropertyChangePublisher
      extended by org.springframework.binding.form.support.DefaultFieldMetadata
All Implemented Interfaces:
FieldMetadata, PropertyChangePublisher

public class DefaultFieldMetadata
extends AbstractPropertyChangePublisher
implements FieldMetadata

Default implementation of FieldMetadata.

NOTE: This is a framework internal class and should not be instantiated in user code.

Author:
Oliver Hutchison

Field Summary
 
Fields inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher
logger
 
Fields inherited from interface org.springframework.binding.form.FieldMetadata
DIRTY_PROPERTY, ENABLED_PROPERTY, READ_ONLY_PROPERTY
 
Constructor Summary
DefaultFieldMetadata(FormModel formModel, DirtyTrackingValueModel valueModel, Class propertyType, boolean forceReadOnly, Map userMetadata)
          Constructs a new instance of DefaultFieldMetadata.
 
Method Summary
 void clearUserMetadata()
          Clears all custom metadata associated with this property.
 Map getAllUserMetadata()
          Returns all custom metadata associated with this property in the form of a Map.
 Class getPropertyType()
          Return the type of this property.
 Object getUserMetadata(String key)
          Returns custom metadata that may be associated with this property.
 boolean isDirty()
          Returns whether or not the property is dirty.
 boolean isEnabled()
          Returns whether or not the property is enabled.
 boolean isReadOnly()
          Returns whether or not the property is read only.
 void setEnabled(boolean enabled)
          Sets the enabled value for this property.
 void setReadOnly(boolean readOnly)
          Sets whether or not this property is read only.
 void setUserMetadata(String key, Object value)
          Sets custom metadata to be associated with this property.
 
Methods inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, firePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasChanged, hasChanged, hasChanged, hasChanged, hasChanged, hasChanged, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.binding.value.PropertyChangePublisher
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

DefaultFieldMetadata

public DefaultFieldMetadata(FormModel formModel,
                            DirtyTrackingValueModel valueModel,
                            Class propertyType,
                            boolean forceReadOnly,
                            Map userMetadata)
Constructs a new instance of DefaultFieldMetadata.

Parameters:
formModel - the form model
valueModel - the value model for the property
propertyType - the type of the property
forceReadOnly - should readOnly be forced to true; this is required if the property can not be modified. e.g. at the PropertyAccessStrategy level.
userMetadata - map using String keys containing user defined metadata. As an example, tiger extensions currently use this to expose JDK 1.5 annotations on the backing object as property metadata. This parameter may be null.
Method Detail

setReadOnly

public void setReadOnly(boolean readOnly)
Description copied from interface: FieldMetadata
Sets whether or not this property is read only.

It's expected that controls bound to this form property will listen for changes to this value and if possible modify their display/behaviour to reflect the new state. e.g. When this property becomes true a text component would grey its self out and prevent any editing.

This value will be propagated up to any descendants.

Specified by:
setReadOnly in interface FieldMetadata
Parameters:
readOnly - should this property be read only

isReadOnly

public boolean isReadOnly()
Description copied from interface: FieldMetadata
Returns whether or not the property is read only.

A property is read only if any of the following are true:

Specified by:
isReadOnly in interface FieldMetadata

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: FieldMetadata
Sets the enabled value for this property.

It's expected that controls bound to this form property will listen for changes to this value and if possible modify their display/behaviour to reflect the new state.

This value will be propagated up to any descendants.

Specified by:
setEnabled in interface FieldMetadata
Parameters:
enabled - should this property be enabled

isEnabled

public boolean isEnabled()
Description copied from interface: FieldMetadata
Returns whether or not the property is enabled.

A property is enabled if all of the following are true:

Specified by:
isEnabled in interface FieldMetadata

isDirty

public boolean isDirty()
Description copied from interface: FieldMetadata
Returns whether or not the property is dirty.

Specified by:
isDirty in interface FieldMetadata

getPropertyType

public Class getPropertyType()
Description copied from interface: FieldMetadata
Return the type of this property.

Specified by:
getPropertyType in interface FieldMetadata

getUserMetadata

public Object getUserMetadata(String key)
Description copied from interface: FieldMetadata
Returns custom metadata that may be associated with this property.

Specified by:
getUserMetadata in interface FieldMetadata

getAllUserMetadata

public Map getAllUserMetadata()
Description copied from interface: FieldMetadata
Returns all custom metadata associated with this property in the form of a Map.

Specified by:
getAllUserMetadata in interface FieldMetadata
Returns:
Map containing String keys

setUserMetadata

public void setUserMetadata(String key,
                            Object value)
Sets custom metadata to be associated with this property. A property change event will be fired (from this FieldMetadata, not from the associated form property) if value differs from the current value of the specified key. The property change event will use the value of key as the property name in the property change event.

Parameters:
key -
value -

clearUserMetadata

public void clearUserMetadata()
Clears all custom metadata associated with this property. A property change event will be fired for every key that contained a non-null value before this method was invoked. It is possible for a PropertyChangeListener to mutate user metadata, by setting a key value for example, in response to one of these property change events fired during the course of the clear operation. Because of this, there is no guarantee that all user metadata is in fact completely clear and empty by the time this method returns.



Copyright © 2004-2008 The Spring Framework. All Rights Reserved.