Statistics
| Revision:

svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libFMap_data / src / org / gvsig / data / vectorial / MemoryFeatureCollection.java @ 21590

History | View | Annotate | Download (3.16 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();//<FeatureID>
10
        protected Iterator iter = null;
11
        protected boolean allowmodify = true;
12

    
13
        public MemoryFeatureCollection() {
14

    
15
        }
16

    
17
        public void rewind() {
18
                checkModified();
19
                iter = null;
20
                allowmodify = true;
21
        }
22

    
23
        public Feature next() {
24
                checkModified();
25
                if( iter == null ) {
26
                        iter = features.iterator();
27
                        allowmodify = false;
28
                }
29
                if( iter.hasNext() ) {
30
                        return (Feature) iter.next();
31
                }
32
                return null;
33
        }
34

    
35
        public int size() {
36
                checkModified();
37
                return features.size();
38
        }
39

    
40
        public boolean add(Feature feature) {
41
                if( !allowmodify ) {
42
                        throw new RuntimeException();
43
                }
44
                checkModified();
45
                return features.add(feature.getID());
46
        }
47

    
48
        public boolean add(FeatureID id) {
49
                if( !allowmodify ) {
50
                        throw new RuntimeException();
51
                }
52
                checkModified();
53
                return features.add(id);
54
        }
55

    
56
        public boolean contains(FeatureID id) {
57
                checkModified();
58
                return features.contains(id);
59
        }
60

    
61
        public boolean contains(Feature feature) {
62
                checkModified();
63
                return features.contains(feature.getID());
64
        }
65

    
66
        public boolean remove(FeatureID id) {
67
                if( !allowmodify ) {
68
                        throw new RuntimeException();
69
                }
70
                checkModified();
71
                return features.remove(id);
72
        }
73

    
74
        public boolean remove(Feature feature) {
75
                if( !allowmodify ) {
76
                        throw new RuntimeException();
77
                }
78
                checkModified();
79
                return features.remove(feature.getID());
80
        }
81

    
82

    
83
        //==============================================
84

    
85

    
86

    
87
        public boolean add(Object arg0) {
88
                throw new RuntimeException();
89
        }
90

    
91
        public boolean addAll(Collection arg0) {
92
                if( !allowmodify ) {
93
                        throw new RuntimeException();
94
                }
95
                checkModified();
96
                return features.addAll(arg0);
97
        }
98

    
99
        public void clear() {
100
                if( !allowmodify ) {
101
                        throw new RuntimeException();
102
                }
103
                checkModified();
104
                features.clear();
105
        }
106

    
107
        public boolean contains(Object arg0) {
108
                checkModified();
109
                return features.contains(arg0);
110
        }
111

    
112
        public boolean containsAll(Collection arg0) {
113
                checkModified();
114
                return features.containsAll(arg0);
115
        }
116

    
117
        public boolean isEmpty() {
118
                checkModified();
119
                return features.isEmpty();
120
        }
121

    
122
        public Iterator iterator() {
123
                checkModified();
124
                return features.iterator();
125
        }
126

    
127
        public boolean remove(Object arg0) {
128
                if( !allowmodify ) {
129
                        throw new RuntimeException();
130
                }
131
                checkModified();
132
                return features.remove(arg0);
133
        }
134

    
135
        public boolean removeAll(Collection arg0) {
136
                if( !allowmodify ) {
137
                        throw new RuntimeException();
138
                }
139
                checkModified();
140
                return features.removeAll(arg0);
141
        }
142

    
143
        public boolean retainAll(Collection arg0) {
144
                if( !allowmodify ) {
145
                        throw new RuntimeException();
146
                }
147
                checkModified();
148
                return features.retainAll(arg0);
149
        }
150

    
151
        public Object[] toArray() {
152
                checkModified();
153
                return features.toArray();
154
        }
155

    
156
        public Object[] toArray(Object[] arg0) {
157
                checkModified();
158
                return features.toArray(arg0);
159
        }
160

    
161
        public void dispose() {
162
                this.features=null;
163
                this.iter = null;
164

    
165
        }
166
}