|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ValueModel
Describes models with a generic access to a single value that allow
to observe value changes. The value can be accessed using the
#getValue()
/#setValue(Object)
/
#setValueSilently(Object, PropertyChangeListener)
methods. Observers can register instances of PropertyChangeListener
to be notified if the value changes.
The listeners registered with this ValueModel using #addValueChangeListener will be invoked only with PropertyChangeEvents that have the name set to "value".
AbstractValueModel minimizes the effort required to implement this interface. It uses the PropertyChangeSupport to fire PropertyChangeEvents, and it adds PropertyChangeListeners for the specific property name "value". This ensures that the constraint mentioned above is met.
AbstractValueModel
Field Summary | |
---|---|
static String |
VALUE_PROPERTY
The name of the bound property value. |
Method Summary | |
---|---|
void |
addValueChangeListener(PropertyChangeListener listener)
Registers the given PropertyChangeListener with this
ValueModel. |
Object |
getValue()
Returns this model's value. |
void |
removeValueChangeListener(PropertyChangeListener listener)
Deregisters the given PropertyChangeListener from this
ValueModel. |
void |
setValue(Object newValue)
Sets a new value and if the value has changed notifies any registered value change listeners. |
void |
setValueSilently(Object newValue,
PropertyChangeListener listenerToSkip)
Sets a new value and if the value has changed notifies all registered value change listeners except for the specified listener to skip. |
Field Detail |
---|
static final String VALUE_PROPERTY
Method Detail |
---|
Object getValue()
null
or any other appropriate value.
void setValue(Object newValue)
newValue
- the value to be setvoid setValueSilently(Object newValue, PropertyChangeListener listenerToSkip)
newValue
- the value to be setlistenerToSkip
- the PropertyChangeListener
that should
not be notified of this change (may be null
).void addValueChangeListener(PropertyChangeListener listener)
PropertyChangeListener
with this
ValueModel. The listener will be notified if the value has changed.
The PropertyChangeEvents delivered to the listener must have the name
set to "value". The latter ensures that all ValueModel implementers
behave like the AbstractValueModel subclasses.To comply with the above specification implementers can use the PropertyChangeSupport's #addPropertyChangeListener method that accepts a property name, so that listeners will be invoked only if that specific property has changed.
listener
- the listener to be addedAbstractValueModel.addValueChangeListener(PropertyChangeListener)
void removeValueChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from this
ValueModel.
listener
- the listener to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |