Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / feature / Feature.java @ 44669

History | View | Annotate | Download (14.9 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.feature;
25

    
26
import java.math.BigDecimal;
27
import java.util.Date;
28
import java.util.List;
29
import org.cresques.cts.IProjection;
30
import org.gvsig.fmap.dal.exception.DataException;
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.primitive.Envelope;
33
import org.gvsig.timesupport.Instant;
34
import org.gvsig.timesupport.Interval;
35
import org.gvsig.timesupport.Time;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.evaluator.Evaluator;
38
import org.gvsig.tools.evaluator.EvaluatorData;
39
import org.gvsig.tools.util.GetItemByKey;
40

    
41

    
42
/**
43
 * <p>Represents the basic data unit of a tabular structure, equivalent
44
 * to a record in a data base table. In SIG domain, a Feature is a compound
45
 * data structure that may contain a geographic component. The conventional term
46
 * Feature comes from the term cartographic feature and both represent the same
47
 * concept.
48
 * </p>
49
 * <p>
50
 * A Feature may contain more than one geometry attribute. In the case there is not any geometry data,
51
 * the <code>getDefaultGeometry()</code> will return <code>null</code>.
52
 * </p>
53
 * <p>
54
 * Features are not editable as such. To edit a Feature you have to obtain an
55
 * editable instance <code>EditableFeature</code> using the method <code>getEditable()</code>.
56
 * Modify that editable instance and then apply the changes to the Feature. This
57
 * mechanism is to avoid ambiguity and loosing track on the Feature internal state.
58
 * </p>
59
 * <br>
60
 * <p>The Feature:
61
 *   <ul>
62
 *     <li>Has an unique identifier <code>FeatureReference</code>
63
 *     to recognize our Feature from each other from the same data store</li>
64
 *     <li>Has a <code>FeatureType</code> that describes the Feature characteristics (attributes,
65
 *     data types, default geometry, validation rules).</li>
66
 *     <li>Can obtain a copy of itself.</li>
67
 *     <li>Can obtain its default geometry attribute and also a list with all the geometry attributes.</li>
68
 *     <li>Can obtain its default Spatial Reference System and also a list with all the SRSs used in the geometry attributes.</li>
69
 *     <li>Can obtain the envelope (extent) of the default geometry attribute.
70
 *     <li>Can obtain the editable instance of the Feature.</li>
71
 *     <li>Has a set of utility methods to read attributes when their type is known, by both index and name.</li>
72
 *   </ul>
73
 * </p>
74
 *
75
 */
76
public interface Feature extends GetItemByKey<String, Object>{
77

    
78
        /**
79
         * Returns a unique identifier for this Feature in the associated store.
80
         *
81
         * @return
82
         *                 a unique FeatureReference in the associated store
83
         */
84
        public FeatureReference getReference();
85

    
86
        /**
87
         * Returns the FeatureType that describes the structure of this Feature.
88
         *
89
         * @return
90
         *                 a FeatureType describing this Feature structure.
91
         */
92
        public FeatureType getType();
93

    
94
        /**
95
         * Creates and returns a copy of this
96
         *
97
         * @return
98
         *                 a new instance of Feature which is equal to this
99
         */
100
        public Feature getCopy();
101

    
102
        /** Mode that indicates the validation of all FeatureRules */
103
        static final int ALL = 0;
104

    
105
        /** Mode that indicates the validation of the update FeatureRules */
106
        static final int UPDATE = 1;
107

    
108
        /** Mode that indicates the validation of the finish editing FeatureRules */
109
        static final int FINISH_EDITING = 2;
110

    
111
        /**
112
         * Validates this Feature by applying the <code>FeatureRules</code>
113
         * corresponding to the given mode.
114
         *
115
         * @param mode
116
         *                         one of the constants {ALL, UPDATE, FINISH_EDITING}
117
         * @throws DataException on validation errors
118
         */
119
        public void validate(int mode) throws DataException;
120

    
121
        /**
122
         * Returns the editable instance of this Feature.
123
         * EditableFeature offers methods for Feature editing.
124
         *
125
         * @return
126
         *                 EditableFeature of this
127
         */
128
        public EditableFeature getEditable();
129

    
130
        public Object getOrDefault(String name, Object defaultValue);
131
        public String getStringOrDefault(String name, String defaultValue);
132
        public int getIntOrDefault(String name, int defaultValue);
133
        public long getLongOrDefault(String name, long defaultValue);
134
        public float getFloatOrDefault(String name, float defaultValue);
135
        public double getDoubleOrDefault(String name, double defaultValue);
136
        public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue);
137
        public Date getDateOrDefault(String name, Date defaultValue);
138
        
139
        public Object getOrDefault(int index, Object defaultValue);
140
        public String getStringOrDefault(int index, String defaultValue);
141
        public int getIntOrDefault(int index, int defaultValue);
142
        public long getLongOrDefault(int index, long defaultValue);
143
        public float getFloatOrDefault(int index, float defaultValue);
144
        public double getDoubleOrDefault(int index, double defaultValue);
145
        public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue);
