Package ucar.unidata.beans
Class AbstractProperty
java.lang.Object
ucar.unidata.beans.AbstractProperty
- All Implemented Interfaces:
Property
- Direct Known Subclasses:
NonVetoableProperty,VetoableProperty
Provides support for JavaBean properties -- both vetoable and non-vetoable.
This implementation conserves memory by allocating storage for property
change listeners only when the first property change listener is added).
- Version:
- $Id: AbstractProperty.java,v 1.11 2005/05/13 18:28:22 jeffmc Exp $
- Author:
- Steven R. Emmerson
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractProperty(Object sourceBean, String name) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a PropertyChangeListener.abstract voidAdds a VetoableChangeListener.voidThis clears the current and previous value without notifying listenersfinal StringgetName()Gets the name of the property.final ObjectGets the source bean of the property.getValue()Gets the property value.final booleanIndicates if the property is reporting changes.abstract booleanIndicates if changes to this property can be vetoed.final voidReports changes to the Property.voidRemoves a PropertyChangeListener.abstract voidRemoves a VetoableChangeListener.protected final voidsetCurrentValue(Object newValue) Sets the current value.final voidsetReporting(boolean reportChanges) Enables or disables the reporting of property changes.abstract voidSets the property value.abstract voidsetValueAndNotifyListeners(Object newValue) Sets the property value.
-
Constructor Details
-
AbstractProperty
Constructs an instance.- Parameters:
sourceBean- The source bean of the property.name- The name of the property.
-
-
Method Details
-
getSourceBean
Gets the source bean of the property.- Specified by:
getSourceBeanin interfaceProperty- Returns:
- The source bean of the property.
-
getName
Gets the name of the property. -
getValue
Gets the property value. -
addPropertyChangeListener
Adds a PropertyChangeListener.- Specified by:
addPropertyChangeListenerin interfaceProperty- Parameters:
listener- The PropertyChangeListener to add.
-
removePropertyChangeListener
Removes a PropertyChangeListener.- Specified by:
removePropertyChangeListenerin interfaceProperty- Parameters:
listener- The PropertyChangeListener to remove.
-
addVetoableChangeListener
public abstract void addVetoableChangeListener(VetoableChangeListener listener) throws UnsupportedOperationException Adds a VetoableChangeListener.- Specified by:
addVetoableChangeListenerin interfaceProperty- Parameters:
listener- The VetoableChangeListener to add.- Throws:
UnsupportedOperationException- This operation is unsupported for this type of Property.
-
removeVetoableChangeListener
Removes a VetoableChangeListener.- Specified by:
removeVetoableChangeListenerin interfaceProperty- Parameters:
listener- The VetoableChangeListener to remove.
-
isVetoable
public abstract boolean isVetoable()Indicates if changes to this property can be vetoed.- Specified by:
isVetoablein interfaceProperty- Returns:
- True if and only if changes to this property can be vetoed. NB: a VetoableProperty with no registered VetoableChangeListener-s will still return true.
-
setValueAndNotifyListeners
Sets the property value. Will notify any listeners if and only ifisReporting()is true. Will always notify any, registered, VetoableChangeListener-s.- Specified by:
setValueAndNotifyListenersin interfaceProperty- Parameters:
newValue- The new property value.- Throws:
PropertyVetoException- A registered VetoableChangeListener objected to the change. The change was not committed.
-
setValue
Sets the property value. Will not notify any PropertyChangeListener-s but will notify all VetoableChangeListener-s.- Specified by:
setValuein interfaceProperty- Parameters:
newValue- The new property value.- Throws:
PropertyVetoException- A registered VetoableChangeListener objected to the change. The change was not committed.
-
setCurrentValue
Sets the current value. This is the only way to set the value.- Parameters:
newValue- The new property value.
-
setReporting
public final void setReporting(boolean reportChanges) Enables or disables the reporting of property changes.- Specified by:
setReportingin interfaceProperty- Parameters:
reportChanges- Whether to enable or disable property change reporting.
-
isReporting
public final boolean isReporting()Indicates if the property is reporting changes.- Specified by:
isReportingin interfaceProperty- Returns:
- _more_
-
notifyListeners
public final void notifyListeners()Reports changes to the Property. Changes are only actually reported ifisReporting()is true and the current value of the property is not equal to the previously-reported value.- Specified by:
notifyListenersin interfaceProperty
-
clearValue
public void clearValue()This clears the current and previous value without notifying listeners- Specified by:
clearValuein interfaceProperty
-