ucar.unidata.beans
Class VetoableProperty

java.lang.Object
  extended by ucar.unidata.beans.AbstractProperty
      extended by ucar.unidata.beans.VetoableProperty
All Implemented Interfaces:
Property

public class VetoableProperty
extends AbstractProperty

Provides support for vetoable JavaBean properties. A VetoableProperty is a Property that has the capablity of having changes to its value vetoed by registered VetoableChangeListener-s. This implementation conserves memory by allocating storage for VetoableChangeListeners only when the first one is added to this property.

Version:
$Id: VetoableProperty.java,v 1.7 2005/05/13 18:28:22 jeffmc Exp $
Author:
Steven R. Emmerson

Constructor Summary
VetoableProperty(Object sourceBean, String name)
          Constructs an instance.
 
Method Summary
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds a VetoableChangeListener.
 boolean isVetoable()
          Indicates if changes to this property can be vetoed.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Removes a VetoableChangeListener.
 void setValue(Object newValue)
          Sets the property value.
 void setValueAndNotifyListeners(Object newValue)
          Sets the property value.
 
Methods inherited from class ucar.unidata.beans.AbstractProperty
addPropertyChangeListener, clearValue, getName, getSourceBean, getValue, isReporting, notifyListeners, removePropertyChangeListener, setCurrentValue, setReporting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VetoableProperty

public VetoableProperty(Object sourceBean,
                        String name)
Constructs an instance.

Parameters:
sourceBean - The source Bean of the property.
name - The name of the property.
Method Detail

isVetoable

public boolean isVetoable()
Indicates if changes to this property can be vetoed.

Specified by:
isVetoable in interface Property
Specified by:
isVetoable in class AbstractProperty
Returns:
True; always.

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a VetoableChangeListener.

Specified by:
addVetoableChangeListener in interface Property
Specified by:
addVetoableChangeListener in class AbstractProperty
Parameters:
listener - The VetoableChangeListener to add.

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a VetoableChangeListener.

Specified by:
removeVetoableChangeListener in interface Property
Specified by:
removeVetoableChangeListener in class AbstractProperty
Parameters:
listener - The VetoableChangeListener to remove.

setValueAndNotifyListeners

public void setValueAndNotifyListeners(Object newValue)
                                throws PropertyVetoException
Sets the property value. Will notify any listeners if and only if isReporting() is true. Will always notify all VetoableChangeListener-s.

Specified by:
setValueAndNotifyListeners in interface Property
Specified by:
setValueAndNotifyListeners in class AbstractProperty
Parameters:
newValue - The new property value.
Throws:
PropertyVetoException - A registered VetoableChangeListener objected to the change. The change was not committed.

setValue

public void setValue(Object newValue)
              throws PropertyVetoException
Sets the property value. Will not notify any PropertyChangeListener-s but will notify all VetoableChangeListener-s.

Specified by:
setValue in interface Property
Specified by:
setValue in class AbstractProperty
Parameters:
newValue - The new property value.
Throws:
PropertyVetoException - A registered VetoableChangeListener objected to the change. The change was not committed.