Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / DefaultFeatureAttributeDescriptor.java @ 30187

History | View | Annotate | Download (7.92 KB)

1 24496 jmvivo
package org.gvsig.fmap.dal.feature.impl;
2 23754 jjdelcerro
3
import java.text.DateFormat;
4 27439 jmvivo
import java.util.HashMap;
5
import java.util.Iterator;
6
import java.util.Map;
7
import java.util.Map.Entry;
8 23754 jjdelcerro
9 26717 jmvivo
import org.cresques.cts.IProjection;
10 24496 jmvivo
import org.gvsig.fmap.dal.DataTypes;
11
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
12 26790 jmvivo
import org.gvsig.fmap.dal.feature.exception.UnsupportedDataTypeException;
13 23754 jjdelcerro
import org.gvsig.fmap.geom.Geometry;
14 30187 jcarrasco
import org.gvsig.tools.dynobject.DynField;
15
import org.gvsig.tools.dynobject.DynObjectValueItem;
16 23754 jjdelcerro
import org.gvsig.tools.evaluator.Evaluator;
17
18
public class DefaultFeatureAttributeDescriptor implements
19
                FeatureAttributeDescriptor {
20
21
        protected boolean allowNull;
22
        protected int dataType;
23 29033 jmvivo
        protected DateFormat dateFormat;
24 23754 jjdelcerro
        protected Object defaultValue;
25
        protected int index;
26
        protected int maximumOccurrences;
27
        protected int minimumOccurrences;
28
        protected int size;
29
        protected String name;
30
        protected Class objectClass;
31
        protected int precision;
32
        protected Evaluator evaluator;
33
        protected boolean primaryKey;
34
        protected boolean readOnly;
35 26717 jmvivo
        protected IProjection SRS;
36 23754 jjdelcerro
        protected int geometryType;
37 26911 jpiera
        protected int geometrySubType;
38 27439 jmvivo
        protected Map additionalInfo;
39
        protected boolean isAutomatic;
40
41
42 23754 jjdelcerro
        protected DefaultFeatureAttributeDescriptor() {
43 25577 vcaballero
                this.allowNull = true;
44 24421 jmvivo
                this.dataType = DataTypes.UNKNOWN;
45 29033 jmvivo
                this.dateFormat = null;
46 23754 jjdelcerro
                this.defaultValue = null;
47
                this.index = -1;
48
                this.maximumOccurrences = 0;
49
                this.minimumOccurrences = 0;
50
                this.size = 0;
51
                this.name = null;
52
                this.objectClass = null;
53 26220 vcaballero
                this.precision = 0;
54 23754 jjdelcerro
                this.evaluator = null;
55
                this.primaryKey = false;
56
                this.readOnly = false;
57
                this.SRS = null;
58
                this.geometryType = Geometry.TYPES.NULL;
59 26911 jpiera
                this.geometrySubType = Geometry.SUBTYPES.UNKNOWN;
60 27439 jmvivo
                this.additionalInfo = null;
61
                this.isAutomatic = false;
62 23754 jjdelcerro
        }
63
64
        protected DefaultFeatureAttributeDescriptor(
65
                        DefaultFeatureAttributeDescriptor other) {
66
                this.allowNull = other.allowNull;
67
                this.dataType = other.dataType;
68 29033 jmvivo
                this.dateFormat = other.dateFormat;
69 23754 jjdelcerro
                this.defaultValue = other.defaultValue;
70
                this.index = other.index;
71
                this.maximumOccurrences = other.maximumOccurrences;
72
                this.minimumOccurrences = other.minimumOccurrences;
73
                this.size = other.size;
74
                this.name = other.name;
75
                this.objectClass = other.objectClass;
76
                this.precision = other.precision;
77
                this.evaluator = other.evaluator;
78
                this.primaryKey = other.primaryKey;
79
                this.readOnly = other.readOnly;
80
                this.SRS = other.SRS;
81
                this.geometryType = other.geometryType;
82 26911 jpiera
                this.geometrySubType = other.geometrySubType;
83 27439 jmvivo
                if (other.additionalInfo != null) {
84
                        Iterator iter = other.additionalInfo.entrySet().iterator();
85
                        Map.Entry entry;
86
                        this.additionalInfo = new HashMap();
87
                        while (iter.hasNext()) {
88
                                entry = (Entry) iter.next();
89
                                this.additionalInfo.put(entry.getKey(), entry.getValue());
90
                        }
91
                } else {
92
                        this.additionalInfo = null;
93
                }
94
                this.isAutomatic = other.isAutomatic;
95 23754 jjdelcerro
        }
96
97
        public String getDataTypeName() {
98 23894 jjdelcerro
                return DataTypes.TYPE_NAMES[this.getDataType()];
99 23754 jjdelcerro
        }
100
101
        public FeatureAttributeDescriptor getCopy() {
102
                return new DefaultFeatureAttributeDescriptor(this);
103
        }
104
105
        public boolean allowNull() {
106
                return allowNull;
107
        }
108
109
        public int getDataType() {
110
                return this.dataType;
111
        }
112
113
        public DateFormat getDateFormat() {
114 29033 jmvivo
                return this.dateFormat;
115 23754 jjdelcerro
        }
116
117
        public Object getDefaultValue() {
118
                return this.defaultValue;
119
        }
120
121
        public Evaluator getEvaluator() {
122
                return this.evaluator;
123
        }
124
125
        public int getGeometryType() {
126
                return this.geometryType;
127
        }
128
129 26911 jpiera
        public int getGeometrySubType() {
130
                return this.geometrySubType;
131
        }
132
133 23754 jjdelcerro
        public int getIndex() {
134
                return this.index;
135
        }
136
137 25917 jmvivo
        protected FeatureAttributeDescriptor setIndex(int index) {
138
                this.index = index;
139
                return this;
140
        }
141
142 23754 jjdelcerro
        public int getMaximumOccurrences() {
143
                return this.maximumOccurrences;
144
        }
145
146
        public int getMinimumOccurrences() {
147
                return this.minimumOccurrences;
148
        }
149
150
        public String getName() {
151
                return this.name;
152
        }
153
154
        public Class getObjectClass() {
155 30079 jmvivo
                if (this.dataType > DataTypes.TYPE_CLASS.length || this.dataType < 0) {
156 26790 jmvivo
                        throw new UnsupportedDataTypeException(this.name, this.dataType);
157
                }
158 30079 jmvivo
                return DataTypes.TYPE_CLASS[this.dataType];
159 23754 jjdelcerro
        }
160
161
        public int getPrecision() {
162
                return this.precision;
163
        }
164
165 26717 jmvivo
        public IProjection getSRS() {
166 23754 jjdelcerro
                return this.SRS;
167
        }
168
169
        public int getSize() {
170
                return this.size;
171
        }
172
173
        public boolean isPrimaryKey() {
174
                return this.primaryKey;
175
        }
176
177
        public boolean isReadOnly() {
178
                return this.readOnly;
179
        }
180
181 27439 jmvivo
        public Object getAdditionalInfo(String infoName) {
182
                if (this.additionalInfo == null) {
183
                        return null;
184
                }
185
                return this.additionalInfo.get(infoName);
186
        }
187
188
        public boolean isAutomatic() {
189
                return this.isAutomatic;
190
        }
191
192 30187 jcarrasco
193 29033 jmvivo
        private boolean compareObject(Object a, Object b) {
194
                if (a != b) {
195
                        if (a != null) {
196
                                return false;
197
                        }
198
                        return a.equals(b);
199
                }
200
                return true;
201
202
        }
203
204
        public boolean equals(Object obj) {
205
                if (this == obj) {
206
                        return true;
207
                }
208
                if (!(obj instanceof DefaultFeatureAttributeDescriptor)) {
209
                        return false;
210
                }
211
                DefaultFeatureAttributeDescriptor other = (DefaultFeatureAttributeDescriptor) obj;
212
213
                if (this.allowNull != other.allowNull) {
214
                        return false;
215
                }
216
217
                if (this.index != other.index) {
218
                        return false;
219
                }
220
221
                if (!compareObject(this.name, other.name)) {
222
                                return false;
223
                }
224
225
                if (this.dataType != other.dataType) {
226
                        return false;
227
                }
228
229
                if (this.size != other.size) {
230
                        return false;
231
                }
232
233
                if (!compareObject(this.defaultValue, other.defaultValue)) {
234
                        return false;
235
                }
236
237
                if (!compareObject(this.defaultValue, other.defaultValue)) {
238
                        return false;
239
                }
240
241
                if (this.primaryKey != other.primaryKey) {
242
                        return false;
243
                }
244
245
                if (this.isAutomatic != other.isAutomatic) {
246
                        return false;
247
                }
248
249
                if (this.readOnly != other.readOnly) {
250
                        return false;
251
                }
252
253
                if (this.precision != other.precision) {
254
                        return false;
255
                }
256
257
                if (this.maximumOccurrences != other.maximumOccurrences) {
258
                        return false;
259
                }
260
261
                if (this.minimumOccurrences != other.minimumOccurrences) {
262
                        return false;
263
                }
264
                if (this.geometryType != other.geometryType) {
265
                        return false;
266
                }
267
268
                if (this.geometrySubType != other.geometrySubType) {
269
                        return false;
270
                }
271
272
                if (!compareObject(this.evaluator, other.evaluator)) {
273
                        return false;
274
                }
275
276
                if (!compareObject(this.SRS, other.SRS)) {
277
                        return false;
278
                }
279
280
                if (!compareObject(this.dateFormat, other.dateFormat)) {
281
                        return false;
282
                }
283
284
                if (!compareObject(this.objectClass, other.objectClass)) {
285
                        return false;
286
                }
287
288
                return true;
289
        }
290 30187 jcarrasco
291
292
        /**
293
         * Start of DynField interface Implementation
294
         * READONLY
295
         */
296
297
298
        public DynObjectValueItem[] getAvailableValues() {
299
                // TODO Auto-generated method stub
300
                return null;
301
        }
302
303
        public String getDescription() {
304
                // TODO Auto-generated method stub
305
                return null;
306
        }
307
308
        public Object getMaxValue() {
309
                // TODO Auto-generated method stub
310
                return null;
311
        }
312
313
        public Object getMinValue() {
314
                // TODO Auto-generated method stub
315
                return null;
316
        }
317
318
        public int getTheTypeOfAvailableValues() {
319
                // TODO Auto-generated method stub
320
                return 0;
321
        }
322
323
        public int getType() {
324
                return getDataType();
325
        }
326
327
        public boolean isMandatory() {
328
                // TODO Auto-generated method stub
329
                return false;
330
        }
331
332
        public boolean isPersistent() {
333
                // TODO Auto-generated method stub
334
                return false;
335
        }
336
337
        public DynField setAvailableValues(DynObjectValueItem[] values) {
338
                throw new UnsupportedOperationException();
339
        }
340
341
        public DynField setDescription(String description) {
342
                throw new UnsupportedOperationException();
343
        }
344
345
        public DynField setMandatory(boolean mandatory) {
346
                throw new UnsupportedOperationException();
347
        }
348
349
        public DynField setMaxValue(Object maxValue) {
350
                throw new UnsupportedOperationException();
351
        }
352
353
        public DynField setMinValue(Object minValue) {
354
                throw new UnsupportedOperationException();
355
        }
356
357
        public DynField setPersistent(boolean persistent) {
358
                throw new UnsupportedOperationException();
359
        }
360
361
        public DynField setTheTypeOfAvailableValues(int type) {
362
                throw new UnsupportedOperationException();
363
        }
364
365
        public DynField setType(int type) {
366
                throw new UnsupportedOperationException();
367
        }
368
369
        public DynField setDefaultDynValue(Object defaultValue) {
370
                throw new UnsupportedOperationException();
371
        }
372
373 23754 jjdelcerro
}