Statistics
| Revision:

root / trunk / libraries / libDataSource / src / org / gvsig / data / vectorial / expansionadapter / EditingFeatureCollection.java @ 19399

History | View | Annotate | Download (2.42 KB)

1
package org.gvsig.data.vectorial.expansionadapter;
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.IDataCollection;
9
import org.gvsig.data.IObservable;
10
import org.gvsig.data.vectorial.IFeature;
11
import org.gvsig.data.vectorial.IFeatureCollection;
12
import org.gvsig.data.vectorial.IFeatureID;
13
import org.gvsig.data.vectorial.IFeatureType;
14

    
15
public class EditingFeatureCollection implements IFeatureCollection {
16
        protected ComplexObservable observable = new ComplexObservable();
17
        private ArrayList featureIDs=new ArrayList();//<IFeatureID>
18
        private IFeatureType featureType;
19

    
20
        public EditingFeatureCollection(IDataCollection featureCollection, IDataCollection memoryCollection,IFeatureType featureType) {
21
//                this.addAll(featureCollection);
22
                this.addAll(memoryCollection);
23
                this.featureType=featureType;
24

    
25
        }
26

    
27
        public int size() {
28
                return featureIDs.size();
29
        }
30

    
31
        public boolean isEmpty() {
32
                return featureIDs.isEmpty();
33
        }
34

    
35
        public boolean contains(Object o) {
36
                return featureIDs.contains(o);
37
        }
38

    
39
        public Iterator iterator() {
40
                EditingIterator editingIter=new EditingIterator();
41
                return editingIter;
42
        }
43

    
44
        public Object[] toArray() {
45
                return featureIDs.toArray();
46
        }
47

    
48
        public Object[] toArray(Object[] a) {
49
                return featureIDs.toArray(a);
50
        }
51

    
52
        public boolean add(Object o) {
53
                return featureIDs.add((IFeatureID)o);
54
        }
55

    
56
        public boolean remove(Object o) {
57
                return featureIDs.remove(o);
58
        }
59

    
60
        public boolean containsAll(Collection c) {
61
                return featureIDs.containsAll(c);
62
        }
63

    
64
        public boolean addAll(Collection c) {
65
                return featureIDs.addAll(c);
66
        }
67

    
68
        public boolean removeAll(Collection c) {
69
                return featureIDs.removeAll(c);
70
        }
71

    
72
        public boolean retainAll(Collection c) {
73
                return featureIDs.retainAll(c);
74
        }
75

    
76
        public void clear() {
77
                featureIDs.clear();
78
        }
79

    
80
        public void update(IObservable obsevable, Object notification) {
81
                // TODO Auto-generated method stub
82

    
83
        }
84
        private class EditingIterator implements Iterator{
85
                private int position=0;
86
                public EditingIterator(){
87
                        position=0;
88
                }
89
                public boolean hasNext() {
90
                        return position<featureIDs.size();
91
                }
92

    
93
                public Object next() {
94
                        IFeature feature=((IFeatureID)featureIDs.get(position)).getFeature(featureType);
95
                        position++;
96
                        return feature;
97
                }
98

    
99
                public void remove() {
100
                        featureIDs.remove(position);
101
                }
102

    
103
        }
104
}