org.springframework.beans
Class MutablePropertyValues

java.lang.Object
  extended by org.springframework.beans.MutablePropertyValues
All Implemented Interfaces:
Serializable, PropertyValues
Direct Known Subclasses:
ServletRequestParameterPropertyValues

public class MutablePropertyValues
extends Object
implements PropertyValues, Serializable

Default implementation of the PropertyValues interface. Allows simple manipulation of properties, and provides constructors to support deep copy and construction from a Map.

Since:
13 May 2001
Author:
Rod Johnson, Juergen Hoeller, Rob Harrop
See Also:
Serialized Form

Constructor Summary
MutablePropertyValues()
          Creates a new empty MutablePropertyValues object.
MutablePropertyValues(Map original)
          Construct a new PropertyValues object from a Map.
MutablePropertyValues(PropertyValues original)
          Deep copy constructor.
 
Method Summary
 MutablePropertyValues addPropertyValue(PropertyValue pv)
          Add a PropertyValue object, replacing any existing one for the corresponding property.
 void addPropertyValue(String propertyName, Object propertyValue)
          Overloaded version of addPropertyValue that takes a property name and a property value.
 MutablePropertyValues addPropertyValues(Map other)
          Add all property values from the given Map.
 MutablePropertyValues addPropertyValues(PropertyValues other)
          Copy all given PropertyValues into this object.
 PropertyValues changesSince(PropertyValues old)
          Return the changes since the previous PropertyValues.
 void clear()
          Clear this holder, removing all PropertyValues.
 boolean contains(String propertyName)
          Is there a property value for this property?
 PropertyValue getPropertyValue(String propertyName)
          Return the property value with the given name, if any.
 PropertyValue[] getPropertyValues()
          Return an array of the PropertyValue objects held in this object.
 boolean isEmpty()
           
 void removePropertyValue(PropertyValue pv)
          Remove the given PropertyValue, if contained.
 void removePropertyValue(String propertyName)
          Overloaded version of removePropertyValue that takes a property name.
 void setPropertyValueAt(PropertyValue pv, int i)
          Modify a PropertyValue object held in this object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutablePropertyValues

public MutablePropertyValues()
Creates a new empty MutablePropertyValues object. Property values can be added with the addPropertyValue methods.

See Also:
addPropertyValue(PropertyValue), addPropertyValue(String, Object)

MutablePropertyValues

public MutablePropertyValues(PropertyValues original)
Deep copy constructor. Guarantees PropertyValue references are independent, although it can't deep copy objects currently referenced by individual PropertyValue objects.

Parameters:
original - the PropertyValues to copy
See Also:
addPropertyValues(PropertyValues)

MutablePropertyValues

public MutablePropertyValues(Map original)
Construct a new PropertyValues object from a Map.

Parameters:
original - Map with property values keyed by property name Strings
See Also:
addPropertyValues(Map)
Method Detail

addPropertyValues

public MutablePropertyValues addPropertyValues(PropertyValues other)
Copy all given PropertyValues into this object. Guarantees PropertyValue references are independent, although it can't deep copy objects currently referenced by individual PropertyValue objects.

Parameters:
other - the PropertyValues to copy
Returns:
this object to allow creating objects, adding multiple PropertyValues in a single statement

addPropertyValues

public MutablePropertyValues addPropertyValues(Map other)
Add all property values from the given Map.

Parameters:
other - Map with property values keyed by property name, which must be a String
Returns:
this object to allow creating objects, adding multiple PropertyValues in a single statement

addPropertyValue

public MutablePropertyValues addPropertyValue(PropertyValue pv)
Add a PropertyValue object, replacing any existing one for the corresponding property.

Parameters:
pv - PropertyValue object to add
Returns:
this object to allow creating objects, adding multiple PropertyValues in a single statement

addPropertyValue

public void addPropertyValue(String propertyName,
                             Object propertyValue)
Overloaded version of addPropertyValue that takes a property name and a property value.

Parameters:
propertyName - name of the property
propertyValue - value of the property
See Also:
addPropertyValue(PropertyValue)

setPropertyValueAt

public void setPropertyValueAt(PropertyValue pv,
                               int i)
Modify a PropertyValue object held in this object. Indexed from 0.


removePropertyValue

public void removePropertyValue(String propertyName)
Overloaded version of removePropertyValue that takes a property name.

Parameters:
propertyName - name of the property
See Also:
removePropertyValue(PropertyValue)

removePropertyValue

public void removePropertyValue(PropertyValue pv)
Remove the given PropertyValue, if contained.

Parameters:
pv - the PropertyValue to remove

clear

public void clear()
Clear this holder, removing all PropertyValues.


getPropertyValues

public PropertyValue[] getPropertyValues()
Description copied from interface: PropertyValues
Return an array of the PropertyValue objects held in this object.

Specified by:
getPropertyValues in interface PropertyValues

getPropertyValue

public PropertyValue getPropertyValue(String propertyName)
Description copied from interface: PropertyValues
Return the property value with the given name, if any.

Specified by:
getPropertyValue in interface PropertyValues
Parameters:
propertyName - the name to search for
Returns:
the property value, or null

contains

public boolean contains(String propertyName)
Description copied from interface: PropertyValues
Is there a property value for this property?

Specified by:
contains in interface PropertyValues
Parameters:
propertyName - the name of the property we're interested in
Returns:
whether there is a property value for this property

isEmpty

public boolean isEmpty()

changesSince

public PropertyValues changesSince(PropertyValues old)
Description copied from interface: PropertyValues
Return the changes since the previous PropertyValues. Subclasses should also override equals.

Specified by:
changesSince in interface PropertyValues
Parameters:
old - old property values
Returns:
PropertyValues updated or new properties. Return empty PropertyValues if there are no changes.
See Also:
Object.equals(java.lang.Object)

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2002-2007 The Spring Framework Project.