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