root / trunk / libraries / libDataSourceDBBaseDrivers / src / org / gvsig / data / datastores / vectorial / driver / jdbc / hsqldb / HSQLDBFeatureCollectionWithFeatureID.java @ 19610
History | View | Annotate | Download (2.29 KB)
1 |
package org.gvsig.data.datastores.vectorial.driver.jdbc.hsqldb; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.Collection; |
5 |
import java.util.Iterator; |
6 |
|
7 |
import org.gvsig.data.ComplexObservable; |
8 |
import org.gvsig.data.exception.ReadException; |
9 |
import org.gvsig.data.vectorial.AbstractFeatureCollection; |
10 |
import org.gvsig.data.vectorial.IFeature; |
11 |
import org.gvsig.data.vectorial.IFeatureID; |
12 |
import org.gvsig.data.vectorial.IFeatureType; |
13 |
|
14 |
public class HSQLDBFeatureCollectionWithFeatureID extends AbstractFeatureCollection { |
15 |
protected ComplexObservable observable = new ComplexObservable(); |
16 |
protected ArrayList featureIDs=new ArrayList();//<IFeatureID> |
17 |
protected IFeatureType featureType;
|
18 |
|
19 |
public HSQLDBFeatureCollectionWithFeatureID(IFeatureType type, String filter, String order) { |
20 |
this.featureType=type;
|
21 |
} |
22 |
public int size() { |
23 |
return featureIDs.size();
|
24 |
} |
25 |
|
26 |
public boolean isEmpty() { |
27 |
return featureIDs.isEmpty();
|
28 |
} |
29 |
|
30 |
public boolean contains(Object o) { |
31 |
return featureIDs.contains(o);
|
32 |
} |
33 |
|
34 |
public Iterator iterator() { |
35 |
DBFIterator dbfIter=new DBFIterator();
|
36 |
return dbfIter;
|
37 |
} |
38 |
|
39 |
public Object[] toArray() { |
40 |
return featureIDs.toArray();
|
41 |
} |
42 |
|
43 |
public Object[] toArray(Object[] a) { |
44 |
return featureIDs.toArray(a);
|
45 |
} |
46 |
|
47 |
public boolean add(Object o) { |
48 |
return featureIDs.add((IFeatureID)o);
|
49 |
} |
50 |
|
51 |
public boolean remove(Object o) { |
52 |
return featureIDs.remove(o);
|
53 |
} |
54 |
|
55 |
public boolean containsAll(Collection c) { |
56 |
return featureIDs.containsAll(c);
|
57 |
} |
58 |
|
59 |
public boolean addAll(Collection c) { |
60 |
return featureIDs.addAll(c);
|
61 |
} |
62 |
|
63 |
public boolean removeAll(Collection c) { |
64 |
return featureIDs.removeAll(c);
|
65 |
} |
66 |
|
67 |
public boolean retainAll(Collection c) { |
68 |
return featureIDs.retainAll(c);
|
69 |
} |
70 |
|
71 |
public void clear() { |
72 |
featureIDs.clear(); |
73 |
} |
74 |
|
75 |
private class DBFIterator implements Iterator{ |
76 |
private int position=0; |
77 |
public DBFIterator(){
|
78 |
position=0;
|
79 |
} |
80 |
public boolean hasNext() { |
81 |
return position<featureIDs.size();
|
82 |
} |
83 |
|
84 |
public Object next() { |
85 |
IFeature feature; |
86 |
try {
|
87 |
feature = ((IFeatureID)featureIDs.get(position)).getFeature(featureType); |
88 |
} catch (ReadException e) {
|
89 |
throw new RuntimeException(e); |
90 |
} |
91 |
position++; |
92 |
return feature;
|
93 |
} |
94 |
|
95 |
public void remove() { |
96 |
featureIDs.remove(position); |
97 |
} |
98 |
|
99 |
} |
100 |
|
101 |
} |