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

History | View | Annotate | Download (15 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.expressionevaluator.Expression;
31
import org.gvsig.fmap.dal.exception.DataException;
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.timesupport.Time;
37
import org.gvsig.tools.dynobject.DynObject;
38
import org.gvsig.tools.evaluator.Evaluator;
39
import org.gvsig.tools.evaluator.EvaluatorData;
40
import org.gvsig.tools.util.GetItemByKeyWithSizeAndGetKeys;
41
import org.gvsig.json.SupportToJson;
42
import org.gvsig.tools.dataTypes.DataType;
43

    
44
/**
45
 * <p>
46
 * Represents the basic data unit of a tabular structure, equivalent to a record
47
 * in a data base table. In SIG domain, a Feature is a compound data structure
48
 * that may contain a geographic component. The conventional term Feature comes
49
 * from the term cartographic feature and both represent the same concept.
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
 * Features are not editable as such. To edit a Feature you have to obtain an
56
 * editable instance <code>EditableFeature</code> using the method
57
 * <code>getEditable()</code>. Modify that editable instance and then apply the
58
 * changes to the Feature. This mechanism is to avoid ambiguity and loosing
59
 * track on the Feature internal state.
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
66
 * <li>Has a <code>FeatureType</code> that describes the Feature characteristics
67
 * (attributes, data types, default geometry, validation rules).
68
 * <li>Can obtain a copy of itself.
69
 * <li>Can obtain its default geometry attribute and also a list with all the
70
 * geometry attributes.
71
 * <li>Can obtain its default Spatial Reference System and also a list with all
72
 * the SRSs used in the geometry attributes.
73
 * <li>Can obtain the envelope (extent) of the default geometry attribute.
74
 * <li>Can obtain the editable instance of the Feature.
75
 * <li>Has a set of utility methods to read attributes when their type is known,
76
 * by both index and name.
77
 * </ul>
78
 *
79
 */
80
public interface Feature extends GetItemByKeyWithSizeAndGetKeys<String, Object>, SupportToJson {
81

    
82
  static final int CHECK_RULES_AT_EDITING = 1;
83
  static final int CHECK_RULES_AT_FINISH = 2;    
84
  static final int CHECK_REQUIREDS = 4;
85
  static final int CHECK_BASIC = 8;
86
    
87
  /**
88
   * Returns a unique identifier for this Feature in the associated store.
89
   *
90
   * @return a unique FeatureReference in the associated store
91
   */
92
  public FeatureReference getReference();
93

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

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

    
108
 public void validate(int mode) throws DataException;
109
  
110
  /**
111
   * Returns the editable instance of this Feature. EditableFeature offers
112
   * methods for Feature editing.
113
   *
114
   * @return EditableFeature of this
115
   */
116
  public EditableFeature getEditable();
117

    
118
  public Object getOrDefault(String name, Object defaultValue);
119

    
120
  public Object getOrDefault(String name, DataType type, Object defaultValue);
121

    
122
  public Object getOrDefault(String name, int type, Object defaultValue);
123

    
124
  public String getStringOrDefault(String name, String defaultValue);
125

    
126
  public int getIntOrDefault(String name, int defaultValue);
127

    
128
  public long getLongOrDefault(String name, long defaultValue);
129

    
130
  public float getFloatOrDefault(String name, float defaultValue);
131

    
132
  public double getDoubleOrDefault(String name, double defaultValue);
133

    
134
  public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue);
135

    
136
  public Date getDateOrDefault(String name, Date defaultValue);
137

    
138
  public Object getOrDefault(int index, Object defaultValue);
139

    
140
  public String getStringOrDefault(int index, String defaultValue);
141

    
142
  public int getIntOrDefault(int index, int defaultValue);
143

    
144
  public long getLongOrDefault(int index, long defaultValue);
145

    
146
  public float getFloatOrDefault(int index, float defaultValue);
147

    
148
  public double getDoubleOrDefault(int index, double defaultValue);
149

    
150
  public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue);
151

    
152
  public Date getDateOrDefault(int index, Date defaultValue);
153

    
154
  /**
155
   * Returns the value of an attribute given its name.
156
   *
157
   * @param name a string containing the name of the attribute
158
   * @return value of the specified attribute
159
   */
160
  @Override
161
  public Object get(String name);
162

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

    
171
  public boolean isNull(int index);
172

    
173
  public boolean isNull(String name);
174

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

    
183
  /**
184
   * Returns the int 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 int getInt(int index);
190

    
191
  /**
192
   * Returns the Boolean value of an attribute given its name.
193
   *
194
   * @param name name of the attribute
195
   * @return value of the specified attribute
196
   */
197
  public boolean getBoolean(String name);
198
  public boolean getBooleanOrDefault(String name, boolean defaultValue);
199

    
200
  /**
201
   * Returns the Boolean value of an attribute given its position.
202
   *
203
   * @param index position of the attribute
204
   * @return value of the specified attribute
205
   */
206
  public boolean getBoolean(int index);
207
  public boolean getBooleanOrDefault(int index, boolean defaultValue);
208

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

    
217
  /**
218
   * Returns the long value of an attribute given its position.
219
   *
220
   * @param index position of the attribute
221
   * @return value of the specified attribute
222
   */
223
  public long getLong(int index);
224

    
225
  /**
226
   * Returns the float value of an attribute given its name.
227
   *
228
   * @param name name of the attribute
229
   * @return value of the specified attribute
230
   */
231
  public float getFloat(String name);
232

    
233
  /**
234
   * Returns the float value of an attribute given its position.
235
   *
236
   * @param index position of the attribute
237
   * @return value of the specified attribute
238
   */
239
  public float getFloat(int index);
