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 @ 44376

History | View | Annotate | Download (14.1 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.util.Date;
27
import java.util.List;
28
import org.cresques.cts.IProjection;
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.fmap.geom.Geometry;
31
import org.gvsig.fmap.geom.primitive.Envelope;
32
import org.gvsig.timesupport.Instant;
33
import org.gvsig.timesupport.Interval;
34
import org.gvsig.timesupport.Time;
35
import org.gvsig.tools.dynobject.DynObject;
36
import org.gvsig.tools.evaluator.Evaluator;
37
import org.gvsig.tools.evaluator.EvaluatorData;
38
import org.gvsig.tools.util.GetItemByKey;
39

    
40

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

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

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

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

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

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

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

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

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

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

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

    
166
        /**
167
         * Returns the int value of an attribute given its name.
168
         *
169
         * @param name
170
         *                         a string containing the name of the attribute
171
         * @return
172
         *                 value of the specified attribute
173
         */
174
        public int      getInt(String name);
175

    
176
        /**
177
         * Returns the int value of an attribute given its position.
178
         *
179
         * @param index
180
         *                         position of the attribute
181
         * @return
182
         *                 value of the specified attribute
183
         */
184
        public int      getInt(int index);
185

    
186
        /**
187
         * Returns the Boolean value of an attribute given its name.
188
         *
189
         * @param name
190
         *                         name of the attribute
191
         * @return
192
         *                 value of the specified attribute
193
         */
194
        public boolean  getBoolean(String name);
195

    
196
        /**
197
         * Returns the Boolean value of an attribute given its position.
198
         *
199
         * @param index
200
         *                         position of the attribute
201
         * @return
202
         *                 value of the specified attribute
203
         */
204
        public boolean  getBoolean(int index);
205

    
206
        /**
207
         * Returns the long value of an attribute given its name.
208
         *
209
         * @param name
210
         *                         name of the attribute
211
         * @return
212
         *                 value of the specified attribute
213
         */
214
        public long     getLong(String name);
215

    
216
        /**
217
         * Returns the long value of an attribute given its position.
218
         *
219
         * @param index
220
         *                         position of the attribute
221
         * @return
222
         *                 value of the specified attribute
223
         */
224
        public long     getLong(int index);
225

    
226
        /**
227
         * Returns the float value of an attribute given its name.
228
         *
229
         * @param name
230
         *                         name of the attribute
231
         * @return
232
         *                 value of the specified attribute
233
         */
234
        public float   getFloat(String name);
235

    
236
        /**
237
         * Returns the float value of an attribute given its position.
238
         *
239
         * @param index
240
         *                         position of the attribute
241
         * @return
242
         *                 value of the specified attribute
243
         */
244
        public float    getFloat(int index);
245

    
246
        /**
247
         * Returns the double value of an attribute given its name.
248
         *
249
         * @param name
250
         *                         name of the attribute
251
         * @return
252
         *                 value of the specified attribute
253
         */
254
        public double  getDouble(String name);
255

    
256
        /**
257
         * Returns the double value of an attribute given its position.
258
         *
259
         * @param index
260
         *                         position of the attribute
261
         * @return
262
         *                 value of the specified attribute
263
         */
264
        public double   getDouble(int index);
265

    
266
        /**
267
         * Returns the Date value of an attribute given its name.
268
         *
269
         * @param name
270
         *                         name of the attribute
271
         * @return
272
         *                 value of the specified attribute
273
         */
274
        public Date    getDate(String name);
275

    
276
        /**
277
         * Returns the Date value of an attribute given its position.
278
         *
279
         * @param index
280
         *                         position of the attribute
281
         * @return
282
         *                 value of the specified attribute
283
         */
284
        public Date     getDate(int index);
285

    
286
        /**
287
         * Returns the String value of an attribute given its name.
288
         *
289
         * @param name
290
         *                         name of the attribute
291
         * @return
292
         *                 value of the specified attribute
293
         */
294
        public String  getString(String name);
295

    
296
        /**
297
         * Returns the String value of an attribute given its position.
298
         *
299
         * @param index
300
         *                         position of the attribute
301
         * @return
302
         *                 value of the specified attribute
303
         */
304
        public String   getString(int index);
305

    
306
        /**
307
         * Returns the byte value of an attribute given its name.
308
         *
309
         * @param name
310
         *                         name of the attribute
311
         * @return
312
         *                 value of the specified attribute
313
         */
314
        public byte    getByte(String name);
315

    
316
        /**
317
         * Returns the byte value of an attribute given its position.
318
         *
319
         * @param index
320
         *                         position of the attribute
321
         * @return
322
         *                 value of the specified attribute
323
         */
324
        public byte     getByte(int index);
325

    
326
        /**
327
         * Returns the Geometry value of an attribute given its name.
328
         *
329
         * @param name
330
         *                         name of the attribute
331
         * @return
332
         *                 value of the specified attribute
333
         */
334
        public Geometry getGeometry(String name);
335

    
336
        /**
337
         * Returns the Geometry value of an attribute given its position.
338
         *
339
         * @param index
340
         *                         position of the attribute
341
         * @return
342
         *                 value of the specified attribute
343
         */
344
        public Geometry getGeometry(int index);
345

    
346
        public byte[] getByteArray(String name);
347

    
348
        public byte[] getByteArray(int index);
349

    
350
        /**
351
         * Returns the array value of an attribute given its name.
352
         *
353
         * @param name
354
         *                         name of the attribute
355
         * @return
356
         *                 value of the specified attribute
357
         */
358
        public Object[] getArray(String name);
359

    
360
        /**
361
         * Returns the array value of an attribute given its position.
362
         *
363
         * @param index
364
         *                         position of the attribute
365
         * @return
366
         *                 value of the specified attribute
367
         */
368
        public Object[] getArray(int index);
369

    
370
        /**
371
         * Returns the Feature value of an attribute given its name.
372
         *
373
         * @param name
374
         *                         name of the attribute
375
         * @return
376
         *                 value of the specified attribute
377
         */
378
        public Feature  getFeature(String name);
379

    
380
        /**
381
         * Returns the Feature value of an attribute given its position.
382
         *
383
         * @param index
384
         *                         position of the attribute
385
         * @return
386
         *                 value of the specified attribute
387
         */
388
        public Feature  getFeature(int index);
389

    
390

    
391
        public Object getFromProfile(int index);
392
        
393
        public Object getFromProfile(String name);
394
        
395
        /**
396
         * Envelope (AKA extent or bounding box) of the default
397
         * geometry attribute.
398
         *
399
         * @return Envelope
400
         *                                 of the default geometry attribute
401
         */
402
        public Envelope getDefaultEnvelope();
403

    
404
        /**
405
         * Returns the value of the default geometry attribute,
406
         * which is a {@link Geometry}.
407
         *
408
         * @return
409
         *                 value of the default geometry attribute
410
         */
411
        public Geometry getDefaultGeometry();
412

    
413
        /**
414
         * Returns a list with the values of this Feature's
415
         * geometry attributes.
416
         *
417
         * @return
418
         *                 a list with the values of this Feature's geometry attributes
419
         */
420
        public List getGeometries();
421

    
422
        /**
423
         * Returns the Spatial Reference System in which is
424
         * expressed the default geometry attribute.
425
         *
426
         * @return
427
         *                 A string containing the default geometry attribute SRS.
428
         */
429
        public IProjection getDefaultSRS();
430

    
431
        /**
432
         * Returns a list with the Spatial Reference Systems in which
433
         * are expressed this Feature's geometry attributes.
434
         *
435
         * @return
436
         *                 a list with the Spatial Reference Systems.
437
         */
438
        public List getSRSs();
439
        
440
        
441
        public Time getDefaultTime();
442
        
443
            public Time getTime(int index);
444
        
445
            public Time getTime(String name);
446
        
447
    /**
448
     * Returns the instant value of an attribute given its position.
449
     *
450
     * @param index
451
     *          position of the attribute
452
     * @return
453
     *      value of the specified attribute
454
     */
455
        public Instant getInstant(int index);
456

    
457
        /**
458
     * Returns the instant value of an attribute given its name.
459
     *
460
     * @param name
461
     *          a string containing the name of the attribute
462
     * @return
463
     *      value of the specified attribute
464
     */
465
        public Instant getInstant(String name);
466

    
467
    /**
468
     * Returns the interval value of an attribute given its position.
469
     *
470
     * @param index
471
     *          position of the attribute
472
     * @return
473
     *      value of the specified attribute
474
     */
475
        public Interval getInterval(int index);
476

    
477
        /**
478
     * Returns the interval value of an attribute given its name.
479
     *
480
     * @param name
481
     *          a string containing the name of the attribute
482
     * @return
483
     *      value of the specified attribute
484
     */
485
        public Interval getInterval(String name);
486

    
487
        public DynObject getAsDynObject();
488
        
489
        /**
490
         * This lets Feature be used eaily with {@link Evaluator}
491
         * 
492
         * @return
493
         *     An instance of {@link EvaluatorData} which returns the data
494
         *     of this feature
495
         */
496
        public EvaluatorData getEvaluatorData();
497
        
498
        /**
499
         * Return the store associated to this feature.
500
         * 
501
         * @return the FeatureStore of the feature.
502
         */
503
        public FeatureStore getStore();
504

    
505
        public String getLabelOfValue(String name);
506

    
507
        public Object getExtraValue(int index);
508
        
509
        public Object getExtraValue(String name);
510

    
511
}