javax.media.jai
Class WritablePropertySourceImpl

java.lang.Object
  |
  +--javax.media.jai.PropertySourceImpl
        |
        +--javax.media.jai.WritablePropertySourceImpl
All Implemented Interfaces:
PropertyChangeEmitter, PropertySource, Serializable, WritablePropertySource

public class WritablePropertySourceImpl
extends PropertySourceImpl
implements WritablePropertySource

A utility implementation of the WritablePropertySource interface. The same internal superclass data structures are used and are supplemented by a PropertyChangeSupportJAI to handle property event firing. All events fired by an instance of this class will be PropertySourceChangeEvents with an event source equal to the object used to create the PropertyChangeSupportJAI helper object. This object is user-specifiable at construction time or automatically created when a PropertyChangeListener is added or removed and the PropertyChangeSupportJAI specified at construction was null.

Since:
JAI 1.1
See Also:
CaselessStringKey, PropertySource, PropertySourceChangeEvent, PropertySourceImpl, WritablePropertySource, PropertyChangeEmitter, PropertyChangeSupportJAI, Serialized Form

Field Summary
protected  PropertyChangeSupportJAI manager
          Helper object for bean-style property events.
 
Fields inherited from class javax.media.jai.PropertySourceImpl
cachedPropertyNames, properties, propertySources
 
Constructor Summary
WritablePropertySourceImpl()
          Constructs a WritablePropertySourceImpl instance with no properties set.
WritablePropertySourceImpl(Map propertyMap, PropertySource source, PropertyChangeSupportJAI manager)
          Constructs a WritablePropertySourceImpl instance which will derive properties from one or both of the supplied parameters.
 
Method Summary
 void addProperties(Map propertyMap)
          Copies from the supplied Map to the property set all entries wherein the key is an instance of String or CaselessStringKey.
 void addProperties(PropertySource propertySource)
          Adds a PropertySource to the name-PropertySource mapping.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 void clearCachedProperties()
          Clears from the name-value mapping all properties which were derived from a source in the name-PropertySource mapping.
 void clearProperties()
          Clears all properties from the PropertySource by invoking removeProperty() with all known names.
 void clearPropertyMap()
          Clears the name-value mapping of all properties.
 void clearPropertySourceMap()
          Clears the name-PropertySource mapping.
 Object getProperty(String propertyName)
          Returns the value of a property.
 void removeProperty(String propertyName)
          Removes the named property from the PropertySource.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void removePropertySource(PropertySource propertySource)
          Removes from the name-PropertySource mapping all entries which refer to the supplied PropertySource.
 void setProperty(String propertyName, Object propertyValue)
          Adds the property value associated with the supplied name to the PropertySource.
 
Methods inherited from class javax.media.jai.PropertySourceImpl
getProperties, getPropertyClass, getPropertyNames, getPropertyNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.media.jai.PropertySource
getPropertyClass, getPropertyNames, getPropertyNames
 

Field Detail

manager

protected PropertyChangeSupportJAI manager
Helper object for bean-style property events. Its default value is null which indicates that no events are to be fired.
Constructor Detail

WritablePropertySourceImpl

public WritablePropertySourceImpl()
Constructs a WritablePropertySourceImpl instance with no properties set.

WritablePropertySourceImpl

public WritablePropertySourceImpl(Map propertyMap,
                                  PropertySource source,
                                  PropertyChangeSupportJAI manager)
Constructs a WritablePropertySourceImpl instance which will derive properties from one or both of the supplied parameters. The propertyMap and propertySource parameters will be used to initialize the name-value and name-PropertySource mappings, respectively. Entries in the propertyMap object will be assumed to be properties if the key is a String or a CaselessStringKey. The propertySource object will be queried for the names of properties that it emits but requests for associated values will not be made at this time so as to to defer any calculation that such requests might provoke. The case of property names will be retained but will be ignored insofar as the name is used as a key to the property value.
Parameters:
propertyMap - A Map from which to copy properties which have keys which are either Strings or CaselessStringKeys.
propertySource - A PropertySource from which to derive properties.
manager - The object which will actually fire the events. May be null in which case a default event manager will be created as needed with this object as its event source.
Method Detail

getProperty

public Object getProperty(String propertyName)
Returns the value of a property. If the property name is not recognized, java.awt.Image.UndefinedProperty will be returned.

If the requested name is found in the name-value mapping, the corresponding value will be returned. Otherwise the name-PropertySource mapping will be queried and the value will be derived from the found PropertySource, if any. If the value is derived from a PropertySource, a record will be kept of this and this property will be referred to as a "cached property". Derivation of the value from a PropertySource rather than from the name-value mapping may cause a PropertySourceChangeEvent to be fired.

