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 @ 45539
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.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 |
|
42 |
/**
|
43 |
* <p>
|
44 |
* Represents the basic data unit of a tabular structure, equivalent to a record
|
45 |
* in a data base table. In SIG domain, a Feature is a compound data structure
|
46 |
* that may contain a geographic component. The conventional term Feature comes
|
47 |
* from the term cartographic feature and both represent the same concept.
|
48 |
* </p>
|
49 |
* <p>
|
50 |
* 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 |
* </p>
|
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 |
* </p>
|
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</li>
|
67 |
* <li>Has a <code>FeatureType</code> that describes the Feature characteristics
|
68 |
* (attributes, data types, default geometry, validation rules).</li>
|
69 |
* <li>Can obtain a copy of itself.</li>
|
70 |
* <li>Can obtain its default geometry attribute and also a list with all the
|
71 |
* geometry attributes.</li>
|
72 |
* <li>Can obtain its default Spatial Reference System and also a list with all
|
73 |
* the SRSs used in the geometry attributes.</li>
|
74 |
* <li>Can obtain the envelope (extent) of the default geometry attribute.
|
75 |
* <li>Can obtain the editable instance of the Feature.</li>
|
76 |
* <li>Has a set of utility methods to read attributes when their type is known,
|
77 |
* by both index and name.</li>
|
78 |
* </ul>
|
79 |
* </p>
|
80 |
*
|
81 |
*/
|
82 |
public interface Feature extends GetItemByKeyWithSizeAndGetKeys<String, Object>, SupportToJson { |
83 |
|
84 |
/**
|
85 |
* Returns a unique identifier for this Feature in the associated store.
|
86 |
*
|
87 |
* @return a unique FeatureReference in the associated store
|
88 |
*/
|
89 |
public FeatureReference getReference();
|
90 |
|
91 |
/**
|
92 |
* Returns the FeatureType that describes the structure of this Feature.
|
93 |
*
|
94 |
* @return a FeatureType describing this Feature structure.
|
95 |
*/
|
96 |
public FeatureType getType();
|
97 |
|
98 |
/**
|
99 |
* Creates and returns a copy of this
|
100 |
*
|
101 |
* @return a new instance of Feature which is equal to this
|
102 |
*/
|
103 |
public Feature getCopy();
|
104 |
|
105 |
/**
|
106 |
* Mode that indicates the validation of all FeatureRules
|
107 |
*/
|
108 |
static final int ALL = 0; |
109 |
|
110 |
/**
|
111 |
* Mode that indicates the validation of the update FeatureRules
|
112 |
*/
|
113 |
static final int UPDATE = 1; |
114 |
|
115 |
/**
|
116 |
* Mode that indicates the validation of the finish editing FeatureRules
|
117 |
*/
|
118 |
static final int FINISH_EDITING = 2; |
119 |
|
120 |
/**
|
121 |
* Validates this Feature by applying the <code>FeatureRules</code>
|
122 |
* corresponding to the given mode.
|
123 |
*
|
124 |
* @param mode one of the constants {ALL, UPDATE, FINISH_EDITING}
|
125 |
* @throws DataException on validation errors
|
126 |
*/
|
127 |
public void validate(int mode) throws DataException; |
128 |
|
129 |
/**
|
130 |
* Returns the editable instance of this Feature. EditableFeature offers
|
131 |
* methods for Feature editing.
|
132 |
*
|
133 |
* @return EditableFeature of this
|
134 |
*/
|
135 |
public EditableFeature getEditable();
|
136 |
|
137 |
public Object getOrDefault(String name, Object defaultValue); |
138 |
|
139 |
public String getStringOrDefault(String name, String defaultValue); |
140 |
|
141 |
public int getIntOrDefault(String name, int defaultValue); |
142 |
|
143 |
public long getLongOrDefault(String name, long defaultValue); |
144 |
|
145 |
public float getFloatOrDefault(String name, float defaultValue); |
146 |
|
147 |
public double getDoubleOrDefault(String name, double defaultValue); |
148 |
|
149 |
public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue); |
150 |
|
151 |
public Date getDateOrDefault(String name, Date defaultValue); |
152 |
|
153 |
public Object getOrDefault(int index, Object defaultValue); |
154 |
|
155 |
public String getStringOrDefault(int index, String defaultValue); |
156 |
|
157 |
public int getIntOrDefault(int index, int defaultValue); |
158 |
|
159 |
public long getLongOrDefault(int index, long defaultValue); |
160 |
|
161 |
public float getFloatOrDefault(int index, float defaultValue); |
162 |
|
163 |
public double getDoubleOrDefault(int index, double defaultValue); |
164 |
|
165 |
public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue); |
166 |
|
167 |
public Date getDateOrDefault(int index, Date defaultValue); |
168 |
|
169 |
/**
|
170 |
* Returns the value of an attribute given its name.
|
171 |
*
|
172 |
* @param name a string containing the name of the attribute
|
173 |
* @return value of the specified attribute
|
174 |
*/
|
175 |
@Override
|
176 |
public Object get(String name); |
177 |
|
178 |
/**
|
179 |
* Returns the value of an attribute given its position.
|
180 |
*
|
181 |
* @param index position of the attribute
|
182 |
* @return value of the specified attribute
|
183 |
*/
|
184 |
public Object get(int index); |
185 |
|
186 |
public boolean isNull(int index); |
187 |
|
188 |
public boolean isNull(String name); |
189 |
|
190 |
/**
|
191 |
* Returns the int value of an attribute given its name.
|
192 |
*
|
193 |
* @param name a string containing the name of the attribute
|
194 |
* @return value of the specified attribute
|
195 |
*/
|
196 |
public int getInt(String name); |
197 |
|
198 |
/**
|
199 |
* Returns the int value of an attribute given its position.
|
200 |
*
|
201 |
* @param index position of the attribute
|
202 |
* @return value of the specified attribute
|
203 |
*/
|
204 |
public int getInt(int index); |
205 |
|
206 |
/**
|
207 |
* Returns the Boolean value of an attribute given its name.
|
208 |
*
|
209 |
* @param name name of the attribute
|
210 |
* @return value of the specified attribute
|
211 |
*/
|
212 |
public boolean getBoolean(String name); |
213 |
public boolean getBooleanOrDefault(String name, boolean defaultValue); |
214 |
|
215 |
/**
|
216 |
* Returns the Boolean value of an attribute given its position.
|
217 |
*
|
218 |
* @param index position of the attribute
|
219 |
* @return value of the specified attribute
|
220 |
*/
|
221 |
public boolean getBoolean(int index); |
222 |
public boolean getBooleanOrDefault(int index, boolean defaultValue); |
223 |
|
224 |
/**
|
225 |
* Returns the long 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 long getLong(String name); |
231 |
|
232 |
/**
|
233 |
* Returns the long 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 long getLong(int index); |
239 |
|
240 |
/**
|
241 |
* Returns the float 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 float getFloat(String name); |
247 |
|
248 |
/**
|
249 |
* Returns the float 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 float getFloat(int index); |
255 |
|
256 |
/**
|
257 |
* Returns the double 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 double getDouble(String name); |
263 |
|
264 |
/**
|
265 |
* Returns the double 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 double getDouble(int index); |
271 |
|
272 |
/**
|
273 |
* Returns the BigDecimal value of an attribute given its name.
|
274 |
*
|
275 |
* @param name name of the attribute
|
276 |
* @return value of the specified attribute
|
277 |
*/
|
278 |
public BigDecimal getDecimal(String name); |
279 |
|
280 |
/**
|
281 |
* Returns the BigDecimal value of an attribute given its position.
|
282 |
*
|
283 |
* @param index position of the attribute
|
284 |
* @return value of the specified attribute
|
285 |
*/
|
286 |
public BigDecimal getDecimal(int index); |
287 |
|
288 |
/**
|
289 |
* Returns the Date value of an attribute given its name.
|
290 |
*
|
291 |
* @param name name of the attribute
|
292 |
* @return value of the specified attribute
|
293 |
*/
|
294 |
public java.sql.Date getDate(String name); |
295 |
|
296 |
/**
|
297 |
* Returns the Date value of an attribute given its position.
|
298 |
*
|
299 |
* @param index position of the attribute
|
300 |
* @return value of the specified attribute
|
301 |
*/
|
302 |
public java.sql.Date getDate(int index); |
303 |
|
304 |
public java.sql.Time getTime(String name); |
305 |
public java.sql.Time getTime(int index); |
306 |
|
307 |
public java.sql.Timestamp getTimestamp(String name); |
308 |
public java.sql.Timestamp getTimestamp(int index); |
309 |
|
310 |
/**
|
311 |
* Returns the String 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 String getString(String name); |
317 |
|
318 |
/**
|
319 |
* Returns the String 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 String getString(int index); |
325 |
|
326 |
/**
|
327 |
* Returns the byte 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 byte getByte(String name); |
333 |
|
334 |
/**
|
335 |
* Returns the byte 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 byte getByte(int index); |
341 |
|
342 |
/**
|
343 |
* Returns the Geometry value of an attribute given its name.
|
344 |
*
|
345 |
* @param name name of the attribute
|
346 |
* @return value of the specified attribute
|
347 |
*/
|
348 |
public Geometry getGeometry(String name); |
349 |
|
350 |
/**
|
351 |
* Returns the Geometry value of an attribute given its position.
|
352 |
*
|
353 |
* @param index position of the attribute
|
354 |
* @return value of the specified attribute
|
355 |
*/
|
356 |
public Geometry getGeometry(int index); |
357 |
|
358 |
public byte[] getByteArray(String name); |
359 |
|
360 |
public byte[] getByteArray(int index); |
361 |
|
362 |
/**
|
363 |
* Returns the array 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 Object[] getArray(String name); |
369 |
|
370 |
/**
|
371 |
* Returns the array 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 Object[] getArray(int index); |
377 |
|
378 |
/**
|
379 |
* Returns the Feature value of an attribute given its name.
|
380 |
*
|
381 |
* @param name name of the attribute
|
382 |
* @return value of the specified attribute
|
383 |
*/
|
384 |
public Feature getFeature(String name); |
385 |
|
386 |
/**
|
387 |
* Returns the Feature value of an attribute given its position.
|
388 |
*
|
389 |
* @param index position of the attribute
|
390 |
* @return value of the specified attribute
|
391 |
*/
|
392 |
public Feature getFeature(int index); |
393 |
|
394 |
public Object getFromProfile(int index); |
395 |
|
396 |
public Object getFromProfile(String name); |
397 |
|
398 |
/**
|
399 |
* Envelope (AKA extent or bounding box) of the default geometry attribute.
|
400 |
*
|
401 |
* @return Envelope of the default geometry attribute
|
402 |
*/
|
403 |
public Envelope getDefaultEnvelope();
|
404 |
|
405 |
/**
|
406 |
* Returns the value of the default geometry attribute, which is a
|
407 |
* {@link Geometry}.
|
408 |
*
|
409 |
* @return value of the default geometry attribute
|
410 |
*/
|
411 |
public Geometry getDefaultGeometry();
|
412 |
|
413 |
/**
|
414 |
* Returns a list with the values of this Feature's geometry attributes.
|
415 |
*
|
416 |
* @return a list with the values of this Feature's geometry attributes
|
417 |
*/
|
418 |
public List getGeometries(); |
419 |
|
420 |
/**
|
421 |
* Returns the Spatial Reference System in which is expressed the default
|
422 |
* geometry attribute.
|
423 |
*
|
424 |
* @return A string containing the default geometry attribute SRS.
|
425 |
*/
|
426 |
public IProjection getDefaultSRS();
|
427 |
|
428 |
/**
|
429 |
* Returns a list with the Spatial Reference Systems in which are expressed
|
430 |
* this Feature's geometry attributes.
|
431 |
*
|
432 |
* @return a list with the Spatial Reference Systems.
|
433 |
*/
|
434 |
public List getSRSs(); |
435 |
|
436 |
// public Time getDefaultTime();
|
437 |
//
|
438 |
// public Time getTime(int index);
|
439 |
//
|
440 |
// public Time getTime(String name);
|
441 |
//
|
442 |
// /**
|
443 |
// * Returns the instant 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 Instant getInstant(int index);
|
449 |
//
|
450 |
// /**
|
451 |
// * Returns the instant 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 Instant getInstant(String name);
|
457 |
//
|
458 |
// /**
|
459 |
// * Returns the interval value of an attribute given its position.
|
460 |
// *
|
461 |
// * @param index position of the attribute
|
462 |
// * @return value of the specified attribute
|
463 |
// */
|
464 |
// public Interval getInterval(int index);
|
465 |
//
|
466 |
// /**
|
467 |
// * Returns the interval value of an attribute given its name.
|
468 |
// *
|
469 |
// * @param name a string containing the name of the attribute
|
470 |
// * @return value of the specified attribute
|
471 |
// */
|
472 |
// public Interval getInterval(String name);
|
473 |
|
474 |
public DynObject getAsDynObject();
|
475 |
|
476 |
/**
|
477 |
* This lets Feature be used eaily with {@link Evaluator}
|
478 |
*
|
479 |
* @return An instance of {@link EvaluatorData} which returns the data of this
|
480 |
* feature
|
481 |
*/
|
482 |
public EvaluatorData getEvaluatorData();
|
483 |
|
484 |
/**
|
485 |
* Return the store associated to this feature.
|
486 |
*
|
487 |
* @return the FeatureStore of the feature.
|
488 |
*/
|
489 |
public FeatureStore getStore();
|
490 |
|
491 |
public String getLabelOfValue(String name); |
492 |
|
493 |
public Object getExtraValue(int index); |
494 |
|
495 |
public Object getExtraValue(String name); |
496 |
|
497 |
public boolean hasExtraValue(String name); |
498 |
|
499 |
public void setExtraValue(String name, Object value); |
500 |
|
501 |
public boolean hasValue(String name); |
502 |
// public Feature getRelatedFeature(String name);
|
503 |
//
|
504 |
// public List<Feature> getRelatedFeatures(String name);
|
505 |
|
506 |
} |