240

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

    
249
  /**
250
   * Returns the double value of an attribute given its position.
251
   *
252
   * @param index position of the attribute
253
   * @return value of the specified attribute
254
   */
255
  public double getDouble(int index);
256

    
257
  /**
258
   * Returns the BigDecimal value of an attribute given its name.
259
   *
260
   * @param name name of the attribute
261
   * @return value of the specified attribute
262
   */
263
  public BigDecimal getDecimal(String name);
264

    
265
  /**
266
   * Returns the BigDecimal value of an attribute given its position.
267
   *
268
   * @param index position of the attribute
269
   * @return value of the specified attribute
270
   */
271
  public BigDecimal getDecimal(int index);
272

    
273
  /**
274
   * Returns the Date value of an attribute given its name.
275
   *
276
   * @param name name of the attribute
277
   * @return value of the specified attribute
278
   */
279
  public java.sql.Date getDate(String name);
280

    
281
  /**
282
   * Returns the Date value of an attribute given its position.
283
   *
284
   * @param index position of the attribute
285
   * @return value of the specified attribute
286
   */
287
  public java.sql.Date getDate(int index);
288
  
289
  public java.sql.Time getTime(String name);
290
  public java.sql.Time getTime(int index);
291
  
292
  public java.sql.Timestamp getTimestamp(String name);
293
  public java.sql.Timestamp getTimestamp(int index);
294

    
295
  /**
296
   * Returns the String value of an attribute given its name.
297
   *
298
   * @param name name of the attribute
299
   * @return value of the specified attribute
300
   */
301
  public String getString(String name);
302

    
303
  /**
304
   * Returns the String value of an attribute given its position.
305
   *
306
   * @param index position of the attribute
307
   * @return value of the specified attribute
308
   */
309
  public String getString(int index);
310

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

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

    
327
  /**
328
   * Returns the Geometry value of an attribute given its name.
329
   *
330
   * @param name name of the attribute
331
   * @return value of the specified attribute
332
   */
333
  public Geometry getGeometry(String name);
334

    
335
  /**
336
   * Returns the Geometry value of an attribute given its position.
337
   *
338
   * @param index position of the attribute
339
   * @return value of the specified attribute
340
   */
341
  public Geometry getGeometry(int index);
342

    
343
  public byte[] getByteArray(String name);
344

    
345
  public byte[] getByteArray(int index);
346

    
347
  /**
348
   * Returns the array 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 Object[] getArray(String name);
354

    
355
  /**
356
   * Returns the array 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 Object[] getArray(int index);
362

    
363
  /**
364
   * Returns the Feature value of an attribute given its name.
365
   *
366
   * @param name name of the attribute
367
   * @return value of the specified attribute
368
   */
369
  public Feature getFeature(String name);
370

    
371
  /**
372
   * Returns the Feature value of an attribute given its position.
373
   *
374
   * @param index position of the attribute
375
   * @return value of the specified attribute
376
   */
377
  public Feature getFeature(int index);
378

    
379
  public Object getFromProfile(int index);
380

    
381
  public Object getFromProfile(String name);
382

    
383
  /**
384
   * Envelope (AKA extent or bounding box) of the default geometry attribute.
385
   *
386
   * @return Envelope of the default geometry attribute
387
   */
388
  public Envelope getDefaultEnvelope();
389

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

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

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

    
413
  /**
414
   * Returns a list with the Spatial Reference Systems in which are expressed
415
   * this Feature's geometry attributes.
416
   *
417
   * @return a list with the Spatial Reference Systems.
418
   */
419
  public List getSRSs();
420

    
421
//  public Time getDefaultTime();
422
//
423
//  public Time getTime(int index);
424
//
425
//  public Time getTime(String name);
426
//
427
//  /**
428
//   * Returns the instant value of an attribute given its position.
429
//   *
430
//   * @param index position of the attribute
431
//   * @return value of the specified attribute
432
//   */
433
//  public Instant getInstant(int index);
434
//
435
//  /**
436
//   * Returns the instant value of an attribute given its name.
437
//   *
438
//   * @param name a string containing the name of the attribute
439
//   * @return value of the specified attribute
440
//   */
441
//  public Instant getInstant(String name);
442
//
443
//  /**
444
//   * Returns the interval value of an attribute given its position.
445
//   *
446
//   * @param index position of the attribute
447
//   * @return value of the specified attribute
448
//   */
449
//  public Interval getInterval(int index);
450
//
451
//  /**
452
//   * Returns the interval value of an attribute given its name.
453
//   *
454
//   * @param name a string containing the name of the attribute
455
//   * @return value of the specified attribute
456
//   */
457
//  public Interval getInterval(String name);
458

    
459
  public DynObject getAsDynObject();
460

    
461
  /**
462
   * This lets Feature be used eaily with {@link Evaluator}
463
   *
464
   * @return An instance of {@link EvaluatorData} which returns the data of this
465
   * feature
466
   */
467
  public EvaluatorData getEvaluatorData();
468

    
469
  /**
470
   * Return the store associated to this feature.
471
   *
472
   * @return the FeatureStore of the feature.
473
   */
474
  public FeatureStore getStore();
475

    
476
  public String getLabelOfValue(String name);
477

    
478
  public Object getExtraValue(int index);
479

    
480
  public Object getExtraValue(String name);
481

    
482
  public boolean hasExtraValue(String name);
483
  
484
  public void setExtraValue(String name, Object value);
485

    
486
   public boolean hasValue(String name);
487
//  public Feature getRelatedFeature(String name);
488
//  
489
//  public List<Feature> getRelatedFeatures(String name);
490
  
491
    public String format(String name);
492

    
493
    public String format(int index);
494
    
495
    public Feature getForeignFeature(String attrName);
496

    
497
    public Expression createFilter();
498
    
499
    public boolean isBroken();
500
    
501
}