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

History | View | Annotate | Download (12.5 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

    
29
import org.cresques.cts.IProjection;
30
import org.gvsig.fmap.dal.exception.DataException;
31

    
32
import org.gvsig.fmap.geom.Geometry;
33
import org.gvsig.fmap.geom.primitive.Envelope;
34
import org.gvsig.timesupport.Instant;
35
import org.gvsig.timesupport.Interval;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.evaluator.Evaluator;
38
import org.gvsig.tools.evaluator.EvaluatorData;
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 {
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
        public Object   get(String name);
138

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

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

    
159
        /**
160
         * Returns the int 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 int      getInt(int index);
168

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
329
        /**
330
         * Returns the array value of an attribute given its name.
331
         *
332
         * @param name
333
         *                         name of the attribute
334
         * @return
335
         *                 value of the specified attribute
336
         */
337
        public Object[] getArray(String name);
338

    
339
        /**
340
         * Returns the array value of an attribute given its position.
341
         *
342
         * @param index
343
         *                         position of the attribute
344
         * @return
345
         *                 value of the specified attribute
346
         */
347
        public Object[] getArray(int index);
348

    
349
        /**
350
         * Returns the Feature value of an attribute given its name.
351
         *
352
         * @param name
353
         *                         name of the attribute
354
         * @return
355
         *                 value of the specified attribute
356
         */
357
        public Feature  getFeature(String name);
358

    
359
        /**
360
         * Returns the Feature value of an attribute given its position.
361
         *
362
         * @param index
363
         *                         position of the attribute
364
         * @return
365
         *                 value of the specified attribute
366
         */
367
        public Feature  getFeature(int index);
368

    
369

    
370
        /**
371
         * Envelope (AKA extent or bounding box) of the default
372
         * geometry attribute.
373
         *
374
         * @return Envelope
375
         *                                 of the default geometry attribute
376
         */
377
        public Envelope getDefaultEnvelope();
378

    
379
        /**
380
         * Returns the value of the default geometry attribute,
381
         * which is a {@link Geometry}.
382
         *
383
         * @return
384
         *                 value of the default geometry attribute
385
         */
386
        public Geometry getDefaultGeometry();
387

    
388
        /**
389
         * Returns a list with the values of this Feature's
390
         * geometry attributes.
391
         *
392
         * @return
393
         *                 a list with the values of this Feature's geometry attributes
394
         */
395
        public List getGeometries();
396

    
397
        /**
398
         * Returns the Spatial Reference System in which is
399
         * expressed the default geometry attribute.
400
         *
401
         * @return
402
         *                 A string containing the default geometry attribute SRS.
403
         */
404
        public IProjection getDefaultSRS();
405

    
406
        /**
407
         * Returns a list with the Spatial Reference Systems in which
408
         * are expressed this Feature's geometry attributes.
409
         *
410
         * @return
411
         *                 a list with the Spatial Reference Systems.
412
         */
413
        public List getSRSs();
414
        
415
        /**
416
     * Returns the instant value of an attribute given its position.
417
     *
418
     * @param index
419
     *          position of the attribute
420
     * @return
421
     *      value of the specified attribute
422
     */
423
        public Instant getInstant(int index);
424

    
425
        /**
426
     * Returns the instant value of an attribute given its name.
427
     *
428
     * @param name
429
     *          a string containing the name of the attribute
430
     * @return
431
     *      value of the specified attribute
432
     */
433
        public Instant getInstant(String name);
434

    
435
    /**
436
     * Returns the interval value of an attribute given its position.
437
     *
438
     * @param index
439
     *          position of the attribute
440
     * @return
441
     *      value of the specified attribute
442
     */
443
        public Interval getInterval(int index);
444

    
445
        /**
446
     * Returns the interval value of an attribute given its name.
447
     *
448
     * @param name
449
     *          a string containing the name of the attribute
450
     * @return
451
     *      value of the specified attribute
452
     */
453
        public Interval getInterval(String name);
454

    
455
        public DynObject getAsDynObject();
456
        
457
        /**
458
         * This lets Feature be used eaily with {@link Evaluator}
459
         * 
460
         * @return
461
         *     An instance of {@link EvaluatorData} which returns the data
462
         *     of this feature
463
         */
464
        public EvaluatorData getEvaluatorData();
465
        
466
        /**
467
         * Return the store associated to this feature.
468
         * 
469
         * @return the FeatureStore of the feature.
470
         */
471
        public FeatureStore getStore();
472
}