01: package org.conform;
02:
03: import java.beans.PropertyChangeListener;
04: import java.beans.PropertyChangeEvent;
05:
06: public abstract class BeanChangeHandler 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(propertyName, evt.getOldValue(), evt
15: .getNewValue());
16: }
17:
18: protected abstract void propertyChange(String propertyName,
19: Object oldValue, Object newValue);
20:
21: protected BeanData beanData() {
22: return beanData;
23: }
24:
25: protected BeanMeta beanMeta() {
26: return beanData.getBeanMeta();
27: }
28:
29: protected PropertyData propertyData() {
30: return beanData.getPropertyData(beanData.getBeanMeta()
31: .getProperty(propertyName));
32: }
33:
34: protected PropertyMeta propertyMeta() {
35: return beanData.getBeanMeta().getProperty(propertyName);
36: }
37:
38: protected PropertyData propertyData(String propertyName) {
39: return beanData.getPropertyData(beanData.getBeanMeta()
40: .getProperty(propertyName));
41: }
42:
43: protected PropertyMeta propertyMeta(String propertyName) {
44: return beanData.getBeanMeta().getProperty(propertyName);
45: }
46:
47: protected Object get(String propertyName) {
48: return propertyData(propertyName).getValue();
49: }
50:
51: protected void set(String propertyName, Object value) {
52: propertyData(propertyName).setValue(value);
53: }
54: }
|