root / branches / Mobile_Compatible_Hito_1 / libFMap / src-data / org / gvsig / data / vectorial / MemoryFeatureCollection.java @ 21606
History | View | Annotate | Download (2.64 KB)
1 |
package org.gvsig.data.vectorial; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.Collection; |
5 |
import java.util.Iterator; |
6 |
|
7 |
public class MemoryFeatureCollection extends AbstractFeatureCollection { |
8 |
|
9 |
protected Collection features = new ArrayList();//<IFeatureID> |
10 |
protected Iterator iter = null; |
11 |
protected boolean allowmodify = true; |
12 |
|
13 |
public MemoryFeatureCollection() {
|
14 |
|
15 |
} |
16 |
|
17 |
public void rewind() { |
18 |
iter = null;
|
19 |
allowmodify = true;
|
20 |
} |
21 |
|
22 |
public IFeature next() {
|
23 |
if( iter == null ) { |
24 |
iter = features.iterator(); |
25 |
allowmodify = false;
|
26 |
} |
27 |
if( iter.hasNext() ) {
|
28 |
return (IFeature) iter.next();
|
29 |
} |
30 |
return null; |
31 |
} |
32 |
|
33 |
public int size() { |
34 |
return features.size();
|
35 |
} |
36 |
|
37 |
public boolean add(IFeature feature) { |
38 |
if( !allowmodify ) {
|
39 |
throw new RuntimeException(); |
40 |
} |
41 |
return features.add(feature.getID());
|
42 |
} |
43 |
|
44 |
public boolean add(IFeatureID id) { |
45 |
if( !allowmodify ) {
|
46 |
throw new RuntimeException(); |
47 |
} |
48 |
return features.add(id);
|
49 |
} |
50 |
|
51 |
public boolean contains(IFeatureID id) { |
52 |
return features.contains(id);
|
53 |
} |
54 |
|
55 |
public boolean contains(IFeature feature) { |
56 |
return features.contains(feature.getID());
|
57 |
} |
58 |
|
59 |
public boolean remove(IFeatureID id) { |
60 |
if( !allowmodify ) {
|
61 |
throw new RuntimeException(); |
62 |
} |
63 |
return features.remove(id);
|
64 |
} |
65 |
|
66 |
public boolean remove(IFeature feature) { |
67 |
if( !allowmodify ) {
|
68 |
throw new RuntimeException(); |
69 |
} |
70 |
return features.remove(feature.getID());
|
71 |
} |
72 |
|
73 |
|
74 |
//==============================================
|
75 |
|
76 |
|
77 |
|
78 |
public boolean add(Object arg0) { |
79 |
throw new RuntimeException(); |
80 |
} |
81 |
|
82 |
public boolean addAll(Collection arg0) { |
83 |
if( !allowmodify ) {
|
84 |
throw new RuntimeException(); |
85 |
} |
86 |
return features.addAll(arg0);
|
87 |
} |
88 |
|
89 |
public void clear() { |
90 |
if( !allowmodify ) {
|
91 |
throw new RuntimeException(); |
92 |
} |
93 |
features.clear(); |
94 |
} |
95 |
|
96 |
public boolean contains(Object arg0) { |
97 |
return features.contains(arg0);
|
98 |
} |
99 |
|
100 |
public boolean containsAll(Collection arg0) { |
101 |
return features.containsAll(arg0);
|
102 |
} |
103 |
|
104 |
public boolean isEmpty() { |
105 |
return features.isEmpty();
|
106 |
} |
107 |
|
108 |
public Iterator iterator() { |
109 |
return features.iterator();
|
110 |
} |
111 |
|
112 |
public boolean remove(Object arg0) { |
113 |
if( !allowmodify ) {
|
114 |
throw new RuntimeException(); |
115 |
} |
116 |
return features.remove(arg0);
|
117 |
} |
118 |
|
119 |
public boolean removeAll(Collection arg0) { |
120 |
if( !allowmodify ) {
|
121 |
throw new RuntimeException(); |
122 |
} |
123 |
return features.removeAll(arg0);
|
124 |
} |
125 |
|
126 |
public boolean retainAll(Collection arg0) { |
127 |
if( !allowmodify ) {
|
128 |
throw new RuntimeException(); |
129 |
} |
130 |
return features.retainAll(arg0);
|
131 |
} |
132 |
|
133 |
public Object[] toArray() { |
134 |
return features.toArray();
|
135 |
} |
136 |
|
137 |
public Object[] toArray(Object[] arg0) { |
138 |
return features.toArray(arg0);
|
139 |
} |
140 |
|
141 |
public void dispose() { |
142 |
this.features=null; |
143 |
this.iter = null; |
144 |
|
145 |
} |
146 |
} |