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

History | View | Annotate | Download (15.1 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.expressionevaluator.ExpressionBuilder;
32
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.fmap.geom.Geometry;
34
import org.gvsig.fmap.geom.primitive.Envelope;
35
//import org.gvsig.timesupport.Instant;
36
//import org.gvsig.timesupport.Interval;
37
//import org.gvsig.timesupport.Time;
38
import org.gvsig.tools.dynobject.DynObject;
39
import org.gvsig.tools.evaluator.Evaluator;
40
import org.gvsig.tools.evaluator.EvaluatorData;
41
import org.gvsig.tools.util.GetItemByKeyWithSizeAndGetKeys;
42
import org.gvsig.json.SupportToJson;
43
import org.gvsig.tools.dataTypes.DataType;
44

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
172
  public boolean isNull(int index);
173

    
174
  public boolean isNull(String name);
175

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
348
  /**
349
   * Returns the array value of an attribute given its name.
350
   *
351
   * @param name name of the attribute
352
   * @return value of the specified attribute
353
   */
354
  public Object[] getArray(String name);
355

    
356
  /**
357
   * Returns the array value of an attribute given its position.
358
   *
359
   * @param index position of the attribute
360
   * @return value of the specified attribute
361
   */
362
  public Object[] getArray(int index);
363

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

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

    
380
  public Object getFromProfile(int index);
381

    
382
  public Object getFromProfile(String name);
383

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

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

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

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

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

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

    
460
  public DynObject getAsDynObject();
461

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

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

    
477
  public String getLabelOfValue(String name);
478

    
479
  public Object getExtraValue(int index);
480

    
481
  public Object getExtraValue(String name);
482

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

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

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

    
498
    public Expression createFilter();
499
    
500
    public ExpressionBuilder createBuilderFilter();
501
    
502
    public boolean isBroken();
503
    
504
}