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
ConstructorsModifierConstructorDescriptionprotected
AbstractProperty
(Object sourceBean, String name) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a PropertyChangeListener.abstract void
Adds a VetoableChangeListener.void
This clears the current and previous value without notifying listenersfinal String
getName()
Gets the name of the property.final Object
Gets the source bean of the property.getValue()
Gets the property value.final boolean
Indicates if the property is reporting changes.abstract boolean
Indicates if changes to this property can be vetoed.final void
Reports changes to the Property.void
Removes a PropertyChangeListener.abstract void
Removes a VetoableChangeListener.protected final void
setCurrentValue
(Object newValue) Sets the current value.final void
setReporting
(boolean reportChanges) Enables or disables the reporting of property changes.abstract void
Sets the property value.abstract void
setValueAndNotifyListeners
(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:
getSourceBean
in 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:
addPropertyChangeListener
in interfaceProperty
- Parameters:
listener
- The PropertyChangeListener to add.
-
removePropertyChangeListener
Removes a PropertyChangeListener.- Specified by:
removePropertyChangeListener
in interfaceProperty
- Parameters:
listener
- The PropertyChangeListener to remove.
-
addVetoableChangeListener
public abstract void addVetoableChangeListener(VetoableChangeListener listener) throws UnsupportedOperationException Adds a VetoableChangeListener.- Specified by:
addVetoableChangeListener
in interfaceProperty
- Parameters:
listener
- The VetoableChangeListener to add.- Throws:
UnsupportedOperationException
- This operation is unsupported for this type of Property.
-
removeVetoableChangeListener
Removes a VetoableChangeListener.- Specified by:
removeVetoableChangeListener
in interfaceProperty
- Parameters:
listener
- The VetoableChangeListener to remove.
-
isVetoable
public abstract boolean isVetoable()Indicates if changes to this property can be vetoed.- Specified by:
isVetoable
in 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:
setValueAndNotifyListeners
in 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:
setValue
in 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:
setReporting
in 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:
isReporting
in 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:
notifyListeners
in interfaceProperty
-
clearValue
public void clearValue()This clears the current and previous value without notifying listeners- Specified by:
clearValue
in interfaceProperty
-