root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / featureSet / DefaultIterator.java @ 24496
History | View | Annotate | Download (1.74 KB)
1 |
package org.gvsig.fmap.dal.feature.impl.featureSet; |
---|---|
2 |
|
3 |
import java.util.Iterator; |
4 |
|
5 |
import org.gvsig.fmap.dal.exceptions.DataException; |
6 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
7 |
import org.gvsig.fmap.dal.feature.spi.FeatureData; |
8 |
|
9 |
|
10 |
class DefaultIterator implements Iterator { |
11 |
|
12 |
protected Iterator iterator; |
13 |
protected DefaultFeatureSet fset;
|
14 |
|
15 |
public DefaultIterator(DefaultFeatureSet featureSet) {
|
16 |
this.fset = featureSet;
|
17 |
} |
18 |
|
19 |
public DefaultIterator(DefaultFeatureSet featureSet, long index) |
20 |
throws DataException {
|
21 |
this.fset = featureSet;
|
22 |
if (index > 0) { |
23 |
if (featureSet.provider.canIterateFromIndex()) {
|
24 |
try {
|
25 |
this.iterator = featureSet.provider.iterator(index);
|
26 |
} catch (UnsupportedOperationException e) { |
27 |
this.iterator = featureSet.provider.iterator();
|
28 |
skypto(index); |
29 |
} |
30 |
} else {
|
31 |
this.iterator = featureSet.provider.iterator();
|
32 |
skypto(index); |
33 |
} |
34 |
} else {
|
35 |
this.iterator = featureSet.provider.iterator();
|
36 |
} |
37 |
} |
38 |
|
39 |
protected void skypto(long index) { |
40 |
// TODO: Comprobar si esta bien la condicion de n<=
|
41 |
for (long n = 0; n <= index && this.getIterator().hasNext(); n++, this |
42 |
.getIterator() |
43 |
.next()) { |
44 |
; |
45 |
} |
46 |
} |
47 |
|
48 |
public boolean hasNext() { |
49 |
fset.checkModified(); |
50 |
return this.getIterator().hasNext(); |
51 |
} |
52 |
|
53 |
public Object next() { |
54 |
fset.checkModified(); |
55 |
return this.createFeature((FeatureData) this.getIterator().next()); |
56 |
} |
57 |
|
58 |
public void remove() { |
59 |
throw new UnsupportedOperationException(); |
60 |
|
61 |
} |
62 |
|
63 |
protected DefaultFeature createFeature(FeatureData fData) {
|
64 |
return new DefaultFeature(fset.store, fData); |
65 |
} |
66 |
|
67 |
protected Iterator getIterator() { |
68 |
return this.iterator; |
69 |
} |
70 |
|
71 |
protected boolean isDeleted(FeatureData data) { |
72 |
return false; |
73 |
} |
74 |
|
75 |
protected void doNext() throws DataException { |
76 |
|
77 |
} |
78 |
|
79 |
} |