Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_data / src / org / gvsig / data / vectorial / AbstractFeatureCollection.java @ 21511

History | View | Annotate | Download (1.47 KB)

1
package org.gvsig.data.vectorial;
2

    
3
import java.util.ConcurrentModificationException;
4
import java.util.Iterator;
5

    
6
import org.gvsig.data.vectorial.visitor.FeaturesVisitor;
7
import org.gvsig.exceptions.BaseException;
8
import org.gvsig.util.observer.Observable;
9

    
10
public abstract class AbstractFeatureCollection implements FeatureCollection{
11

    
12
        protected boolean modified=false;
13
        public void update(Observable obsevable, Object notification) {
14
                if (modified){
15
                        return;
16
                }
17
                String type = ((FeatureStoreNotification)notification).getType();
18
                if (type.equalsIgnoreCase(FeatureStoreNotification.AFTER_INSERT) ||
19
                                type.equalsIgnoreCase(FeatureStoreNotification.AFTER_DELETE) ||
20
                                type.equalsIgnoreCase(FeatureStoreNotification.RESOURCE_CHANGED)){
21
                        modified=true;
22
                }
23
        }
24

    
25
        /*
26
         * (non-Javadoc)
27
         * @see org.gvsig.data.vectorial.visitor.FeaturesVisitable#accept(org.gvsig.data.vectorial.visitor.FeaturesVisitor)
28
         */
29
        public void accept(FeaturesVisitor visitor) throws BaseException {
30
                Iterator iterator=iterator();
31
                while (iterator.hasNext()) {
32
                        Feature feature = (Feature) iterator.next();
33
                        visitor.visit(feature);
34
                }
35
        }
36

    
37
        protected void checkModified() {
38
                if (modified)
39
                        throw new ConcurrentModificationException("FeatureCollection modified");
40
        }
41

    
42
        public boolean isEmpty() {
43
                checkModified();
44
                return (size()==0);
45
        }
46

    
47
        public Feature getFeature(int index) {
48
                // TODO 
49
                throw new UnsupportedOperationException();
50
//                return null;
51
        }
52

    
53

    
54
        
55
}