Version: 1.1.1

org.biomoby.service.dashboard
Class PropertyChannel

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable
          extended by org.biomoby.service.dashboard.PropertyChannel
All Implemented Interfaces:
Serializable, Cloneable, Map

public class PropertyChannel
extends Hashtable

PropertyChannel is a shared storage for properties created by panels and their models. It is a Hashtable but extends it because whenever a value is created or updated, it also fires an event to inform about it its listeners. In other words, this channel provides its stored properties in two ways:

Additionally, it also serves as a PropertyChangeSupport object: it can register and deregister PropertyChangeListeners, and it can fire an event to them on behave of other objects. The other objects either identify themselves (see method fire(Object,String,Object)), or use this channel for firing anonymous messages (see method fire(String,Object)) - in which case the message source will be this class.

The fired events are stored here under their names. That means that you can always get the last event of a particular name.

The panels/models are sending here properties by calling method put. If we find, in the future, that sending properties here is better to do by listening to them (being a property change listener) we may re-consider this desision. At the moment, I do not see any advantage of it.

Concrete property names are of no interest for this class, but it is good to remind that they should be collected in the class DashboardProperties.

Version:
$Id: PropertyChannel.java,v 1.12 2006/02/19 18:42:55 senger Exp $
Author:
Martin Senger
See Also:
Serialized Form

Constructor Summary
PropertyChannel()
          Default constructor.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Register listeners.
 void fire(Object source, String key, Object value)
          Fire an event to any registered listeners.
 void fire(String key, Object value)
          Fire an event to any registered listeners.
 boolean getBoolean(Object key, boolean defaultValue)
           
 String getString(Object key)
           
 Object put(Object key, Object value)
          Maps the specified key to the specified value in this hashtable.
 Object put(Object source, Object key, Object value)
          Maps the specified key to the specified value in this hashtable.
 void removePropertyChangeListener(PropertyChangeListener l)
          Unregister listeners.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyChannel

public PropertyChannel()
Default constructor.

Method Detail

put

public Object put(Object key,
                  Object value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

The given value, apart from being stored, is also propagated by firing a property change event (this is called a channel push style). The event is anonymous. If you need to send the source of the message to the listeners, use instead put(Object,Object,Object).

Specified by:
put in interface Map
Overrides:
put in class Hashtable
Parameters:
key - the hashtable key
value - the value
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one

put

public Object put(Object source,
                  Object key,
                  Object value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

The given value, apart from being stored, is also propagated by firing a property change event (this is called a channel push style). The event contains also its 'source'. For anonymously sent events, use instead put(Object,Object).

Parameters:
source - that initiated this event
key - the hashtable key
value - the value
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one

getString

public String getString(Object key)

getBoolean

public boolean getBoolean(Object key,
                          boolean defaultValue)

fire

public void fire(String key,
                 Object value)
Fire an event to any registered listeners. The source of this event will be this class.

Parameters:
key - is a name of the fired event
value - is a value associated with this event

fire

public void fire(Object source,
                 String key,
                 Object value)
Fire an event to any registered listeners. The source of this event will be this class.

Parameters:
source - that initiated the event
key - is a name of the fired event
value - is a value associated with this event

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Register listeners.


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Unregister listeners.


Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010