|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.util.beans.BeanMonitor
public class BeanMonitor
A monitor of beans.
You indicates which properties to monitor (via the constructor). Then attach a bean to monitor via the methodsetBean(Object).
The method clearModified() reset the states about modified
properties.
The method wasModified() tells if there was any modification on
monitored properties for the attached bean since the last call to
clearModified() (or setBean(Object).
the method getModifiedProperties() gives you the names of monitored
properties for the attached bean since the last call to
clearModified() (or setBean(Object).
| Field Summary | |
|---|---|
protected Object |
bean
The bean to monitor. |
protected PropertyChangeListener |
listener
The PropertyChangeListener which listen modification on bean
only on monitored properties. |
protected Set<String> |
modifiedProperties
Names of monitored and modified properties for the attached bean. |
protected Map<String,Object> |
originalValues
To store the original values when watched properties are changing. |
protected List<String> |
propertyNames
Names of properties to watch on attached bean. |
| Constructor Summary | |
|---|---|
BeanMonitor(String... propertyNames)
Constructor of monitor with property names to monitor. |
|
| Method Summary | |
|---|---|
void |
clearModified()
To clear the modified states. |
Object |
getBean()
Obtains the monitored bean. |
String[] |
getModifiedProperties()
Obtains the names of monitored properties which has been touched for the attached bean since last call to clearModified() or
setBean(Object). |
Map<String,Object> |
getOriginalValues()
Obtains the original values for all modified properties. |
void |
setBean(Object bean)
Sets the bean to monitor. |
boolean |
wasModified()
Tells if any of the monitored properties were modified on the attached bean since last call to clearModified() or
setBean(Object). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final List<String> propertyNames
protected final Set<String> modifiedProperties
protected final Map<String,Object> originalValues
protected final PropertyChangeListener listener
PropertyChangeListener which listen modification on bean
only on monitored properties.
protected Object bean
| Constructor Detail |
|---|
public BeanMonitor(String... propertyNames)
propertyNames - the names of properties to monitor| Method Detail |
|---|
public Object getBean()
bean.
null if none attached.public boolean wasModified()
clearModified() or
setBean(Object).
true if there were a modified monitored property on
the attached bean, false otherwise.public String[] getModifiedProperties()
clearModified() or
setBean(Object).
public Map<String,Object> getOriginalValues()
public void setBean(Object bean)
bean to monitor.
As a side effect, it will attach the listener to new bean
(if not null) and remove it from the previous bean attached (if not null).
As a second side effect, it will always clean the modified states,
using the method clearModified().
bean - the new bean to monitorpublic void clearModified()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||