01: package org.conform;
02:
03: import java.beans.PropertyChangeListener;
04: import java.beans.PropertyChangeEvent;
05:
06: public abstract class PropertyChangeHandler<O> implements
07: PropertyChangeListener {
08: private BeanData beanData;
09: private String propertyName;
10:
11: public final void propertyChange(PropertyChangeEvent evt) {
12: this .beanData = (BeanData) evt.getSource();
13: this .propertyName = evt.getPropertyName();
14: propertyChange((O) evt.getOldValue(), (O) evt.getNewValue());
15: }
16:
17: protected abstract void propertyChange(O oldValue, O newValue);
18:
19: protected BeanData beanData() {
20: return beanData;
21: }
22:
23: protected BeanMeta beanMeta() {
24: return beanData.getBeanMeta();
25: }
26:
27: protected PropertyData propertyData() {
28: return beanData.getPropertyData(beanData.getBeanMeta()
29: .getProperty(propertyName));
30: }
31:
32: protected PropertyMeta propertyMeta() {
33: return beanData.getBeanMeta().getProperty(propertyName);
34: }
35:
36: protected PropertyData propertyData(String propertyName) {
37: return beanData.getPropertyData(beanData.getBeanMeta()
38: .getProperty(propertyName));
39: }
40:
41: protected PropertyMeta propertyMeta(String propertyName) {
42: return beanData.getBeanMeta().getProperty(propertyName);
43: }
44:
45: protected Object get(String propertyName) {
46: return propertyData(propertyName).getValue();
47: }
48:
49: protected void set(String propertyName, Object value) {
50: propertyData(propertyName).setValue(value);
51: }
52: }
|