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

History | View | Annotate | Download (15.2 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.GetItemByKeyWithSizeAndGetKeys;
40
import org.gvsig.json.SupportToJson;
41
import org.gvsig.tools.dataTypes.DataType;
42

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

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

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

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

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

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

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

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

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

    
138
  public Object getOrDefault(String name, Object defaultValue);
139

    
140
  public Object getOrDefault(String name, DataType type, Object defaultValue);
141

    
142
  public Object getOrDefault(String name, int type, Object defaultValue);
143

    
144
  public String getStringOrDefault(String name, String defaultValue);
145

    
146
  public int getIntOrDefault(String name, int defaultValue);
147

    
148
  public long getLongOrDefault(String name, long defaultValue);
149

    
150
  public float getFloatOrDefault(String name, float defaultValue);
151

    
152
  public double getDoubleOrDefault(String name, double defaultValue);
153

    
154
  public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue);
155

    
156
  public Date getDateOrDefault(String name, Date defaultValue);
157

    
158
  public Object getOrDefault(int index, Object defaultValue);
159

    
160
  public String getStringOrDefault(int index, String defaultValue);
161

    
162
  public int getIntOrDefault(int index, int defaultValue);
163

    
164
  public long getLongOrDefault(int index, long defaultValue);
165

    
166
  public float getFloatOrDefault(int index, float defaultValue);
167

    
168
  public double getDoubleOrDefault(int index, double defaultValue);
169

    
170
  public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue);
171

    
172
  public Date getDateOrDefault(int index, Date defaultValue);
173

    
174
  /**
175
   * Returns the value of an attribute given its name.
176
   *
177
   * @param name a string containing the name of the attribute
178
   * @return value of the specified attribute
179
   */
180
  @Override
181
  public Object get(String name);
182

    
183
  /**
184
   * Returns the value of an attribute given its position.
185
   *
186
   * @param index position of the attribute
187
   * @return value of the specified attribute
188
   */
189
  public Object get(int index);
190

    
191
  public boolean isNull(int index);
192

    
193
  public boolean isNull(String name);
194

    
195
  /**
196
   * Returns the int value of an attribute given its name.
197
   *
198
   * @param name a string containing the name of the attribute
199
   * @return value of the specified attribute
200
   */
201
  public int getInt(String name);
202

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

    
211
  /**
212
   * Returns the Boolean value of an attribute given its name.
213
   *
214
   * @param name name of the attribute
215
   * @return value of the specified attribute
216
   */
217
  public boolean getBoolean(String name);
218
  public boolean getBooleanOrDefault(String name, boolean defaultValue);
219

    
220
  /**
221
   * Returns the Boolean value of an attribute given its position.
222
   *
223
   * @param index position of the attribute
224
   * @return value of the specified attribute
225
   */
226
  public boolean getBoolean(int index);
227
  public boolean getBooleanOrDefault(int index, boolean defaultValue);
228

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

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

    
245
  /**
246
   * Returns the float value of an attribute given its name.
247
   *
248
   * @param name name of the attribute
249
   * @return value of the specified attribute
250
   */
251
  public float getFloat(String name);
252

    
253
  /**
254
   * Returns the float value of an attribute given its position.
255
   *
256
   * @param index position of the attribute
257
   * @return value of the specified attribute
258
   */
259
  public float getFloat(int index);
260

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

    
269
  /**
270
   * Returns the double value of an attribute given its position.
271
   *
272
   * @param index position of the attribute
273
   * @return value of the specified attribute
274
   */
275
  public double getDouble(int index);
276

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

    
285
  /**
286
   * Returns the BigDecimal value of an attribute given its position.
287
   *
288
   * @param index position of the attribute
289
   * @return value of the specified attribute
290
   */
291
  public BigDecimal getDecimal(int index);
292

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

    
301
  /**
302
   * Returns the Date value of an attribute given its position.
303
   *
304
   * @param index position of the attribute
305
   * @return value of the specified attribute
306
   */
307
  public java.sql.Date getDate(int index);
308
  
309
  public java.sql.Time getTime(String name);
310
  public java.sql.Time getTime(int index);
311
  
312
  public java.sql.Timestamp getTimestamp(String name);
