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

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

    
83
  /**
84
   * Returns a unique identifier for this Feature in the associated store.
85
   *
86
   * @return a unique FeatureReference in the associated store
87
   */
88
  public FeatureReference getReference();
89

    
90
  /**
91
   * Returns the FeatureType that describes the structure of this Feature.
92
   *
93
   * @return a FeatureType describing this Feature structure.
94
   */
95
  public FeatureType getType();
96

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

    
104
  /**
105
   * Mode that indicates the validation of all FeatureRules
106
   */
107
  static final int ALL = 0;
108

    
109
  /**
110
   * Mode that indicates the validation of the update FeatureRules
111
   */
112
  static final int UPDATE = 1;
113

    
114
  /**
115
   * Mode that indicates the validation of the finish editing FeatureRules
116
   */
117
  static final int FINISH_EDITING = 2;
118

    
119
  /**
120
   * Validates this Feature by applying the <code>FeatureRules</code>
121
   * corresponding to the given mode.
122
   *
123
   * @param mode one of the constants {ALL, UPDATE, FINISH_EDITING}
124
   * @throws DataException on validation errors
125
   */
126
  public void validate(int mode) throws DataException;
127

    
128
  /**
129
   * Returns the editable instance of this Feature. EditableFeature offers
130
   * methods for Feature editing.
131
   *
132
   * @return EditableFeature of this
133
   */
134
  public EditableFeature getEditable();
135

    
136
  public Object getOrDefault(String name, Object defaultValue);
137

    
138
  public String getStringOrDefault(String name, String defaultValue);
139

    
140
  public int getIntOrDefault(String name, int defaultValue);
141

    
142
  public long getLongOrDefault(String name, long defaultValue);
143

    
144
  public float getFloatOrDefault(String name, float defaultValue);
145

    
146
  public double getDoubleOrDefault(String name, double defaultValue);
147

    
148
  public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue);
149

    
150
  public Date getDateOrDefault(String name, Date defaultValue);
151

    
152
  public Object getOrDefault(int index, Object defaultValue);
153

    
154
  public String getStringOrDefault(int index, String defaultValue);
155

    
156
  public int getIntOrDefault(int index, int defaultValue);
157

    
158
  public long getLongOrDefault(int index, long defaultValue);
159

    
160
  public float getFloatOrDefault(int index, float defaultValue);
161

    
162
  public double getDoubleOrDefault(int index, double defaultValue);
163

    
164
  public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue);
165

    
166
  public Date getDateOrDefault(int index, Date defaultValue);
167

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

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

    
185
  public boolean isNull(int index);
186

    
187
  public boolean isNull(String name);
188

    
189
  /**
190
   * Returns the int value of an attribute given its name.
191
   *
192
   * @param name a string containing the name of the attribute
193
   * @return value of the specified attribute
194
   */
195
  public int getInt(String name);
196

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

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

    
213
  /**
214
   * Returns the Boolean value of an attribute given its position.
215
   *
216
   * @param index position of the attribute
217
   * @return value of the specified attribute
218
   */
219
  public boolean getBoolean(int index);
220

    
221
  /**
222
   * Returns the long value of an attribute given its name.
223
   *
224
   * @param name name of the attribute
225
   * @return value of the specified attribute
226
   */
227
  public long getLong(String name);
228

    
229
  /**
230
   * Returns the long value of an attribute given its position.
231
   *
232
   * @param index position of the attribute
233
   * @return value of the specified attribute
234
   */
235
  public long getLong(int index);
236

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

    
245
  /**
246
   * Returns the float value of an attribute given its position.
247
   *
248
   * @param index position of the attribute
249
   * @return 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 name of the attribute
257
   * @return value of the specified attribute
258
   */
259
  public double getDouble(String name);
260

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

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

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

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

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

    
301
  /**
302
   * Returns the String value of an attribute given its name.
303
   *
304
   * @param name name of the attribute
305
   * @return value of the specified attribute
306
   */
307
  public String getString(String name);
308

    
309
  /**
310
   * Returns the String value of an attribute given its position.
311
   *
312
   * @param index position of the attribute
313
   * @return value of the specified attribute
314
   */
315
  public String getString(int index);
316

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

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

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

    
341
  /**
342
   * Returns the Geometry value of an attribute given its position.
343
   *
344
   * @param index position of the attribute
345
   * @return value of the specified attribute
346
   */
347
  public Geometry getGeometry(int index);
348

    
349
  public byte[] getByteArray(String name);
350

    
351
  public byte[] getByteArray(int index);
352

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

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

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

    
377
  /**
378
   * Returns the Feature value of an attribute given its position.
379
   *
380
   * @param index position of the attribute
381
   * @return value of the specified attribute
382
   */
383
  public Feature getFeature(int index);
384

    
385
  public Object getFromProfile(int index);
386

    
387
  public Object getFromProfile(String name);
388

    
389
  /**
390
   * Envelope (AKA extent or bounding box) of the default geometry attribute.
391
   *
392
   * @return Envelope of the default geometry attribute
393
   */
394
  public Envelope getDefaultEnvelope();
395

    
396
  /**
397
   * Returns the value of the default geometry attribute, which is a
398
   * {@link Geometry}.
399
   *
400
   * @return value of the default geometry attribute
401
   */
402
  public Geometry getDefaultGeometry();
403

    
404
  /**
405
   * Returns a list with the values of this Feature's geometry attributes.
406
   *
407
   * @return a list with the values of this Feature's geometry attributes
408
   */
409
  public List getGeometries();
410

    
411
  /**
412
   * Returns the Spatial Reference System in which is expressed the default
413
   * geometry attribute.
414
   *
415
   * @return A string containing the default geometry attribute SRS.
416
   */
417
  public IProjection getDefaultSRS();
418

    
419
  /**
420
   * Returns a list with the Spatial Reference Systems in which are expressed
421
   * this Feature's geometry attributes.
422
   *
423
   * @return a list with the Spatial Reference Systems.
424
   */
425
  public List getSRSs();
426

    
427
  public Time getDefaultTime();
428

    
429
  public Time getTime(int index);
430

    
431
  public Time getTime(String name);
432

    
433
  /**
434
   * Returns the instant value of an attribute given its position.
435
   *
436
   * @param index position of the attribute
437
   * @return 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 a string containing the name of the attribute
445
   * @return value of the specified attribute
446
   */
447
  public Instant getInstant(String name);
448

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

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

    
465
  public DynObject getAsDynObject();
466

    
467
  /**
468
   * This lets Feature be used eaily with {@link Evaluator}
469
   *
470
   * @return An instance of {@link EvaluatorData} which returns the data of this
471
   * feature
472
   */
473
  public EvaluatorData getEvaluatorData();
474

    
475
  /**
476
   * Return the store associated to this feature.
477
   *
478
   * @return the FeatureStore of the feature.
479
   */
480
  public FeatureStore getStore();
481

    
482
  public String getLabelOfValue(String name);
483

    
484
  public Object getExtraValue(int index);
485

    
486
  public Object getExtraValue(String name);
487

    
488
  public boolean hasExtraValue(String name);
489
}