Statistics
| Revision:

root / trunk / libraries / libDataSource / src / org / gvsig / data / vectorial / MemoryFeature.java @ 20599

History | View | Annotate | Download (2.14 KB)

1
package org.gvsig.data.vectorial;
2

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

    
6
import org.gvsig.data.exception.DataException;
7
import org.gvsig.data.exception.InitializeException;
8
import org.gvsig.data.exception.ReadException;
9
import org.gvsig.data.spatialprovisional.IExtent;
10

    
11
public class MemoryFeature extends Feature implements IFeature {
12

    
13
        /**
14
         *
15
         */
16
        private static final long serialVersionUID = 5866395773511247527L;
17

    
18
        public MemoryFeature(IFeature feature) throws ReadException {
19
                super(feature.getType(),false);
20

    
21
                Iterator iter=this.featureType.iterator();
22

    
23
                Object value;
24
                IFeatureAttributeDescriptor featureAttribute;
25
                int column;
26
                this.loading();
27
                while(iter.hasNext()){
28
                        featureAttribute=(IFeatureAttributeDescriptor)iter.next();
29
                        column=((DefaultAttributeDescriptor)featureAttribute).originalPosition();
30
                        value=feature.get(column);
31
                        try {
32
                        if (featureAttribute.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){
33
                                //TODO: Falta clonar geometria
34
                                this.setGeometry(column, value);
35

    
36
                        }else if (featureAttribute.equals(IFeatureAttributeDescriptor.TYPE_OBJECT)){
37
                                //TODO falta clonar el objeto
38
//                                ((Cloneable)get(i)).clo
39
//                                set(i,.);
40
                        }else {
41
                                this.set(column, value);
42
                        }
43
                        } catch (IsNotFeatureSettingException e){
44
                                throw new InitializeException("Feature",e);
45
                        }
46

    
47
                }
48
                this.stopLoading();
49

    
50

    
51
        }
52

    
53
        public MemoryFeature(IFeatureType type,boolean defaultValues) throws ReadException {
54
                super(type,defaultValues);
55
        }
56

    
57
        public IFeatureID getID() {
58
                return new MemoryFeatureID(this);
59
        }
60

    
61
        public IExtent getExtent() {
62
                String geomColumn=featureType.getDefaultGeometry();
63
                Object geometry=getGeometry(geomColumn);
64
//                return geometry.getExtent();
65
                return null;
66
        }
67

    
68
        public List getAllSRS() {
69
                // TODO Auto-generated method stub
70
                return null;
71
        }
72

    
73
        public String getDefaultSRS() {
74
                // TODO Auto-generated method stub
75
                return null;
76
        }
77

    
78
        public void loading() {
79
                super.loading();
80
        }
81
        public void stopLoading(){
82
                super.stopLoading();
83
        }
84

    
85
        protected IFeature cloneFeature() throws DataException {
86
                return new MemoryFeature(this);
87
        }
88

    
89
}