Specified by:
getProperty in interface PropertySource
Overrides:
getProperty in class PropertySourceImpl
Parameters:
propertyName - the name of the property, as a String.
Returns:
the value of the property, as an Object, or the value java.awt.Image.UndefinedProperty.
Throws:
IllegalArgumentException - if propertyName is null.

setProperty

public void setProperty(String propertyName,
                        Object propertyValue)
Adds the property value associated with the supplied name to the PropertySource. Values set by this means will supersede any previously defined value of the property.

PropertySourceChangeEvents may be fired with a name set to that of the property (retaining case) and old and new values set to the previous and current values of the property, respectively. The value returned by the getSource() method of the event is determined by the value passed to the constructor of the PropertyChangeSupportJAI parameter. Neither the old nor the new value may be null: undefined properties must as usual be indicated by the constant value java.awt.Image.UndefinedProperty. It is however legal for either but not both of the old and new property values to equal java.awt.Image.UndefinedProperty.

Specified by:
setProperty in interface WritablePropertySource
Parameters:
propertyName - the name of the property, as a String.
propertyValue - the property, as a general Object.
Throws:
IllegalArgumentException - if propertyName or propertyValue is null.

removeProperty

public void removeProperty(String propertyName)
Removes the named property from the PropertySource. PropertySourceChangeEvents may be fired if the property values is actually removed from the name-value mapping. In this case the new value of the property event will be java.awt.Image.UndefinedProperty.
Specified by:
removeProperty in interface WritablePropertySource
Parameters:
propertyName - the name of the property, as a String.
propertyValue - the property, as a general Object.
Throws:
IllegalArgumentException - if propertyName is null.

addProperties

public void addProperties(Map propertyMap)
Copies from the supplied Map to the property set all entries wherein the key is an instance of String or CaselessStringKey. Values set by this means will supersede any previously defined values of the respective properties. All property values are copied by reference. PropertySourceChangeEvents may be fired for each property added. If the property was not previously defined the old value of the property event will be java.awt.Image.UndefinedProperty.
Parameters:
propertyMap - A Map from which to copy properties which have keys which are either Strings or CaselessStringKeys. If null no properties will be added.

addProperties

public void addProperties(PropertySource propertySource)
Adds a PropertySource to the name-PropertySource mapping. The actual property values are not requested at this time but instead an entry for the name of each property emitted by the PropertySource is added to the name-PropertySource mapping. Properties defined by this PropertySource supersede those of all other previously added PropertySources including that specified at construction, if any. Note that this method will not provoke any events as no properties will actually have changed.
Parameters:
propertySource - A PropertySource from which to derive properties. If null nothing is done.

clearProperties

public void clearProperties()
Clears all properties from the PropertySource by invoking removeProperty() with all known names. PropertySourceChangeEvents may be fired for each stored property removed. In this case the new value of the property event will be java.awt.Image.UndefinedProperty.

clearPropertyMap

public void clearPropertyMap()
Clears the name-value mapping of all properties. PropertySourceChangeEvents may be fired for each stored property removed. In this case the new value of the property event will be java.awt.Image.UndefinedProperty.

clearPropertySourceMap

public void clearPropertySourceMap()
Clears the name-PropertySource mapping. No events will be fired.

clearCachedProperties

public void clearCachedProperties()
Clears from the name-value mapping all properties which were derived from a source in the name-PropertySource mapping. PropertySourceChangeEvents may be fired for each stored property removed. In this case the new value of the property event will be java.awt.Image.UndefinedProperty.

removePropertySource

public void removePropertySource(PropertySource propertySource)
Removes from the name-PropertySource mapping all entries which refer to the supplied PropertySource.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

If the property event utility object was not set at construction, then it will be initialized to a PropertyChangeSupportJAI whose property event source is this object.

Specified by:
addPropertyChangeListener in interface PropertyChangeEmitter

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property.

If the property event utility object was not set at construction, then it will be initialized to a PropertyChangeSupportJAI whose property event source is this object.

Specified by:
addPropertyChangeListener in interface PropertyChangeEmitter
Following copied from interface: javax.media.jai.PropertyChangeEmitter
Throws:
IllegalArgumentException - for null propertyName.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

If the property event utility object was not set at construction, then it will be initialized to a PropertyChangeSupportJAI whose property event source is this object.

Specified by:
removePropertyChangeListener in interface PropertyChangeEmitter

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property.

If the property event utility object was not set at construction, then it will be initialized to a PropertyChangeSupportJAI whose property event source is this object.

Specified by:
removePropertyChangeListener in interface PropertyChangeEmitter
Following copied from interface: javax.media.jai.PropertyChangeEmitter
Throws:
IllegalArgumentException - for null propertyName.