146
        public Date getDateOrDefault(int index, Date defaultValue);
147
        
148
        /**
149
         * Returns the value of an attribute given its name.
150
         *
151
         * @param name
152
         *                         a string containing the name of the attribute
153
         * @return
154
         *                 value of the specified attribute
155
         */
156
        @Override
157
        public Object   get(String name);
158

    
159
        /**
160
         * Returns the value of an attribute given its position.
161
         *
162
         * @param index
163
         *                         position of the attribute
164
         * @return
165
         *                 value of the specified attribute
166
         */
167
        public Object   get(int index);
168

    
169
        public boolean isNull(int index);
170
        
171
        public boolean isNull(String name);
172
        
173
        /**
174
         * Returns the int value of an attribute given its name.
175
         *
176
         * @param name
177
         *                         a string containing the name of the attribute
178
         * @return
179
         *                 value of the specified attribute
180
         */
181
        public int      getInt(String name);
182

    
183
        /**
184
         * Returns the int value of an attribute given its position.
185
         *
186
         * @param index
187
         *                         position of the attribute
188
         * @return
189
         *                 value of the specified attribute
190
         */
191
        public int      getInt(int index);
192

    
193
        /**
194
         * Returns the Boolean value of an attribute given its name.
195
         *
196
         * @param name
197
         *                         name of the attribute
198
         * @return
199
         *                 value of the specified attribute
200
         */
201
        public boolean  getBoolean(String name);
202

    
203
        /**
204
         * Returns the Boolean value of an attribute given its position.
205
         *
206
         * @param index
207
         *                         position of the attribute
208
         * @return
209
         *                 value of the specified attribute
210
         */
211
        public boolean  getBoolean(int index);
212

    
213
        /**
214
         * Returns the long value of an attribute given its name.
215
         *
216
         * @param name
217
         *                         name of the attribute
218
         * @return
219
         *                 value of the specified attribute
220
         */
221
        public long     getLong(String name);
222

    
223
        /**
224
         * Returns the long value of an attribute given its position.
225
         *
226
         * @param index
227
         *                         position of the attribute
228
         * @return
229
         *                 value of the specified attribute
230
         */
231
        public long     getLong(int index);
232

    
233
        /**
234
         * Returns the float value of an attribute given its name.
235
         *
236
         * @param name
237
         *                         name of the attribute
238
         * @return
239
         *                 value of the specified attribute
240
         */
241
        public float   getFloat(String name);
242

    
243
        /**
244
         * Returns the float value of an attribute given its position.
245
         *
246
         * @param index
247
         *                         position of the attribute
248
         * @return
249
         *                 value of the specified attribute
250
         */
251
        public float    getFloat(int index);
252

    
253
        /**
254
         * Returns the double value of an attribute given its name.
255
         *
256
         * @param name
257
         *                         name of the attribute
258
         * @return
259
         *                 value of the specified attribute
260
         */
261
        public double  getDouble(String name);
262

    
263
        /**
264
         * Returns the double value of an attribute given its position.
265
         *
266
         * @param index
267
         *                         position of the attribute
268
         * @return
269
         *                 value of the specified attribute
270
         */
271
        public double   getDouble(int index);
272

    
273
        /**
274
         * Returns the BigDecimal value of an attribute given its name.
275
         *
276
         * @param name
277
         *                         name of the attribute
278
         * @return
279
         *                 value of the specified attribute
280
         */
281
        public BigDecimal getDecimal(String name);
282

    
283
        /**
284
         * Returns the BigDecimal value of an attribute given its position.
285
         *
286
         * @param index
287
         *                         position of the attribute
288
         * @return
289
         *                 value of the specified attribute
290
         */
291
        public BigDecimal getDecimal(int index);
292

    
293
        /**
294
         * Returns the Date value of an attribute given its name.
295
         *
296
         * @param name
297
         *                         name of the attribute
298
         * @return
299
         *                 value of the specified attribute
300
         */
301
        public Date    getDate(String name);
302

    
303
        /**
304
         * Returns the Date value of an attribute given its position.
305
         *
306
         * @param index
307
         *                         position of the attribute
308
         * @return
309
         *                 value of the specified attribute
310
         */
311
        public Date     getDate(int index);
312

    
313
        /**
314
         * Returns the String value of an attribute given its name.
315
         *
316
         * @param name
317
         *                         name of the attribute
318
         * @return
319
         *                 value of the specified attribute
320
         */
321
        public String  getString(String name);
322

    
323
        /**
324
         * Returns the String value of an attribute given its position.
325
         *
326
         * @param index
327
         *                         position of the attribute
328
         * @return
329
         *                 value of the specified attribute
330
         */
331
        public String   getString(int index);
332

    
333
        /**
334
         * Returns the byte value of an attribute given its name.
335
         *
336
         * @param name
337
         *                         name of the attribute
338
         * @return
339
         *                 value of the specified attribute
340
         */
341
        public byte    getByte(String name);
