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

History | View | Annotate | Download (14.7 KB)

1 40559 jjdelcerro
/**
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 40435 jjdelcerro
package org.gvsig.fmap.dal.feature;
25
26 44669 jjdelcerro
import java.math.BigDecimal;
27 40435 jjdelcerro
import java.util.Date;
28
import java.util.List;
29
import org.cresques.cts.IProjection;
30 41251 jjdelcerro
import org.gvsig.fmap.dal.exception.DataException;
31 40435 jjdelcerro
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.primitive.Envelope;
33 44767 jjdelcerro
//import org.gvsig.timesupport.Instant;
34
//import org.gvsig.timesupport.Interval;
35
//import org.gvsig.timesupport.Time;
36 40435 jjdelcerro
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.evaluator.Evaluator;
38
import org.gvsig.tools.evaluator.EvaluatorData;
39 45013 jjdelcerro
import org.gvsig.tools.util.GetItemByKeyWithSizeAndGetKeys;
40 45425 jjdelcerro
import org.gvsig.json.SupportToJson;
41 45738 fdiaz
import org.gvsig.tools.dataTypes.DataType;
42 40435 jjdelcerro
43
/**
44 44738 jjdelcerro
 * <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 40435 jjdelcerro
 * <p>
50 44738 jjdelcerro
 * A Feature may contain more than one geometry attribute. In the case there is
51
 * not any geometry data, the <code>getDefaultGeometry()</code> will return
52
 * <code>null</code>.
53 40435 jjdelcerro
 * <p>
54
 * Features are not editable as such. To edit a Feature you have to obtain an
55 44738 jjdelcerro
 * 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 40435 jjdelcerro
 * <br>
60 44738 jjdelcerro
 * <p>
61
 * The Feature:
62
 * <ul>
63
 * <li>Has an unique identifier <code>FeatureReference</code> to recognize our
64 45739 jjdelcerro
 * Feature from each other from the same data store
65 44738 jjdelcerro
 * <li>Has a <code>FeatureType</code> that describes the Feature characteristics
66 45739 jjdelcerro
 * (attributes, data types, default geometry, validation rules).
67
 * <li>Can obtain a copy of itself.
68 44738 jjdelcerro
 * <li>Can obtain its default geometry attribute and also a list with all the
69 45739 jjdelcerro
 * geometry attributes.
70 44738 jjdelcerro
 * <li>Can obtain its default Spatial Reference System and also a list with all
71 45739 jjdelcerro
 * the SRSs used in the geometry attributes.
72 44738 jjdelcerro
 * <li>Can obtain the envelope (extent) of the default geometry attribute.
73 45739 jjdelcerro
 * <li>Can obtain the editable instance of the Feature.
74 44738 jjdelcerro
 * <li>Has a set of utility methods to read attributes when their type is known,
75 45739 jjdelcerro
 * by both index and name.
76 44738 jjdelcerro
 * </ul>
77 40435 jjdelcerro
 *
78
 */
79 45425 jjdelcerro
public interface Feature extends GetItemByKeyWithSizeAndGetKeys<String, Object>, SupportToJson {
80 40435 jjdelcerro
81 45739 jjdelcerro
  static final int CHECK_RULES_AT_EDITING = 1;
82
  static final int CHECK_RULES_AT_FINISH = 2;
83
  static final int CHECK_REQUIREDS = 4;
84
  static final int CHECK_BASIC = 8;
85
86 44738 jjdelcerro
  /**
87
   * Returns a unique identifier for this Feature in the associated store.
88
   *
89
   * @return a unique FeatureReference in the associated store
90
   */
91
  public FeatureReference getReference();
92 40435 jjdelcerro
93 44738 jjdelcerro
  /**
94
   * Returns the FeatureType that describes the structure of this Feature.
95
   *
96
   * @return a FeatureType describing this Feature structure.
97
   */
98
  public FeatureType getType();
99 40435 jjdelcerro
100 44738 jjdelcerro
  /**
101
   * Creates and returns a copy of this
102
   *
103
   * @return a new instance of Feature which is equal to this
104
   */
105
  public Feature getCopy();
106 40435 jjdelcerro
107 45739 jjdelcerro
 public void validate(int mode) throws DataException;
108
109 44738 jjdelcerro
  /**
110
   * Returns the editable instance of this Feature. EditableFeature offers
111
   * methods for Feature editing.
112
   *
113
   * @return EditableFeature of this
114
   */
115
  public EditableFeature getEditable();
116 40435 jjdelcerro
117 44738 jjdelcerro
  public Object getOrDefault(String name, Object defaultValue);
118 40435 jjdelcerro
119 45738 fdiaz
  public Object getOrDefault(String name, DataType type, Object defaultValue);
120
121
  public Object getOrDefault(String name, int type, Object defaultValue);
122
123 44738 jjdelcerro
  public String getStringOrDefault(String name, String defaultValue);
124 40435 jjdelcerro
125 44738 jjdelcerro
  public int getIntOrDefault(String name, int defaultValue);
126 40435 jjdelcerro
127 44738 jjdelcerro
  public long getLongOrDefault(String name, long defaultValue);
128 40435 jjdelcerro
129 44738 jjdelcerro
  public float getFloatOrDefault(String name, float defaultValue);
130 40435 jjdelcerro
131 44738 jjdelcerro
  public double getDoubleOrDefault(String name, double defaultValue);
132 40435 jjdelcerro
133 44738 jjdelcerro
  public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue);
