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

History | View | Annotate | Download (13 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
        /**
130
         * Returns the value of an attribute given its name.
131
         *
132
         * @param name
133
         *                         a string containing the name of the attribute
134
         * @return
135
         *                 value of the specified attribute
136
         */
137
        @Override
138
        public Object   get(String name);
139

    
140
        /**
141
         * Returns the value of an attribute given its position.
142
         *
143
         * @param index
144
         *                         position of the attribute
145
         * @return
146
         *                 value of the specified attribute
147
         */
148
        public Object   get(int index);
149

    
150
        /**
151
         * Returns the int value of an attribute given its name.
152
         *
153
         * @param name
154
         *                         a string containing the name of the attribute
155
         * @return
156
         *                 value of the specified attribute
157
         */
158
        public int      getInt(String name);
159

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

    
170
        /**
171
         * Returns the Boolean value of an attribute given its name.
172
         *
173
         * @param name
174
         *                         name of the attribute
175
         * @return
176
         *                 value of the specified attribute
177
         */
178
        public boolean  getBoolean(String name);
179

    
180
        /**
181
         * Returns the Boolean value of an attribute given its position.
182
         *
183
         * @param index
184
         *                         position of the attribute
185
         * @return
186
         *                 value of the specified attribute
187
         */
188
        public boolean  getBoolean(int index);
189

    
190
        /**
191
         * Returns the long value of an attribute given its name.
192
         *
193
         * @param name
194
         *                         name of the attribute
195
         * @return
196
         *                 value of the specified attribute
197
         */
198
        public long     getLong(String name);
199

    
200
        /**
201
         * Returns the long value of an attribute given its position.
202
         *
203
         * @param index
204
         *                         position of the attribute
205
         * @return
206
         *                 value of the specified attribute
207
         */
208
        public long     getLong(int index);
209

    
210
        /**
211
         * Returns the float value of an attribute given its name.
212
         *
213
         * @param name
214
         *                         name of the attribute
215
         * @return
216
         *                 value of the specified attribute
217
         */
218
        public float   getFloat(String name);
219

    
220
        /**
221
         * Returns the float value of an attribute given its position.
222
         *
223
         * @param index
224
         *                         position of the attribute
225
         * @return
226
         *                 value of the specified attribute
227
         */
228
        public float    getFloat(int index);
229

    
230
        /**
231
         * Returns the double value of an attribute given its name.
232
         *
233
         * @param name
234
         *                         name of the attribute
235
         * @return
236
         *                 value of the specified attribute
237
         */
238
        public double  getDouble(String name);
239

    
240
        /**
241
         * Returns the double value of an attribute given its position.
242
         *
243
         * @param index
244
         *                         position of the attribute
245
         * @return
246
         *                 value of the specified attribute
247
         */
248
        public double   getDouble(int index);
249

    
250
        /**
251
         * Returns the Date value of an attribute given its name.
252
         *
253
         * @param name
254
         *                         name of the attribute
255
         * @return
256
         *                 value of the specified attribute
257
         */
258
        public Date    getDate(String name);
259

    
260
        /**
261
         * Returns the Date value of an attribute given its position.
262
         *
263
         * @param index
264
         *                         position of the attribute
265
         * @return
266
         *                 value of the specified attribute
267
         */
268
        public Date     getDate(int index);
269

    
270
        /**
271
         * Returns the String value of an attribute given its name.
272
         *
273
         * @param name
274
         *                         name of the attribute
275
         * @return
276
         *                 value of the specified attribute
277
         */
278
        public String  getString(String name);
279

    
280
        /**
281
         * Returns the String value of an attribute given its position.
282
         *
283
         * @param index
284
         *                         position of the attribute
285
         * @return
286
         *                 value of the specified attribute
287
         */
288
        public String   getString(int index);
289

    
290
        /**
291
         * Returns the byte value of an attribute given its name.
292
         *
293
         * @param name
294
         *                         name of the attribute
295
         * @return
296
         *                 value of the specified attribute
297
         */
298
        public byte    getByte(String name);
299

    
300
        /**
301
         * Returns the byte value of an attribute given its position.
302
         *
303
         * @param index
304
         *                         position of the attribute
305
         * @return
306
         *                 value of the specified attribute
307
         */
308
        public byte     getByte(int index);
309

    
310
        /**
311
         * Returns the Geometry value of an attribute given its name.
312
         *
313
         * @param name
314
         *                         name of the attribute
315
         * @return
316
         *                 value of the specified attribute
317
         */
318
        public Geometry getGeometry(String name);
319

    
320
        /**
321
         * Returns the Geometry value of an attribute given its position.
322
         *
323
         * @param index
324
         *                         position of the attribute
325
         * @return
326
         *                 value of the specified attribute
327
         */
328
        public Geometry getGeometry(int index);
329

    
330
        public byte[] getByteArray(String name);
331

    
332
        public byte[] getByteArray(int index);
333

    
334
        /**
335
         * Returns the array value of an attribute given its name.
336
         *
337
         * @param name
338
         *                         name of the attribute
339
         * @return
340
         *                 value of the specified attribute
341
         */
342
        public Object[] getArray(String name);
343

    
344
        /**
345
         * Returns the array value of an attribute given its position.
346
         *
347
         * @param index
348
         *                         position of the attribute
349
         * @return
350
         *                 value of the specified attribute
351
         */
352
        public Object[] getArray(int index);
353

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

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

    
374

    
375
        public Object getFromProfile(int index);
376
        
377
        public Object getFromProfile(String name);
378
        
379
        /**
380
         * Envelope (AKA extent or bounding box) of the default
381
         * geometry attribute.
382
         *
383
         * @return Envelope
384
         *                                 of the default geometry attribute
385
         */
386
        public Envelope getDefaultEnvelope();
387

    
388
        /**
389
         * Returns the value of the default geometry attribute,
390
         * which is a {@link Geometry}.
391
         *
392
         * @return
393
         *                 value of the default geometry attribute
394
         */
395
        public Geometry getDefaultGeometry();
396

    
397
        /**
398
         * Returns a list with the values of this Feature's
399
         * geometry attributes.
400
         *
401
         * @return
402
         *                 a list with the values of this Feature's geometry attributes
403
         */
404
        public List getGeometries();
405

    
406
        /**
407
         * Returns the Spatial Reference System in which is
408
         * expressed the default geometry attribute.
409
         *
410
         * @return
411
         *                 A string containing the default geometry attribute SRS.
412
         */
413
        public IProjection getDefaultSRS();
414

    
415
        /**
416
         * Returns a list with the Spatial Reference Systems in which
417
         * are expressed this Feature's geometry attributes.
418
         *
419
         * @return
420
         *                 a list with the Spatial Reference Systems.
421
         */
422
        public List getSRSs();
423
        
424
        
425
        public Time getDefaultTime();
426
        
427
            public Time getTime(int index);
428
        
429
            public Time getTime(String name);
430
        
431
    /**
432
     * Returns the instant value of an attribute given its position.
433
     *
434
     * @param index
435
     *          position of the attribute
436
     * @return
437
     *      value of the specified attribute
438
     */
439
        public Instant getInstant(int index);
440

    
441
        /**
442
     * Returns the instant value of an attribute given its name.
443
     *
444
     * @param name
445
     *          a string containing the name of the attribute
446
     * @return
447
     *      value of the specified attribute
448
     */
449
        public Instant getInstant(String name);
450

    
451
    /**
452
     * Returns the interval value of an attribute given its position.
453
     *
454
     * @param index
455
     *          position of the attribute
456
     * @return
457
     *      value of the specified attribute
458
     */
459
        public Interval getInterval(int index);
460

    
461
        /**
462
     * Returns the interval value of an attribute given its name.
463
     *
464
     * @param name
465
     *          a string containing the name of the attribute
466
     * @return
467
     *      value of the specified attribute
468
     */
469
        public Interval getInterval(String name);
470

    
471
        public DynObject getAsDynObject();
472
        
473
        /**
474
         * This lets Feature be used eaily with {@link Evaluator}
475
         * 
476
         * @return
477
         *     An instance of {@link EvaluatorData} which returns the data
478
         *     of this feature
479
         */
480
        public EvaluatorData getEvaluatorData();
481
        
482
        /**
483
         * Return the store associated to this feature.
484
         * 
485
         * @return the FeatureStore of the feature.
486
         */
487
        public FeatureStore getStore();
488
}