01: package org.geotools.xml.impl.jxpath;
02:
03: import java.util.List;
04:
05: import org.apache.commons.jxpath.DynamicPropertyHandler;
06: import org.geotools.xml.Node;
07: import org.geotools.xml.impl.NodeImpl;
08:
09: public class NodePropertyHandler implements DynamicPropertyHandler {
10:
11: public Object getProperty(Object object, String property) {
12: Node node = (Node) object;
13: return node.getChildren(property);
14: }
15:
16: public String[] getPropertyNames(Object object) {
17: Node node = (Node) object;
18: List children = node.getChildren();
19:
20: if (children == null || children.isEmpty()) {
21: return new String[] {};
22: }
23:
24: String[] propertyNames = new String[children.size()];
25: for (int i = 0; i < children.size(); i++) {
26: Node child = (Node) children.get(i);
27: propertyNames[i] = child.getComponent().getName();
28: }
29:
30: return propertyNames;
31: }
32:
33: public void setProperty(Object object, String property, Object value) {
34: throw new UnsupportedOperationException();
35: }
36:
37: }
|