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 @ 47785
History | View | Annotate | Download (15 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 | 47078 | jjdelcerro | import org.gvsig.expressionevaluator.Expression; |
31 | 41251 | jjdelcerro | import org.gvsig.fmap.dal.exception.DataException; |
32 | 40435 | jjdelcerro | import org.gvsig.fmap.geom.Geometry; |
33 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
34 | 44767 | jjdelcerro | //import org.gvsig.timesupport.Instant;
|
35 | //import org.gvsig.timesupport.Interval;
|
||
36 | //import org.gvsig.timesupport.Time;
|
||
37 | 40435 | jjdelcerro | import org.gvsig.tools.dynobject.DynObject; |
38 | import org.gvsig.tools.evaluator.Evaluator; |
||
39 | import org.gvsig.tools.evaluator.EvaluatorData; |
||
40 | 45013 | jjdelcerro | import org.gvsig.tools.util.GetItemByKeyWithSizeAndGetKeys; |
41 | 45425 | jjdelcerro | import org.gvsig.json.SupportToJson; |
42 | 45738 | fdiaz | import org.gvsig.tools.dataTypes.DataType; |
43 | 40435 | jjdelcerro | |
44 | /**
|
||
45 | 44738 | jjdelcerro | * <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 | 40435 | jjdelcerro | * <p>
|
51 | 44738 | jjdelcerro | * 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 | 40435 | jjdelcerro | * <p>
|
55 | * Features are not editable as such. To edit a Feature you have to obtain an
|
||
56 | 44738 | jjdelcerro | * 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 | 40435 | jjdelcerro | * <br>
|
61 | 44738 | jjdelcerro | * <p>
|
62 | * The Feature:
|
||
63 | * <ul>
|
||
64 | * <li>Has an unique identifier <code>FeatureReference</code> to recognize our
|
||
65 | 45739 | jjdelcerro | * Feature from each other from the same data store
|
66 | 44738 | jjdelcerro | * <li>Has a <code>FeatureType</code> that describes the Feature characteristics
|
67 | 45739 | jjdelcerro | * (attributes, data types, default geometry, validation rules).
|
68 | * <li>Can obtain a copy of itself.
|
||
69 | 44738 | jjdelcerro | * <li>Can obtain its default geometry attribute and also a list with all the
|
70 | 45739 | jjdelcerro | * geometry attributes.
|
71 | 44738 | jjdelcerro | * <li>Can obtain its default Spatial Reference System and also a list with all
|
72 | 45739 | jjdelcerro | * the SRSs used in the geometry attributes.
|
73 | 44738 | jjdelcerro | * <li>Can obtain the envelope (extent) of the default geometry attribute.
|
74 | 45739 | jjdelcerro | * <li>Can obtain the editable instance of the Feature.
|
75 | 44738 | jjdelcerro | * <li>Has a set of utility methods to read attributes when their type is known,
|
76 | 45739 | jjdelcerro | * by both index and name.
|
77 | 44738 | jjdelcerro | * </ul>
|
78 | 40435 | jjdelcerro | *
|
79 | */
|
||
80 | 45425 | jjdelcerro | public interface Feature extends GetItemByKeyWithSizeAndGetKeys<String, Object>, SupportToJson { |
81 | 40435 | jjdelcerro | |
82 | 45739 | jjdelcerro | 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 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
94 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
101 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
108 | 45739 | jjdelcerro | public void validate(int mode) throws DataException; |
109 | |||
110 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
118 | 44738 | jjdelcerro | public Object getOrDefault(String name, Object defaultValue); |
119 | 40435 | jjdelcerro | |
120 | 45738 | fdiaz | public Object getOrDefault(String name, DataType type, Object defaultValue); |
121 | |||
122 | public Object getOrDefault(String name, int type, Object defaultValue); |
||
123 | |||
124 | 44738 | jjdelcerro | public String getStringOrDefault(String name, String defaultValue); |
125 | 40435 | jjdelcerro | |
126 | 44738 | jjdelcerro | public int getIntOrDefault(String name, int defaultValue); |
127 | 40435 | jjdelcerro | |
128 | 44738 | jjdelcerro | public long getLongOrDefault(String name, long defaultValue); |
129 | 40435 | jjdelcerro | |
130 | 44738 | jjdelcerro | public float getFloatOrDefault(String name, float defaultValue); |
131 | 40435 | jjdelcerro | |
132 | 44738 | jjdelcerro | public double getDoubleOrDefault(String name, double defaultValue); |
133 | 40435 | jjdelcerro | |
134 | 44738 | jjdelcerro | public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue); |
135 | 40435 | jjdelcerro | |
136 | 44738 | jjdelcerro | public Date getDateOrDefault(String name, Date defaultValue); |
137 | 40435 | jjdelcerro | |
138 | 44738 | jjdelcerro | public Object getOrDefault(int index, Object defaultValue); |
139 | 40435 | jjdelcerro | |
140 | 44738 | jjdelcerro | public String getStringOrDefault(int index, String defaultValue); |
141 | 40435 | jjdelcerro | |
142 | 44738 | jjdelcerro | public int getIntOrDefault(int index, int defaultValue); |
143 | 40435 | jjdelcerro | |
144 | 44738 | jjdelcerro | public long getLongOrDefault(int index, long defaultValue); |
145 | 40435 | jjdelcerro | |
146 | 44738 | jjdelcerro | public float getFloatOrDefault(int index, float defaultValue); |
147 | 44669 | jjdelcerro | |
148 | 44738 | jjdelcerro | public double getDoubleOrDefault(int index, double defaultValue); |
149 | 44669 | jjdelcerro | |
150 | 44738 | jjdelcerro | public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue); |
151 | 40435 | jjdelcerro | |
152 | 44738 | jjdelcerro | public Date getDateOrDefault(int index, Date defaultValue); |
153 | 40435 | jjdelcerro | |
154 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
163 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
171 | 44738 | jjdelcerro | public boolean isNull(int index); |
172 | 40435 | jjdelcerro | |
173 | 44738 | jjdelcerro | public boolean isNull(String name); |
174 | 40435 | jjdelcerro | |
175 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
183 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
191 | 44738 | jjdelcerro | /**
|
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 | 45539 | jjdelcerro | public boolean getBooleanOrDefault(String name, boolean defaultValue); |
199 | 44297 | jjdelcerro | |
200 | 44738 | jjdelcerro | /**
|
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 | 45539 | jjdelcerro | public boolean getBooleanOrDefault(int index, boolean defaultValue); |
208 | 44297 | jjdelcerro | |
209 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
217 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
225 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
233 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
241 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
249 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
257 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
265 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
273 | 44738 | jjdelcerro | /**
|
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 | 45425 | jjdelcerro | public java.sql.Date getDate(String name); |
280 | 40435 | jjdelcerro | |
281 | 44738 | jjdelcerro | /**
|
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 | 45425 | jjdelcerro | public java.sql.Date getDate(int index); |
288 | 44767 | jjdelcerro | |
289 | 45425 | jjdelcerro | public java.sql.Time getTime(String name); |
290 | public java.sql.Time getTime(int index); |
||
291 | 44767 | jjdelcerro | |
292 | 45425 | jjdelcerro | public java.sql.Timestamp getTimestamp(String name); |
293 | public java.sql.Timestamp getTimestamp(int index); |
||
294 | 40435 | jjdelcerro | |
295 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
303 | 44738 | jjdelcerro | /**
|
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 | 40435 | jjdelcerro | |
311 | 44738 | jjdelcerro | /**
|
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 | 41251 | jjdelcerro | |
319 | 44738 | jjdelcerro | /**
|
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 | 44346 | jjdelcerro | |
327 | 44738 | jjdelcerro | /**
|
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 | 44376 | jjdelcerro | |
335 | 44738 | jjdelcerro | /**
|
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 | 44376 | jjdelcerro | |
343 | 44738 | jjdelcerro | 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 | 44767 | jjdelcerro | // 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 | 44738 | jjdelcerro | |
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 | 44858 | jjdelcerro | |
484 | public void setExtraValue(String name, Object value); |
||
485 | 44740 | jjdelcerro | |
486 | 45221 | omartinez | public boolean hasValue(String name); |
487 | 44740 | jjdelcerro | // public Feature getRelatedFeature(String name);
|
488 | //
|
||
489 | // public List<Feature> getRelatedFeatures(String name);
|
||
490 | |||
491 | 45968 | jjdelcerro | public String format(String name); |
492 | |||
493 | public String format(int index); |
||
494 | 46966 | fdiaz | |
495 | public Feature getForeignFeature(String attrName); |
||
496 | 47078 | jjdelcerro | |
497 | public Expression createFilter(); |
||
498 | 46966 | fdiaz | |
499 | 47436 | fdiaz | public boolean isBroken(); |
500 | |||
501 | 40435 | jjdelcerro | } |