342

    
343
        /**
344
         * Returns the byte value of an attribute given its position.
345
         *
346
         * @param index
347
         *                         position of the attribute
348
         * @return
349
         *                 value of the specified attribute
350
         */
351
        public byte     getByte(int index);
352

    
353
        /**
354
         * Returns the Geometry value of an attribute given its name.
355
         *
356
         * @param name
357
         *                         name of the attribute
358
         * @return
359
         *                 value of the specified attribute
360
         */
361
        public Geometry getGeometry(String name);
362

    
363
        /**
364
         * Returns the Geometry value of an attribute given its position.
365
         *
366
         * @param index
367
         *                         position of the attribute
368
         * @return
369
         *                 value of the specified attribute
370
         */
371
        public Geometry getGeometry(int index);
372

    
373
        public byte[] getByteArray(String name);
374

    
375
        public byte[] getByteArray(int index);
376

    
377
        /**
378
         * Returns the array value of an attribute given its name.
379
         *
380
         * @param name
381
         *                         name of the attribute
382
         * @return
383
         *                 value of the specified attribute
384
         */
385
        public Object[] getArray(String name);
386

    
387
        /**
388
         * Returns the array value of an attribute given its position.
389
         *
390
         * @param index
391
         *                         position of the attribute
392
         * @return
393
         *                 value of the specified attribute
394
         */
395
        public Object[] getArray(int index);
396

    
397
        /**
398
         * Returns the Feature value of an attribute given its name.
399
         *
400
         * @param name
401
         *                         name of the attribute
402
         * @return
403
         *                 value of the specified attribute
404
         */
405
        public Feature  getFeature(String name);
406

    
407
        /**
408
         * Returns the Feature value of an attribute given its position.
409
         *
410
         * @param index
411
         *                         position of the attribute
412
         * @return
413
         *                 value of the specified attribute
414
         */
415
        public Feature  getFeature(int index);
416

    
417

    
418
        public Object getFromProfile(int index);
419
        
420
        public Object getFromProfile(String name);
421
        
422
        /**
423
         * Envelope (AKA extent or bounding box) of the default
424
         * geometry attribute.
425
         *
426
         * @return Envelope
427
         *                                 of the default geometry attribute
428
         */
429
        public Envelope getDefaultEnvelope();
430

    
431
        /**
432
         * Returns the value of the default geometry attribute,
433
         * which is a {@link Geometry}.
434
         *
435
         * @return
436
         *                 value of the default geometry attribute
437
         */
438
        public Geometry getDefaultGeometry();
439

    
440
        /**
441
         * Returns a list with the values of this Feature's
442
         * geometry attributes.
443
         *
444
         * @return
445
         *                 a list with the values of this Feature's geometry attributes
446
         */
447
        public List getGeometries();
448

    
449
        /**
450
         * Returns the Spatial Reference System in which is
451
         * expressed the default geometry attribute.
452
         *
453
         * @return
454
         *                 A string containing the default geometry attribute SRS.
455
         */
456
        public IProjection getDefaultSRS();
457

    
458
        /**
459
         * Returns a list with the Spatial Reference Systems in which
460
         * are expressed this Feature's geometry attributes.
461
         *
462
         * @return
463
         *                 a list with the Spatial Reference Systems.
464
         */
465
        public List getSRSs();
466
        
467
        
468
        public Time getDefaultTime();
469
        
470
            public Time getTime(int index);
471
        
472
            public Time getTime(String name);
473
        
474
    /**
475
     * Returns the instant value of an attribute given its position.
476
     *
477
     * @param index
478
     *          position of the attribute
479
     * @return
480
     *      value of the specified attribute
481
     */
482
        public Instant getInstant(int index);
483

    
484
        /**
485
     * Returns the instant value of an attribute given its name.
486
     *
487
     * @param name
488
     *          a string containing the name of the attribute
489
     * @return
490
     *      value of the specified attribute
491
     */
492
        public Instant getInstant(String name);
493

    
494
    /**
495
     * Returns the interval value of an attribute given its position.
496
     *
497
     * @param index
498
     *          position of the attribute
499
     * @return
500
     *      value of the specified attribute
501
     */
502
        public Interval getInterval(int index);
503

    
504
        /**
505
     * Returns the interval value of an attribute given its name.
506
     *
507
     * @param name
508
     *          a string containing the name of the attribute
509
     * @return
510
     *      value of the specified attribute
511
     */
512
        public Interval getInterval(String name);
513

    
514
        public DynObject getAsDynObject();
515
        
516
        /**
517
         * This lets Feature be used eaily with {@link Evaluator}
518
         * 
519
         * @return
520
         *     An instance of {@link EvaluatorData} which returns the data
521
         *     of this feature
522
         */
523
        public EvaluatorData getEvaluatorData();
524
        
525
        /**
526
         * Return the store associated to this feature.
527
         * 
528
         * @return the FeatureStore of the feature.
529
         */
530
        public FeatureStore getStore();
531

    
532
        public String getLabelOfValue(String name);
533

    
534
        public Object getExtraValue(int index);
535
        
536
        public Object getExtraValue(String name);
537

    
538
}