com.miginfocom.util
Class PropertyConsumerMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.IdentityHashMap
          extended by com.miginfocom.util.PropertyConsumerMap
All Implemented Interfaces:
PropertyConsumer, PropertyProvider, java.io.Serializable, java.lang.Cloneable, java.util.Map

public class PropertyConsumerMap
extends java.util.IdentityHashMap
implements PropertyConsumer

A PropertyConsumer that just transfers the calls to a IdentityHashMap. This class can be used as a fast storage of properties.

It does never fire any events no matter what fireChangeEvent) is.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
PropertyConsumerMap()
           
PropertyConsumerMap(int expectedMaxSize)
           
 
Method Summary
 boolean containsProperty(PropertyKey property)
          Return if the provider contains the property.
 java.lang.Object getProperty(PropertyKey property)
          Returns the property for a name.
 java.lang.Object removeProperty(PropertyKey property, java.lang.Boolean fireChangeEvent)
          Removes the property.
 java.lang.Object removePropertySilent(PropertyKey property, java.lang.Boolean fireChangeEvent)
          Convenience method for PropertyConsumer.removeProperty(com.miginfocom.util.PropertyKey, Boolean) that catches the PropertyVetoException.
 java.lang.Object setProperty(PropertyKey property, java.lang.Object prop, java.lang.Boolean fireChangeEvent)
          Sets a property for this object.
 java.lang.Object setPropertySilent(PropertyKey property, java.lang.Object prop, java.lang.Boolean fireChangeEvent)
          Convenience method for PropertyConsumer.setProperty(com.miginfocom.util.PropertyKey, Object, Boolean) that catches the PropertyVetoException.
 
Methods inherited from class java.util.IdentityHashMap
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyConsumerMap

public PropertyConsumerMap()

PropertyConsumerMap

public PropertyConsumerMap(int expectedMaxSize)
Method Detail

setProperty

public java.lang.Object setProperty(PropertyKey property,
                                    java.lang.Object prop,
                                    java.lang.Boolean fireChangeEvent)
                             throws java.beans.PropertyVetoException
Description copied from interface: PropertyConsumer
Sets a property for this object.

Note that if the PropertyKey defines a value class type it should be checked in this setter and an ClassCastException is thrown if prop the wrong class type.

Specified by:
setProperty in interface PropertyConsumer
Parameters:
property - The property key that denotes the property. Not null.
prop - The property to set for this object.
fireChangeEvent - If Boolean.TRUE fires a change event. If Boolean.FALSE don't fire and if null the old and new object is checked for equality (with .equals()) and fires a change if they differ.
Returns:
The old object, may be null.
Throws:
java.beans.PropertyVetoException - If the property couldn't be set on this for some reason.

setPropertySilent

public java.lang.Object setPropertySilent(PropertyKey property,
                                          java.lang.Object prop,
                                          java.lang.Boolean fireChangeEvent)
Description copied from interface: PropertyConsumer
Convenience method for PropertyConsumer.setProperty(com.miginfocom.util.PropertyKey, Object, Boolean) that catches the PropertyVetoException.

It is required that this method is implemented in the PropertyConsumer.setProperty(com.miginfocom.util.PropertyKey, Object, Boolean).

Note that if the PropertyKey defines a value class type it should be checked in this setter and an ClassCastException is thrown if prop the wrong class type.

Specified by:
setPropertySilent in interface PropertyConsumer
Parameters:
property - The property key that denotes the property. Not null.
prop - The property to set for this object.
fireChangeEvent - If Boolean.TRUE fires a change event. If Boolean.FALSE don't fire and if null the old and new object is checked for equality (with .equals()) and fires a change if they differ.
Returns:
The old object, may be null.

getProperty

public java.lang.Object getProperty(PropertyKey property)
Description copied from interface: PropertyProvider
Returns the property for a name.

Specified by:
getProperty in interface PropertyProvider
Parameters:
property - The property key for the property to return. Not null.
Returns:
The value, may be null.

containsProperty

public boolean containsProperty(PropertyKey property)
Description copied from interface: PropertyProvider
Return if the provider contains the property.

Specified by:
containsProperty in interface PropertyProvider
Parameters:
property - The property key. Not null.
Returns:
If the provider contains the property.

removeProperty

public java.lang.Object removeProperty(PropertyKey property,
                                       java.lang.Boolean fireChangeEvent)
                                throws java.beans.PropertyVetoException
Description copied from interface: PropertyConsumer
Removes the property.

Specified by:
removeProperty in interface PropertyConsumer
Parameters:
property - The property key that denotes the property. Not null.
fireChangeEvent - If Boolean.TRUE fires a change event. If Boolean.FALSE don't fire and if null fires a change if the key existed before this call.
Returns:
The Old object. null both is null was stored or if the key did not exist in the provider.
Throws:
java.beans.PropertyVetoException - If the property couldn't be set on this for some reason.

removePropertySilent

public java.lang.Object removePropertySilent(PropertyKey property,
                                             java.lang.Boolean fireChangeEvent)
Description copied from interface: PropertyConsumer
Convenience method for PropertyConsumer.removeProperty(com.miginfocom.util.PropertyKey, Boolean) that catches the PropertyVetoException.

It is required that this method is implemented in the PropertyConsumer.setProperty(com.miginfocom.util.PropertyKey, Object, Boolean).

Specified by:
removePropertySilent in interface PropertyConsumer
Parameters:
property - The property key that denotes the property. Not null.
fireChangeEvent - If Boolean.TRUE fires a change event. If Boolean.FALSE don't fire and if null fires a change if the key existed before this call.
Returns:
The Old object. null both is null was stored or if the key did not exist in the provider.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.