134 40435 jjdelcerro
135 44738 jjdelcerro
  public Date getDateOrDefault(String name, Date defaultValue);
136 40435 jjdelcerro
137 44738 jjdelcerro
  public Object getOrDefault(int index, Object defaultValue);
138 40435 jjdelcerro
139 44738 jjdelcerro
  public String getStringOrDefault(int index, String defaultValue);
140 40435 jjdelcerro
141 44738 jjdelcerro
  public int getIntOrDefault(int index, int defaultValue);
142 40435 jjdelcerro
143 44738 jjdelcerro
  public long getLongOrDefault(int index, long defaultValue);
144 40435 jjdelcerro
145 44738 jjdelcerro
  public float getFloatOrDefault(int index, float defaultValue);
146 44669 jjdelcerro
147 44738 jjdelcerro
  public double getDoubleOrDefault(int index, double defaultValue);
148 44669 jjdelcerro
149 44738 jjdelcerro
  public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue);
150 40435 jjdelcerro
151 44738 jjdelcerro
  public Date getDateOrDefault(int index, Date defaultValue);
152 40435 jjdelcerro
153 44738 jjdelcerro
  /**
154
   * Returns the value of an attribute given its name.
155
   *
156
   * @param name a string containing the name of the attribute
157
   * @return value of the specified attribute
158
   */
159
  @Override
160
  public Object get(String name);
161 40435 jjdelcerro
162 44738 jjdelcerro
  /**
163
   * Returns the value of an attribute given its position.
164
   *
165
   * @param index position of the attribute
166
   * @return value of the specified attribute
167
   */
168
  public Object get(int index);
169 40435 jjdelcerro
170 44738 jjdelcerro
  public boolean isNull(int index);
171 40435 jjdelcerro
172 44738 jjdelcerro
  public boolean isNull(String name);
173 40435 jjdelcerro
174 44738 jjdelcerro
  /**
175
   * Returns the int 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
  public int getInt(String name);
181 40435 jjdelcerro
182 44738 jjdelcerro
  /**
183
   * Returns the int value of an attribute given its position.
184
   *
185
   * @param index position of the attribute
186
   * @return value of the specified attribute
187
   */
188
  public int getInt(int index);
189 40435 jjdelcerro
190 44738 jjdelcerro
  /**
191
   * Returns the Boolean value of an attribute given its name.
192
   *
193
   * @param name name of the attribute
194
   * @return value of the specified attribute
195
   */
196
  public boolean getBoolean(String name);
197 45539 jjdelcerro
  public boolean getBooleanOrDefault(String name, boolean defaultValue);
198 44297 jjdelcerro
199 44738 jjdelcerro
  /**
200
   * Returns the Boolean value of an attribute given its position.
201
   *
202
   * @param index position of the attribute
203
   * @return value of the specified attribute
204
   */
205
  public boolean getBoolean(int index);
206 45539 jjdelcerro
  public boolean getBooleanOrDefault(int index, boolean defaultValue);
207 44297 jjdelcerro
208 44738 jjdelcerro
  /**
209
   * Returns the long value of an attribute given its name.
210
   *
211
   * @param name name of the attribute
212
   * @return value of the specified attribute
213
   */
214
  public long getLong(String name);
