Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.

JSR 216 (Maintenance Release)

java.beans
Class VetoableChangeSupport

java.lang.Object
  extended byjava.beans.VetoableChangeSupport
All Implemented Interfaces:
Serializable

public class VetoableChangeSupport
extends Object
implements Serializable

This is a utility class that can be used by beans that support constrained properties. You can use an instance of this class as a member field of your bean and delegate various work to it. This class is serializable. When it is serialized it will save (and restore) any listeners that are themselves serializable. Any non-serializable listeners will be skipped during serialization.

See Also:
Serialized Form

Constructor Summary
VetoableChangeSupport(Object sourceBean)
          Constructs a VetoableChangeSupport object.
 
Method Summary
 void addVetoableChangeListener(VetoableChangeListener listener)
          Add a VetoableListener to the listener list.
 void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
          Report a vetoable property update to any registered listeners.
 VetoableChangeListener[] getVetoableChangeListeners()
          Returns the list of VetoableChangeListeners.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Remove a VetoableChangeListener from the listener list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VetoableChangeSupport

public VetoableChangeSupport(Object sourceBean)
Constructs a VetoableChangeSupport object.

Parameters:
sourceBean - The bean to be given as the source for any events.
Method Detail

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Add a VetoableListener to the listener list. The listener is registered for all properties.

Parameters:
listener - The VetoableChangeListener to be added

removeVetoableChangeListener

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

Parameters:
listener - The VetoableChangeListener to be removed

getVetoableChangeListeners

public VetoableChangeListener[] getVetoableChangeListeners()
Returns the list of VetoableChangeListeners.

Returns:
List of VetoableChangeListeners
Since:
1.4

fireVetoableChange

public void fireVetoableChange(String propertyName,
                               Object oldValue,
                               Object newValue)
                        throws PropertyVetoException
Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.

No event is fired if old and new are equal and non-null.

Parameters:
propertyName - The programmatic name of the property that is about to change..
oldValue - The old value of the property.
newValue - The new value of the property.
Throws:
PropertyVetoException - if the recipient wishes the property change to be rolled back.

JSR 216 (Maintenance Release)

Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 216 specification.