java.beans
Class VetoableChangeSupport
- Serializable
VetoableChangeSupport makes it easy to fire vetoable change events and
handle listeners. It allows chaining of listeners, as well as filtering
by property name. In addition, it will serialize only those listeners
which are serializable, ignoring the others without problem. This class
is thread-safe.
void | addVetoableChangeListener(VetoableChangeListener l) - Adds a VetoableChangeListener to the list of global listeners.
|
void | addVetoableChangeListener(String propertyName, VetoableChangeListener l) - Adds a VetoableChangeListener listening on the specified property.
|
void | fireVetoableChange(PropertyChangeEvent event) - Fire a PropertyChangeEvent to all the global listeners, and to all the
listeners for the specified property name.
|
void | fireVetoableChange(String propertyName, boolean oldVal, boolean newVal) - Fire a PropertyChangeEvent containing the old and new values of the
property to all the global listeners, and to all the listeners for the
specified property name.
|
void | fireVetoableChange(String propertyName, int oldVal, int newVal) - Fire a PropertyChangeEvent containing the old and new values of the
property to all the global listeners, and to all the listeners for the
specified property name.
|
void | fireVetoableChange(String propertyName, Object oldVal, Object newVal) - Fire a PropertyChangeEvent containing the old and new values of the
property to all the global listeners, and to all the listeners for the
specified property name.
|
VetoableChangeListener[] | getVetoableChangeListeners() - Returns an array of all registered vetoable change listeners.
|
VetoableChangeListener[] | getVetoableChangeListeners(String propertyName) - Returns an array of all vetoable change listeners registered under the
given property name.
|
boolean | hasListeners(String propertyName) - Tell whether the specified property is being listened on or not.
|
void | removeVetoableChangeListener(VetoableChangeListener l) - Removes a VetoableChangeListener from the list of global listeners.
|
void | removeVetoableChangeListener(String propertyName, VetoableChangeListener l) - Removes a VetoableChangeListener from listening to a specific property.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
VetoableChangeSupport
public VetoableChangeSupport(Object source)
Create a VetoableChangeSupport to work with a specific source bean.
source
- the source bean to use
addVetoableChangeListener
public void addVetoableChangeListener(VetoableChangeListener l)
Adds a VetoableChangeListener to the list of global listeners. All
vetoable change events will be sent to this listener. The listener add
is not unique: that is, n adds with the same listener will
result in n events being sent to that listener for every
vetoable change. This method will unwrap a VetoableChangeListenerProxy,
registering the underlying delegate to the named property list.
l
- the listener to add (null
ignored).
addVetoableChangeListener
public void addVetoableChangeListener(String propertyName,
VetoableChangeListener l)
Adds a VetoableChangeListener listening on the specified property. Events
will be sent to the listener only if the property name matches. The
listener add is not unique; that is, n adds on a particular
property for a particular listener will result in n events
being sent to that listener when that property is changed. The effect is
cumulative, too; if you are registered to listen to receive events on
all vetoable changes, and then you register on a particular property,
you will receive change events for that property twice. This method
will unwrap a VetoableChangeListenerProxy, registering the underlying
delegate to the named property list if the names match, and discarding
it otherwise.
propertyName
- the name of the property to listen onl
- the listener to add
fireVetoableChange
public void fireVetoableChange(PropertyChangeEvent event)
throws PropertyVetoException
Fire a PropertyChangeEvent to all the global listeners, and to all the
listeners for the specified property name. This does nothing if old and
new values of the event are equal. If the change is vetoed, a new event
is fired to notify listeners about the rollback before the exception is
thrown.
event
- the event to fire
fireVetoableChange
public void fireVetoableChange(String propertyName,
boolean oldVal,
boolean newVal)
throws PropertyVetoException
Fire a PropertyChangeEvent containing the old and new values of the
property to all the global listeners, and to all the listeners for the
specified property name. This does nothing if old and new are equal.
If the change is vetoed, a new event is fired to notify listeners about
the rollback before the exception is thrown.
propertyName
- the name of the property that changedoldVal
- the old valuenewVal
- the new value
fireVetoableChange
public void fireVetoableChange(String propertyName,
int oldVal,
int newVal)
throws PropertyVetoException
Fire a PropertyChangeEvent containing the old and new values of the
property to all the global listeners, and to all the listeners for the
specified property name. This does nothing if old and new are equal.
If the change is vetoed, a new event is fired to notify listeners about
the rollback before the exception is thrown.
propertyName
- the name of the property that changedoldVal
- the old valuenewVal
- the new value
fireVetoableChange
public void fireVetoableChange(String propertyName,
Object oldVal,
Object newVal)
throws PropertyVetoException
Fire a PropertyChangeEvent containing the old and new values of the
property to all the global listeners, and to all the listeners for the
specified property name. This does nothing if old and new are non-null
and equal. If the change is vetoed, a new event is fired to notify
listeners about the rollback before the exception is thrown.
propertyName
- the name of the property that changedoldVal
- the old valuenewVal
- the new value
getVetoableChangeListeners
public VetoableChangeListener[] getVetoableChangeListeners()
Returns an array of all registered vetoable change listeners. Those that
were registered under a name will be wrapped in a
VetoableChangeListenerProxy
, so you must check whether the
listener is an instance of the proxy class in order to see what name the
real listener is registered under. If there are no registered listeners,
this returns an empty array.
- the array of registered listeners
getVetoableChangeListeners
public VetoableChangeListener[] getVetoableChangeListeners(String propertyName)
Returns an array of all vetoable change listeners registered under the
given property name. If there are no registered listeners, this returns
an empty array.
- the array of registered listeners
hasListeners
public boolean hasListeners(String propertyName)
Tell whether the specified property is being listened on or not. This
will only return true
if there are listeners on all
properties or if there is a listener specifically on this property.
propertyName
- the property that may be listened on
- whether the property is being listened on
removeVetoableChangeListener
public void removeVetoableChangeListener(VetoableChangeListener l)
Removes a VetoableChangeListener from the list of global listeners. If
any specific properties are being listened on, they must be deregistered
by themselves; this will only remove the general listener to all
properties. If add()
has been called multiple times for a
particular listener, remove()
will have to be called the
same number of times to deregister it. This method will unwrap a
VetoableChangeListenerProxy, removing the underlying delegate from the
named property list.
l
- the listener to remove
removeVetoableChangeListener
public void removeVetoableChangeListener(String propertyName,
VetoableChangeListener l)
Removes a VetoableChangeListener from listening to a specific property.
If add()
has been called multiple times for a particular
listener on a property, remove()
will have to be called the
same number of times to deregister it. This method will unwrap a
VetoableChangeListenerProxy, removing the underlying delegate from the
named property list if the names match.
propertyName
- the property to stop listening onl
- the listener to remove
VetoableChangeSupport.java -- support to manage vetoable change listeners
Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006,
Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.