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

History | View | Annotate | Download (14.6 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
  public Date getTime(String name);
302
  public Date getTime(int index);
303
  
304
  public Date getTimestamp(String name);
305
  public Date getTimestamp(int index);
306

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

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

    
323
  /**
324
   * Returns the byte value of an attribute given its name.
325
   *
326
   * @param name name of the attribute
327
   * @return value of the specified attribute
328
   */
329
  public byte getByte(String name);
330

    
331
  /**
332
   * Returns the byte value of an attribute given its position.
333
   *
334
   * @param index position of the attribute
335
   * @return value of the specified attribute
336
   */
337
  public byte getByte(int index);
338

    
339
  /**
340
   * Returns the Geometry value of an attribute given its name.
341
   *
342
   * @param name name of the attribute
343
   * @return value of the specified attribute
344
   */
345
  public Geometry getGeometry(String name);
346

    
347
  /**
348
   * Returns the Geometry value of an attribute given its position.
349
   *
350
   * @param index position of the attribute
351
   * @return value of the specified attribute
352
   */
353
  public Geometry getGeometry(int index);
354

    
355
  public byte[] getByteArray(String name);
356

    
357
  public byte[] getByteArray(int index);
358

    
359
  /**
360
   * Returns the array value of an attribute given its name.
361
   *
362
   * @param name name of the attribute
363
   * @return value of the specified attribute
364
   */
365
  public Object[] getArray(String name);
366

    
367
  /**
368
   * Returns the array value of an attribute given its position.
369
   *
370
   * @param index position of the attribute
371
   * @return value of the specified attribute
372
   */
373
  public Object[] getArray(int index);
374

    
375
  /**
376
   * Returns the Feature value of an attribute given its name.
377
   *
378
   * @param name name of the attribute
379
   * @return value of the specified attribute
380
   */
381
  public Feature getFeature(String name);
382

    
383
  /**
384
   * Returns the Feature value of an attribute given its position.
385
   *
386
   * @param index position of the attribute
387
   * @return value of the specified attribute
388
   */
389
  public Feature getFeature(int index);
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 geometry attribute.
397
   *
398
   * @return Envelope of the default geometry attribute
399
   */
400
  public Envelope getDefaultEnvelope();
401

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

    
410
  /**
411
   * Returns a list with the values of this Feature's geometry attributes.
412
   *
413
   * @return a list with the values of this Feature's geometry attributes
414
   */
415
  public List getGeometries();
416

    
417
  /**
418
   * Returns the Spatial Reference System in which is expressed the default
419
   * geometry attribute.
420
   *
421
   * @return A string containing the default geometry attribute SRS.
422
   */
423
  public IProjection getDefaultSRS();
424

    
425
  /**
426
   * Returns a list with the Spatial Reference Systems in which are expressed
427
   * this Feature's geometry attributes.
428
   *
429
   * @return a list with the Spatial Reference Systems.
430
   */
431
  public List getSRSs();
432

    
433
//  public Time getDefaultTime();
434
//
435
//  public Time getTime(int index);
436
//
437
//  public Time getTime(String name);
438
//
439
//  /**
440
//   * Returns the instant value of an attribute given its position.
441
//   *
442
//   * @param index position of the attribute
443
//   * @return value of the specified attribute
444
//   */
445
//  public Instant getInstant(int index);
446
//
447
//  /**
448
//   * Returns the instant value of an attribute given its name.
449
//   *
450
//   * @param name a string containing the name of the attribute
451
//   * @return value of the specified attribute
452
//   */
453
//  public Instant getInstant(String name);
454
//
455
//  /**
456
//   * Returns the interval value of an attribute given its position.
457
//   *
458
//   * @param index position of the attribute
459
//   * @return value of the specified attribute
460
//   */
461
//  public Interval getInterval(int index);
462
//
463
//  /**
464
//   * Returns the interval value of an attribute given its name.
465
//   *
466
//   * @param name a string containing the name of the attribute
467
//   * @return 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 An instance of {@link EvaluatorData} which returns the data of this
477
   * feature
478
   */
479
  public EvaluatorData getEvaluatorData();
480

    
481
  /**
482
   * Return the store associated to this feature.
483
   *
484
   * @return the FeatureStore of the feature.
485
   */
486
  public FeatureStore getStore();
487

    
488
  public String getLabelOfValue(String name);
489

    
490
  public Object getExtraValue(int index);
491

    
492
  public Object getExtraValue(String name);
493

    
494
  public boolean hasExtraValue(String name);
495

    
496
//  public Feature getRelatedFeature(String name);
497
//  
498
//  public List<Feature> getRelatedFeatures(String name);
499
  
500
}