dsto.dfc.collections
Class BasicPropertySet

java.lang.Object
  extended by dsto.dfc.collections.BasicPropertySet
All Implemented Interfaces:
PropertySet, Serializable, Cloneable

public class BasicPropertySet
extends Object
implements PropertySet, Serializable, Cloneable

An implementation of PropertySet using HashMap and ArrayList.

Version:
$Revision$
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface dsto.dfc.collections.PropertySet
EMPTY_PROPERTY_SET
 
Constructor Summary
BasicPropertySet()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void addPropertyValue(String propertyName, Object newValue)
          Add a values to the end of the list of property values.
 void addPropertyValues(String propertyName, List values)
          Add a set of values to a property.
 Object clone()
           
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
           
 Set getPropertyNames()
          The names of defined properties.
 Object getPropertyValue(String propertyName)
          Get the value of a property.
 List getPropertyValues(String propertyName)
          The values of a property.
protected  ArrayList getValueAsList(String propertyName)
          Get the value of a property as a List, handling the case where a single value for property has been stored directly.
 boolean hasProperty(String propertyName)
          True if a property has any defined values.
 boolean isModifiable()
          True if property set may be changed.
 void removeAll()
          Undefine all properties in the set
 void removeProperty(String propertyName)
          Remove all values of a property (ie undefine it).
 void removePropertyChangeListener(PropertyChangeListener l)
           
 boolean removePropertyValue(String propertyName, Object value)
          Remove the first occurrence of a value from a list of property values.
 void setPropertyValue(String propertyName, Object value)
           
 void setPropertyValues(String propertyName, List values)
          Set the values of a property.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicPropertySet

public BasicPropertySet()
Method Detail

getPropertyNames

public Set getPropertyNames()
Description copied from interface: PropertySet
The names of defined properties.

Specified by:
getPropertyNames in interface PropertySet
Returns:
An immutable set of strings.

getPropertyValues

public List getPropertyValues(String propertyName)
Description copied from interface: PropertySet
The values of a property.

Specified by:
getPropertyValues in interface PropertySet
Parameters:
propertyName - The name of the property.
Returns:
The values for propertyName, or null if no values are defined.

getPropertyValue

public Object getPropertyValue(String propertyName)
Description copied from interface: PropertySet
Get the value of a property. If more than one value exists, the last added value is returned.

Specified by:
getPropertyValue in interface PropertySet

addPropertyValues

public void addPropertyValues(String propertyName,
                              List values)
Description copied from interface: PropertySet
Add a set of values to a property.

Specified by:
addPropertyValues in interface PropertySet

setPropertyValues

public void setPropertyValues(String propertyName,
                              List values)
Description copied from interface: PropertySet
Set the values of a property.

Specified by:
setPropertyValues in interface PropertySet

setPropertyValue

public void setPropertyValue(String propertyName,
                             Object value)
Specified by:
setPropertyValue in interface PropertySet

removeProperty

public void removeProperty(String propertyName)
Description copied from interface: PropertySet
Remove all values of a property (ie undefine it).

Specified by:
removeProperty in interface PropertySet

removePropertyValue

public boolean removePropertyValue(String propertyName,
                                   Object value)
                            throws UnsupportedOperationException
Description copied from interface: PropertySet
Remove the first occurrence of a value from a list of property values.

Specified by:
removePropertyValue in interface PropertySet
Returns:
True if the property set was changed (ie a value was removed).
Throws:
UnsupportedOperationException - if property values cannot be changed.

hasProperty

public boolean hasProperty(String propertyName)
Description copied from interface: PropertySet
True if a property has any defined values.

Specified by:
hasProperty in interface PropertySet

removeAll

public void removeAll()
Description copied from interface: PropertySet
Undefine all properties in the set

Specified by:
removeAll in interface PropertySet

addPropertyValue

public void addPropertyValue(String propertyName,
                             Object newValue)
Description copied from interface: PropertySet
Add a values to the end of the list of property values.

Specified by:
addPropertyValue in interface PropertySet

isModifiable

public boolean isModifiable()
Description copied from interface: PropertySet
True if property set may be changed.

Specified by:
isModifiable in interface PropertySet

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface PropertySet

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Specified by:
removePropertyChangeListener in interface PropertySet

clone

public Object clone()
             throws CloneNotSupportedException
Specified by:
clone in interface PropertySet
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)

getValueAsList

protected ArrayList getValueAsList(String propertyName)
Get the value of a property as a List, handling the case where a single value for property has been stored directly.



Copyright © 2008 Commonwealth of Australia