Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / DefaultEditableFeature.java @ 40435

History | View | Annotate | Download (6.65 KB)

1
package org.gvsig.fmap.dal.feature.impl;
2

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

    
6
import org.gvsig.fmap.dal.feature.EditableFeature;
7
import org.gvsig.fmap.dal.feature.Feature;
8
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
9
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
10
import org.gvsig.fmap.geom.Geometry;
11
import org.gvsig.timesupport.Instant;
12
import org.gvsig.timesupport.Interval;
13

    
14
public class DefaultEditableFeature extends DefaultFeature implements
15
EditableFeature {
16
        private DefaultFeature source;
17

    
18
        protected DefaultEditableFeature(DefaultFeature feature) {
19
                super(feature);
20
                this.source = feature;
21
        }
22

    
23
        protected DefaultEditableFeature(DefaultEditableFeature feature) {
24
                super(feature);
25
                this.source = (DefaultFeature) feature.getSource();
26
        }
27

    
28
        public DefaultEditableFeature(DefaultFeatureStore store, FeatureProvider data) {
29
                // Se trata de un editable feature sobre una ya existente
30
                super(store, data);
31
                this.source = null;
32
        }
33

    
34
        public Feature getSource() {
35
                return this.source;
36
        }
37

    
38
        public EditableFeature getEditable() {
39
                return this;
40
        }
41

    
42
        public Feature getCopy() {
43
                return new DefaultEditableFeature(this);
44
        }
45

    
46

    
47
        public Feature getNotEditableCopy() {
48
                return new DefaultFeature(this);
49
        }
50

    
51
        public void setDefaultGeometry(Geometry geometry) {
52
                FeatureAttributeDescriptor attribute = this.getType()
53
                                .getAttributeDescriptor(
54
                                                this.getType().getDefaultGeometryAttributeIndex());
55
                this.set(attribute, geometry);
56
        }
57

    
58
        public void set(String name, Object value) {
59
                FeatureAttributeDescriptor attribute = this.getType()
60
                .getAttributeDescriptor(name);
61
                this.set(attribute, value);
62
        }
63

    
64
        public void set(int index, Object value) {
65
                FeatureAttributeDescriptor attribute = this.getType()
66
                .getAttributeDescriptor(index);
67
                this.set(attribute, value);
68
        }
69

    
70
        public void setArray(String name, Object[] value) {
71
                FeatureAttributeDescriptor attribute = this.getType()
72
                                .getAttributeDescriptor(name);
73
                this.set(attribute, value);
74
        }
75

    
76
        public void setArray(int index, Object[] value) {
77
                FeatureAttributeDescriptor attribute = this.getType()
78
                                .getAttributeDescriptor(index);
79
                this.set(attribute, value);
80
        }
81

    
82
        public void setBoolean(String name, boolean value) {
83
                FeatureAttributeDescriptor attribute = this.getType()
84
                .getAttributeDescriptor(name);
85
                this.set(attribute, Boolean.valueOf(value));
86
        }
87

    
88
        public void setBoolean(int index, boolean value) {
89
                FeatureAttributeDescriptor attribute = this.getType()
90
                .getAttributeDescriptor(index);
91
                this.set(attribute, Boolean.valueOf(value));
92
        }
93

    
94
        public void setByte(String name, byte value) {
95
                FeatureAttributeDescriptor attribute = this.getType()
96
                .getAttributeDescriptor(name);
97
                this.set(attribute, new Byte(value));
98
        }
99

    
100
        public void setByte(int index, byte value) {
101
                FeatureAttributeDescriptor attribute = this.getType()
102
                .getAttributeDescriptor(index);
103
                this.set(attribute, new Byte(value));
104
        }
105

    
106
        public void setDate(String name, Date value) {
107
                FeatureAttributeDescriptor attribute = this.getType()
108
                .getAttributeDescriptor(name);
109
                this.set(attribute, value);
110
        }
111

    
112
        public void setDate(int index, Date value) {
113
                FeatureAttributeDescriptor attribute = this.getType()
114
                .getAttributeDescriptor(index);
115
                this.set(attribute, value);
116
        }
117

    
118
        public void setDouble(String name, double value) {
119
                FeatureAttributeDescriptor attribute = this.getType()
120
                .getAttributeDescriptor(name);
121
                this.set(attribute, new Double(value));
122
        }
123

    
124
        public void setDouble(int index, double value) {
125
                FeatureAttributeDescriptor attribute = this.getType()
126
                .getAttributeDescriptor(index);
127
                this.set(attribute, new Double(value));
128
        }
129

    
130
        public void setFeature(String name, Feature value) {
131
                FeatureAttributeDescriptor attribute = this.getType()
132
                .getAttributeDescriptor(name);
133
                this.set(attribute, value);
134
        }
135

    
136
        public void setFeature(int index, Feature value) {
137
                FeatureAttributeDescriptor attribute = this.getType()
138
                .getAttributeDescriptor(index);
139
                this.set(attribute, value);
140
        }
141

    
142
        public void setFloat(String name, float value) {
143
                FeatureAttributeDescriptor attribute = this.getType()
144
                .getAttributeDescriptor(name);
145
                this.set(attribute, new Float(value));
146
        }
147

    
148
        public void setFloat(int index, float value) {
149
                FeatureAttributeDescriptor attribute = this.getType()
150
                .getAttributeDescriptor(index);
151
                this.set(attribute, new Float(value));
152
        }
153

    
154
        public void setGeometry(String name, Geometry value) {
155
                FeatureAttributeDescriptor attribute = this.getType()
156
                .getAttributeDescriptor(name);
157
                this.set(attribute, value);
158
        }
159

    
160
        public void setGeometry(int index, Geometry value) {
161
                FeatureAttributeDescriptor attribute = this.getType()
162
                .getAttributeDescriptor(index);
163
                this.set(attribute, value);
164
        }
165

    
166
        public void setInt(String name, int value) {
167
                FeatureAttributeDescriptor attribute = this.getType()
168
                .getAttributeDescriptor(name);
169
                this.set(attribute, new Integer(value));
170
        }
171

    
172
        public void setInt(int index, int value) {
173
                FeatureAttributeDescriptor attribute = this.getType()
174
                .getAttributeDescriptor(index);
175
                this.set(attribute, new Integer(value));
176
        }
177

    
178
        public void setLong(String name, long value) {
179
                FeatureAttributeDescriptor attribute = this.getType()
180
                .getAttributeDescriptor(name);
181
                this.set(attribute, new Long(value));
182
        }
183

    
184
        public void setLong(int index, long value) {
185
                FeatureAttributeDescriptor attribute = this.getType()
186
                .getAttributeDescriptor(index);
187
                this.set(attribute, new Long(value));
188
        }
189

    
190
        public void setString(String name, String value) {
191
                FeatureAttributeDescriptor attribute = this.getType()
192
                .getAttributeDescriptor(name);
193
                this.set(attribute, value);
194
        }
195

    
196
        public void setString(int index, String value) {
197
                FeatureAttributeDescriptor attribute = this.getType()
198
                .getAttributeDescriptor(index);
199
                this.set(attribute, value);
200
        }
201

    
202
        public void copyFrom(Feature source) {
203
                // iterate over the attributes and copy one by one
204
                Iterator it = this.getType().iterator();
205
                while( it.hasNext() ) {
206
                        FeatureAttributeDescriptor attr = (FeatureAttributeDescriptor) it.next();
207
                        set(attr.getIndex(), source.get(attr.getIndex()));
208
                }
209
        }
210

    
211
        public void setInstant(String name, Instant value) {
212
                FeatureAttributeDescriptor attribute = this.getType()
213
                .getAttributeDescriptor(name);
214
                this.set(attribute, value);                
215
        }
216

    
217
        public void setInstant(int index, Instant value) {
218
                FeatureAttributeDescriptor attribute = this.getType()
219
                .getAttributeDescriptor(index);
220
                this.set(attribute, value);                        
221
        }
222

    
223
        public void setInterval(String name, Interval value) {
224
                FeatureAttributeDescriptor attribute = this.getType()
225
                .getAttributeDescriptor(name);
226
                this.set(attribute, value);                        
227
        }
228

    
229
        public void setInterval(int index, Interval value) {
230
                FeatureAttributeDescriptor attribute = this.getType()
231
                .getAttributeDescriptor(index);
232
                this.set(attribute, value);                
233
        }
234
}