01: package org.geotools.xml.impl;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.geotools.xml.Binding;
07: import org.geotools.xml.ComplexBinding;
08:
09: /**
10: * Gets properties from a parent object by visiting bindings in the hierachy.
11: * The object properties are stored as name, object tuples.
12: *
13: * @author Justin Deoliveira, The Open Planning Project
14: *
15: */
16: public class GetPropertiesExecutor implements BindingWalker.Visitor {
17:
18: /** the parent object */
19: Object parent;
20:
21: /** the properties */
22: List properties;
23:
24: public GetPropertiesExecutor(Object parent) {
25: this .parent = parent;
26: properties = new ArrayList();
27: }
28:
29: public List getProperties() {
30: return properties;
31: }
32:
33: public void visit(Binding binding) {
34:
35: if (binding instanceof ComplexBinding) {
36: ComplexBinding complex = (ComplexBinding) binding;
37:
38: try {
39: List properties = complex.getProperties(parent);
40: if (properties != null) {
41: this .properties.addAll(properties);
42: }
43: } catch (Exception e) {
44: String msg = "Failed to get properties. Binding for "
45: + complex.getTarget();
46: throw new RuntimeException(msg, e);
47: }
48: }
49:
50: }
51:
52: }
|