313
  public java.sql.Timestamp getTimestamp(int index);
314

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

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

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

    
339
  /**
340
   * Returns the byte value of an attribute given its position.
341
   *
342
   * @param index position of the attribute
343
   * @return value of the specified attribute
344
   */
345
  public byte getByte(int index);
346

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

    
355
  /**
356
   * Returns the Geometry value of an attribute given its position.
357
   *
358
   * @param index position of the attribute
359
   * @return value of the specified attribute
360
   */
361
  public Geometry getGeometry(int index);
362

    
363
  public byte[] getByteArray(String name);
364

    
365
  public byte[] getByteArray(int index);
366

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

    
375
  /**
376
   * Returns the array value of an attribute given its position.
377
   *
378
   * @param index position of the attribute
379
   * @return value of the specified attribute
380
   */
381
  public Object[] getArray(int index);
382

    
383
  /**
384
   * Returns the Feature value of an attribute given its name.
385
   *
386
   * @param name name of the attribute
387
   * @return value of the specified attribute
388
   */
389
  public Feature getFeature(String name);
390

    
391
  /**
392
   * Returns the Feature value of an attribute given its position.
393
   *
394
   * @param index position of the attribute
395
   * @return value of the specified attribute
396
   */
397
  public Feature getFeature(int index);
398

    
399
  public Object getFromProfile(int index);
400

    
401
  public Object getFromProfile(String name);
402

    
403
  /**
404
   * Envelope (AKA extent or bounding box) of the default geometry attribute.
405
   *
406
   * @return Envelope of the default geometry attribute
407
   */
408
  public Envelope getDefaultEnvelope();
409

    
410
  /**
411
   * Returns the value of the default geometry attribute, which is a
412
   * {@link Geometry}.
413
   *
414
   * @return value of the default geometry attribute
415
   */
416
  public Geometry getDefaultGeometry();
417

    
418
  /**
419
   * Returns a list with the values of this Feature's geometry attributes.
420
   *
421
   * @return a list with the values of this Feature's geometry attributes
422
   */
423
  public List getGeometries();
424

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

    
433
  /**
434
   * Returns a list with the Spatial Reference Systems in which are expressed
435
   * this Feature's geometry attributes.
436
   *
437
   * @return a list with the Spatial Reference Systems.
438
   */
439
  public List getSRSs();
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 position of the attribute
451
//   * @return value of the specified attribute
452
//   */
453
//  public Instant getInstant(int index);
454
//
455
//  /**
456
//   * Returns the instant value of an attribute given its name.
457
//   *
458
//   * @param name a string containing the name of the attribute
459
//   * @return value of the specified attribute
460
//   */
461
//  public Instant getInstant(String name);
462
//
463
//  /**
464
//   * Returns the interval value of an attribute given its position.
465
//   *
466
//   * @param index position of the attribute
467
//   * @return value of the specified attribute
468
//   */
469
//  public Interval getInterval(int index);
470
//
471
//  /**
472
//   * Returns the interval value of an attribute given its name.
473
//   *
474
//   * @param name a string containing the name of the attribute
475
//   * @return value of the specified attribute
476
//   */
477
//  public Interval getInterval(String name);
478

    
479
  public DynObject getAsDynObject();
480

    
481
  /**
482
   * This lets Feature be used eaily with {@link Evaluator}
483
   *
484
   * @return An instance of {@link EvaluatorData} which returns the data of this
485
   * feature
486
   */
487
  public EvaluatorData getEvaluatorData();
488

    
489
  /**
490
   * Return the store associated to this feature.
491
   *
492
   * @return the FeatureStore of the feature.
493
   */
494
  public FeatureStore getStore();
495

    
496
  public String getLabelOfValue(String name);
497

    
498
  public Object getExtraValue(int index);
499

    
500
  public Object getExtraValue(String name);
501

    
502
  public boolean hasExtraValue(String name);
503
  
504
  public void setExtraValue(String name, Object value);
505

    
506
   public boolean hasValue(String name);
507
//  public Feature getRelatedFeature(String name);
508
//  
509
//  public List<Feature> getRelatedFeatures(String name);
510
  
511
}