215 40435 jjdelcerro
216 44738 jjdelcerro
  /**
217
   * Returns the long value of an attribute given its position.
218
   *
219
   * @param index position of the attribute
220
   * @return value of the specified attribute
221
   */
222
  public long getLong(int index);
223 40435 jjdelcerro
224 44738 jjdelcerro
  /**
225
   * Returns the float value of an attribute given its name.
226
   *
227
   * @param name name of the attribute
228
   * @return value of the specified attribute
229
   */
230
  public float getFloat(String name);
231 40435 jjdelcerro
232 44738 jjdelcerro
  /**
233
   * Returns the float value of an attribute given its position.
234
   *
235
   * @param index position of the attribute
236
   * @return value of the specified attribute
237
   */
238
  public float getFloat(int index);
239 40435 jjdelcerro
240 44738 jjdelcerro
  /**
241
   * Returns the double value of an attribute given its name.
242
   *
243
   * @param name name of the attribute
244
   * @return value of the specified attribute
245
   */
246
  public double getDouble(String name);
247 40435 jjdelcerro
248 44738 jjdelcerro
  /**
249
   * Returns the double value of an attribute given its position.
250
   *
251
   * @param index position of the attribute
252
   * @return value of the specified attribute
253
   */
254
  public double getDouble(int index);
255 40435 jjdelcerro
256 44738 jjdelcerro
  /**
257
   * Returns the BigDecimal value of an attribute given its name.
258
   *
259
   * @param name name of the attribute
260
   * @return value of the specified attribute
261
   */
262
  public BigDecimal getDecimal(String name);
263 40435 jjdelcerro
264 44738 jjdelcerro
  /**
265
   * Returns the BigDecimal value of an attribute given its position.
266
   *
267
   * @param index position of the attribute
268
   * @return value of the specified attribute
269
   */
270
  public BigDecimal getDecimal(int index);
271 40435 jjdelcerro
272 44738 jjdelcerro
  /**
273
   * Returns the Date value of an attribute given its name.
274
   *
275
   * @param name name of the attribute
276
   * @return value of the specified attribute
277
   */
278 45425 jjdelcerro
  public java.sql.Date getDate(String name);
279 40435 jjdelcerro
280 44738 jjdelcerro
  /**
281
   * Returns the Date value of an attribute given its position.
282
   *
283
   * @param index position of the attribute
284
   * @return value of the specified attribute
285
   */
286 45425 jjdelcerro
  public java.sql.Date getDate(int index);
287 44767 jjdelcerro
288 45425 jjdelcerro
  public java.sql.Time getTime(String name);
289
  public java.sql.Time getTime(int index);
290 44767 jjdelcerro
291 45425 jjdelcerro
  public java.sql.Timestamp getTimestamp(String name);
292
  public java.sql.Timestamp getTimestamp(int index);
293 40435 jjdelcerro
294 44738 jjdelcerro
  /**
295
   * Returns the String value of an attribute given its name.
296
   *
297
   * @param name name of the attribute
298
   * @return value of the specified attribute
299
   */
300
  public String getString(String name);
301 40435 jjdelcerro
302 44738 jjdelcerro
  /**
303
   * Returns the String value of an attribute given its position.
304
   *
305
   * @param index position of the attribute
306
   * @return value of the specified attribute
307
   */
308
  public String getString(int index);
309 40435 jjdelcerro
310 44738 jjdelcerro
  /**
311
   * Returns the byte value of an attribute given its name.
312
   *
313
   * @param name name of the attribute
314
   * @return value of the specified attribute
315
   */
316
  public byte getByte(String name);
317 41251 jjdelcerro
318 44738 jjdelcerro
  /**
319
   * Returns the byte value of an attribute given its position.
320
   *
321
   * @param index position of the attribute
322
   * @return value of the specified attribute
323
   */
324
  public byte getByte(int index);
325 44346 jjdelcerro
326 44738 jjdelcerro
  /**
327
   * Returns the Geometry value of an attribute given its name.
328
   *
329
   * @param name name of the attribute
330
   * @return value of the specified attribute
331
   */
332
  public Geometry getGeometry(String name);
333 44376 jjdelcerro
334 44738 jjdelcerro
  /**
335
   * Returns the Geometry value of an attribute given its position.
336
   *
337
   * @param index position of the attribute
338
   * @return value of the specified attribute
339
   */
340
  public Geometry getGeometry(int index);
