01: package org.geotools.xml.impl.jxpath;
02:
03: import java.util.Locale;
04:
05: import org.apache.commons.jxpath.ri.QName;
06: import org.apache.commons.jxpath.ri.model.NodePointer;
07: import org.apache.commons.jxpath.ri.model.NodePointerFactory;
08: import org.geotools.feature.Feature;
09: import org.geotools.feature.FeatureType;
10:
11: /**
12: * A node factory which creates special node pointers featurs.
13: * <p>
14: * The following types are supported:
15: * <ul>
16: * <li>{@link org.geotools.feature.Feature}
17: * <li>{@link org.geotools.feature.FeatureType}
18: * </ul>
19: * </p>
20: *
21: * @author Justin Deoliveira, The Open Planning Project
22: *
23: */
24: public class FeatureNodeFactory implements NodePointerFactory {
25:
26: public int getOrder() {
27: return 0;
28: }
29:
30: public NodePointer createNodePointer(QName name, Object object,
31: Locale locale) {
32:
33: if (object instanceof Feature) {
34: return new FeaturePointer(null, (Feature) object, name);
35: }
36:
37: if (object instanceof FeatureType) {
38: return new FeatureTypePointer(null, (FeatureType) object,
39: name);
40: }
41:
42: return null;
43: }
44:
45: public NodePointer createNodePointer(NodePointer parent,
46: QName name, Object object) {
47:
48: if (object instanceof Feature) {
49: return new FeaturePointer(parent, (Feature) object, name);
50: }
51:
52: if (object instanceof FeatureType) {
53: return new FeatureTypePointer(null, (FeatureType) object,
54: name);
55: }
56:
57: return null;
58: }
59:
60: }
|