01: package org.geotools.xml.impl.jxpath;
02:
03: import org.apache.commons.jxpath.ri.model.NodeIterator;
04: import org.apache.commons.jxpath.ri.model.NodePointer;
05: import org.geotools.feature.Feature;
06:
07: /**
08: * Iterates over a single property of a feature.
09: * <p>
10: * Will "iterate" over fid if index is set to -1.
11: * </p>
12: *
13: * @author Justin Deoliveira, The Open Planning Project
14: *
15: */
16: public class SingleFeaturePropertyIterator implements NodeIterator {
17:
18: /**
19: * The feature node pointer
20: */
21: FeaturePointer pointer;
22: /**
23: * The feature.
24: */
25: Feature feature;
26: /**
27: * indedx of property
28: */
29: int index;
30:
31: /**
32: * Creates the iteartor.
33: *
34: * @param pointer The pointer to the feature.
35: * @param index The index of the property to iterate over, or -1 for the feature id.
36: */
37: public SingleFeaturePropertyIterator(FeaturePointer pointer,
38: int index) {
39: this .pointer = pointer;
40: this .index = index;
41: feature = (Feature) pointer.getImmediateNode();
42: }
43:
44: /**
45: * Always return 1, only a single property.
46: */
47: public int getPosition() {
48: return 1;
49: }
50:
51: /**
52: * Return true if position == 1.
53: */
54: public boolean setPosition(int position) {
55: return position < 2;
56: }
57:
58: /**
59: * Return a pointer to the property at the set index.
60: */
61: public NodePointer getNodePointer() {
62: return new FeaturePropertyPointer(pointer, index);
63: }
64:
65: }
|