341 44376 jjdelcerro
342 44738 jjdelcerro
  public byte[] getByteArray(String name);
343
344
  public byte[] getByteArray(int index);
345
346
  /**
347
   * Returns the array value of an attribute given its name.
348
   *
349
   * @param name name of the attribute
350
   * @return value of the specified attribute
351
   */
352
  public Object[] getArray(String name);
353
354
  /**
355
   * Returns the array value of an attribute given its position.
356
   *
357
   * @param index position of the attribute
358
   * @return value of the specified attribute
359
   */
360
  public Object[] getArray(int index);
361
362
  /**
363
   * Returns the Feature value of an attribute given its name.
364
   *
365
   * @param name name of the attribute
366
   * @return value of the specified attribute
367
   */
368
  public Feature getFeature(String name);
369
370
  /**
371
   * Returns the Feature value of an attribute given its position.
372
   *
373
   * @param index position of the attribute
374
   * @return value of the specified attribute
375
   */
376
  public Feature getFeature(int index);
377
378
  public Object getFromProfile(int index);
379
380
  public Object getFromProfile(String name);
381
382
  /**
383
   * Envelope (AKA extent or bounding box) of the default geometry attribute.
384
   *
385
   * @return Envelope of the default geometry attribute
386
   */
387
  public Envelope getDefaultEnvelope();
388
389
  /**
390
   * Returns the value of the default geometry attribute, which is a
391
   * {@link Geometry}.
392
   *
393
   * @return value of the default geometry attribute
394
   */
395
  public Geometry getDefaultGeometry();
396
397
  /**
398
   * Returns a list with the values of this Feature's geometry attributes.
399
   *
400
   * @return a list with the values of this Feature's geometry attributes
401
   */
402
  public List getGeometries();
403
404
  /**
405
   * Returns the Spatial Reference System in which is expressed the default
406
   * geometry attribute.
407
   *
408
   * @return A string containing the default geometry attribute SRS.
409
   */
410
  public IProjection getDefaultSRS();
411
412
  /**
413
   * Returns a list with the Spatial Reference Systems in which are expressed
414
   * this Feature's geometry attributes.
415
   *
416
   * @return a list with the Spatial Reference Systems.
417
   */
418
  public List getSRSs();
419
420 44767 jjdelcerro
//  public Time getDefaultTime();
421
//
422
//  public Time getTime(int index);
423
//
424
//  public Time getTime(String name);
425
//
426
//  /**
427
//   * Returns the instant value of an attribute given its position.
428
//   *
429
//   * @param index position of the attribute
430
//   * @return value of the specified attribute
431
//   */
432
//  public Instant getInstant(int index);
433
//
434
//  /**
435
//   * Returns the instant value of an attribute given its name.
436
//   *
437
//   * @param name a string containing the name of the attribute
438
//   * @return value of the specified attribute
439
//   */
440
//  public Instant getInstant(String name);
441
//
442
//  /**
443
//   * Returns the interval value of an attribute given its position.
444
//   *
445
//   * @param index position of the attribute
446
//   * @return value of the specified attribute
447
//   */
448
//  public Interval getInterval(int index);
449
//
450
//  /**
451
//   * Returns the interval value of an attribute given its name.
452
//   *
453
//   * @param name a string containing the name of the attribute
454
//   * @return value of the specified attribute
455
//   */
456
//  public Interval getInterval(String name);
457 44738 jjdelcerro
458
  public DynObject getAsDynObject();
459
460
  /**
461
   * This lets Feature be used eaily with {@link Evaluator}
462
   *
463
   * @return An instance of {@link EvaluatorData} which returns the data of this
464
   * feature
465
   */
466
  public EvaluatorData getEvaluatorData();
467
468
  /**
469
   * Return the store associated to this feature.
470
   *
471
   * @return the FeatureStore of the feature.
472
   */
473
  public FeatureStore getStore();
474
475
  public String getLabelOfValue(String name);
476
477
  public Object getExtraValue(int index);
478
479
  public Object getExtraValue(String name);
480
481
  public boolean hasExtraValue(String name);
482 44858 jjdelcerro
483
  public void setExtraValue(String name, Object value);
484 44740 jjdelcerro
485 45221 omartinez
   public boolean hasValue(String name);
486 44740 jjdelcerro
//  public Feature getRelatedFeature(String name);
487
//
488
//  public List<Feature> getRelatedFeatures(String name);
489
490 40435 jjdelcerro
}