Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / DefaultEditableFeature.java @ 28076

History | View | Annotate | Download (5.9 KB)

1 24496 jmvivo
package org.gvsig.fmap.dal.feature.impl;
2 23754 jjdelcerro
3
import java.util.Date;
4 25407 jiyarza
import java.util.Iterator;
5 23754 jjdelcerro
6 24496 jmvivo
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.FeatureData;
10 23754 jjdelcerro
import org.gvsig.fmap.geom.Geometry;
11
12
public class DefaultEditableFeature extends DefaultFeature implements
13
EditableFeature {
14
        private DefaultFeature source;
15
16
        protected DefaultEditableFeature(DefaultFeature feature) {
17
                super(feature);
18
                this.source = feature;
19
        }
20
21
        protected DefaultEditableFeature(DefaultEditableFeature feature) {
22
                super(feature);
23 24658 jjdelcerro
                this.source = (DefaultFeature) feature.getSource();
24 23754 jjdelcerro
        }
25
26 24141 vcaballero
        public DefaultEditableFeature(DefaultFeatureStore store, FeatureData data) {
27
                // Se trata de un editable feature sobre una ya existente
28
                super(store, data);
29 23772 jjdelcerro
                this.source = null;
30
        }
31
32 24658 jjdelcerro
        public Feature getSource() {
33 23754 jjdelcerro
                return this.source;
34
        }
35
36
        public EditableFeature getEditable() {
37
                return this;
38
        }
39
40
        public Feature getCopy() {
41
                return new DefaultEditableFeature(this);
42
        }
43
44
45
        public Feature getNotEditableCopy() {
46
                return new DefaultFeature(this);
47
        }
48
49 23772 jjdelcerro
        public void setDefaultGeometry(Geometry geometry) {
50
                FeatureAttributeDescriptor attribute = this.getType()
51
                                .getAttributeDescriptor(
52
                                                this.getType().getDefaultGeometryAttributeIndex());
53
                this.set(attribute, geometry);
54
        }
55
56 23754 jjdelcerro
        public void set(String name, Object value) {
57
                FeatureAttributeDescriptor attribute = this.getType()
58
                .getAttributeDescriptor(name);
59
                this.set(attribute, value);
60
        }
61
62
        public void set(int index, Object value) {
63
                FeatureAttributeDescriptor attribute = this.getType()
64
                .getAttributeDescriptor(index);
65
                this.set(attribute, value);
66
        }
67
68
        public void setArray(String name, Object[] value) {
69
                FeatureAttributeDescriptor attribute = this.getType()
70
                                .getAttributeDescriptor(name);
71
                this.set(attribute, value);
72
        }
73
74
        public void setArray(int index, Object[] value) {
75
                FeatureAttributeDescriptor attribute = this.getType()
76
                                .getAttributeDescriptor(index);
77
                this.set(attribute, value);
78
        }
79
80
        public void setBoolean(String name, boolean value) {
81
                FeatureAttributeDescriptor attribute = this.getType()
82
                .getAttributeDescriptor(name);
83
                this.set(attribute, Boolean.valueOf(value));
84
        }
85
86
        public void setBoolean(int index, boolean value) {
87
                FeatureAttributeDescriptor attribute = this.getType()
88
                .getAttributeDescriptor(index);
89
                this.set(attribute, Boolean.valueOf(value));
90
        }
91
92
        public void setByte(String name, byte value) {
93
                FeatureAttributeDescriptor attribute = this.getType()
94
                .getAttributeDescriptor(name);
95
                this.set(attribute, Byte.valueOf(value));
96
        }
97
98
        public void setByte(int index, byte value) {
99
                FeatureAttributeDescriptor attribute = this.getType()
100
                .getAttributeDescriptor(index);
101
                this.set(attribute, Byte.valueOf(value));
102
        }
103
104
        public void setDate(String name, Date value) {
105
                FeatureAttributeDescriptor attribute = this.getType()
106
                .getAttributeDescriptor(name);
107
                this.set(attribute, value);
108
        }
109
110
        public void setDate(int index, Date value) {
111
                FeatureAttributeDescriptor attribute = this.getType()
112
                .getAttributeDescriptor(index);
113
                this.set(attribute, value);
114
        }
115
116
        public void setDouble(String name, double value) {
117
                FeatureAttributeDescriptor attribute = this.getType()
118
                .getAttributeDescriptor(name);
119
                this.set(attribute, Double.valueOf(value));
120
        }
121
122
        public void setDouble(int index, double value) {
123
                FeatureAttributeDescriptor attribute = this.getType()
124
                .getAttributeDescriptor(index);
125
                this.set(attribute, Double.valueOf(value));
126
        }
127
128
        public void setFeature(String name, Feature value) {
129
                FeatureAttributeDescriptor attribute = this.getType()
130
                .getAttributeDescriptor(name);
131
                this.set(attribute, value);
132
        }
133
134
        public void setFeature(int index, Feature value) {
135
                FeatureAttributeDescriptor attribute = this.getType()
136
                .getAttributeDescriptor(index);
137
                this.set(attribute, value);
138
        }
139
140
        public void setFloat(String name, float value) {
141
                FeatureAttributeDescriptor attribute = this.getType()
142
                .getAttributeDescriptor(name);
143
                this.set(attribute, Float.valueOf(value));
144
        }
145
146
        public void setFloat(int index, float value) {
147
                FeatureAttributeDescriptor attribute = this.getType()
148
                .getAttributeDescriptor(index);
149
                this.set(attribute, Float.valueOf(value));
150
        }
151
152
        public void setGeometry(String name, Geometry value) {
153
                FeatureAttributeDescriptor attribute = this.getType()
154
                .getAttributeDescriptor(name);
155
                this.set(attribute, value);
156
        }
157
158
        public void setGeometry(int index, Geometry value) {
159
                FeatureAttributeDescriptor attribute = this.getType()
160
                .getAttributeDescriptor(index);
161
                this.set(attribute, value);
162
        }
163
164
        public void setInt(String name, int value) {
165
                FeatureAttributeDescriptor attribute = this.getType()
166
                .getAttributeDescriptor(name);
167
                this.set(attribute, Integer.valueOf(value));
168
        }
169
170
        public void setInt(int index, int value) {
171
                FeatureAttributeDescriptor attribute = this.getType()
172
                .getAttributeDescriptor(index);
173
                this.set(attribute, Integer.valueOf(value));
174
        }
175
176
        public void setLong(String name, long value) {
177
                FeatureAttributeDescriptor attribute = this.getType()
178
                .getAttributeDescriptor(name);
179
                this.set(attribute, Long.valueOf(value));
180
        }
181
182
        public void setLong(int index, long value) {
183
                FeatureAttributeDescriptor attribute = this.getType()
184
                .getAttributeDescriptor(index);
185
                this.set(attribute, Long.valueOf(value));
186
        }
187
188
        public void setString(String name, String value) {
189
                FeatureAttributeDescriptor attribute = this.getType()
190
                .getAttributeDescriptor(name);
191
                this.set(attribute, value);
192
        }
193
194
        public void setString(int index, String value) {
195
                FeatureAttributeDescriptor attribute = this.getType()
196
                .getAttributeDescriptor(index);
197
                this.set(attribute, value);
198
        }
199
200 25407 jiyarza
        public void copyFrom(Feature source) {
201
                // iterate over the attributes and copy one by one
202
                Iterator it = this.getType().iterator();
203
                while( it.hasNext() ) {
204
                        FeatureAttributeDescriptor attr = (FeatureAttributeDescriptor) it.next();
205
                        set(attr.getIndex(), source.get(attr.getIndex()));
206 25609 vcaballero
                }
207 25407 jiyarza
        }
208 23772 jjdelcerro
209
210 23754 jjdelcerro
}