Methods Summary |
---|
public void | addPropertyChangeListener(java.beans.PropertyChangeListener pcl)Add a non-specific PropertyChangeListener. Adds a listener that will recieve
events on all properties.
synchronized (listenerMap) {
((WeakHashSet)listenerMap.get(ALL_PROPERTIES)).add(pcl);
}
|
public void | addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener pcl)Add a PropertyChangeListener for a specific property.
validateNamedProperty(property);
synchronized (listenerMap) {
((WeakHashSet)listenerMap.get(property)).add(pcl);
}
|
public void | firePropertyChange(java.lang.String property, java.lang.Object old, java.lang.Object neo)Notify listeners that an object type property has changed
PropertyChangeEvent event = new PropertyChangeEvent(producer, property, old, neo);
firePropertyChange(event);
|
public void | firePropertyChange(java.lang.String property, int old, int neo)Shortcut for firing an event on boolean properties.
PropertyChangeEvent event =
new PropertyChangeEvent(producer, property, new Integer(old), new Integer(neo));
firePropertyChange(event);
|
public void | firePropertyChange(java.lang.String property, boolean old, boolean neo)Shortcut for firing an event on boolean properties.
PropertyChangeEvent event =
new PropertyChangeEvent(producer, property, new Boolean(old), new Boolean(neo));
firePropertyChange(event);
|
public void | firePropertyChange(java.beans.PropertyChangeEvent event)Fire a property change event to all of the listeners.
This method is called by all the fire methods to perform the firing of the events.
The firing will go to the listeners that are registered for the specific property
as well as general purpose listeners.
If the old and new values for the event are the same, by the equals()
method, the event will not be fired.
validateNamedProperty(event.getPropertyName());
if (event.getOldValue() == null) {
if (event.getOldValue() == null) {
return;
}
} else if (event.getOldValue()
.equals(event.getNewValue())) {
return;
}
// validated that an event must be thrown; now throw it.
synchronized (listenerMap) {
// First gets the list of listeners and stores them in strong
// references by copying them into a new set.
Set targets = new HashSet((Set)listenerMap.get(ALL_PROPERTIES));
targets.addAll((Set)listenerMap.get(event.getPropertyName()));
// Fire events at the listeners.
Iterator iter = targets.iterator();
while (iter.hasNext()) {
((PropertyChangeListener)iter.next()).propertyChange(event);
}
// Release the strong set so that the weak refs take over again.
}
|
public java.beans.PropertyChangeListener[] | getPropertyChangeListeners()Returns an array of all the listeners that were added to the PropertyChangeSupport
object with addPropertyChangeListener(). The array is computed as late as
possible to give as much cleanout time as neded.
Set all = new WeakHashSet();
PropertyChangeListener[] pcls = new PropertyChangeListener[0];
synchronized (listenerMap) {
Iterator iter = listenerMap.values()
.iterator();
while (iter.hasNext()) {
all.addAll((Set)iter.next());
}
}
return (PropertyChangeListener[])all.toArray(pcls);
|
public java.beans.PropertyChangeListener[] | getPropertyChangeListeners(java.lang.String property)Returns an array of all the listeners which have been associated with the named
property.
validateNamedProperty(property);
PropertyChangeListener[] pcls = new PropertyChangeListener[0];
Set namedListeners = null;
synchronized (listenerMap) {
namedListeners = new HashSet((Set)listenerMap.get(property));
}
return (PropertyChangeListener[])namedListeners.toArray(pcls);
|
public boolean | hasListeners(java.lang.String property)Check if there are any listeners interested in a specific property.
validateNamedProperty(property);
synchronized (listenerMap) {
return (!((Set)listenerMap.get(property)).isEmpty());
}
|
public void | removePropertyChangeListener(java.beans.PropertyChangeListener pcl)Remove a PropertyChangeListener from the listener list. This removes a
PropertyChangeListener that was registered for all properties.
synchronized (listenerMap) {
((WeakHashSet)listenerMap.get(ALL_PROPERTIES)).remove(pcl);
}
|
public void | removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener pcl)Remove a PropertyChangeListener for a specific property.
validateNamedProperty(property);
synchronized (listenerMap) {
((WeakHashSet)listenerMap.get(property)).remove(pcl);
}
|
private void | validateNamedProperty(java.lang.String property)Validate that a property name is a member of the producer object.
This is a helper method so that all methods that must validate this need not
replicate the code.
if (!listenerMap.containsKey(property)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Key Set: " + listenerMap.keySet()); //$NON-NLS-1$
}
throw new IllegalArgumentException("The property '" + property //$NON-NLS-1$
+ "' is not a valid property of " //$NON-NLS-1$
+ producer.getClass()
+ ". Valid values = " //$NON-NLS-1$
+ listenerMap.keySet().toString());
}
|