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 @ 45968
History | View | Annotate | Download (14.8 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 |
import org.gvsig.tools.dataTypes.DataType; |
42 |
|
43 |
/**
|
44 |
* <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 |
* <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 |
* Features are not editable as such. To edit a Feature you have to obtain an
|
55 |
* 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 |
* <br>
|
60 |
* <p>
|
61 |
* The Feature:
|
62 |
* <ul>
|
63 |
* <li>Has an unique identifier <code>FeatureReference</code> to recognize our
|
64 |
* Feature from each other from the same data store
|
65 |
* <li>Has a <code>FeatureType</code> that describes the Feature characteristics
|
66 |
* (attributes, data types, default geometry, validation rules).
|
67 |
* <li>Can obtain a copy of itself.
|
68 |
* <li>Can obtain its default geometry attribute and also a list with all the
|
69 |
* geometry attributes.
|
70 |
* <li>Can obtain its default Spatial Reference System and also a list with all
|
71 |
* the SRSs used in the geometry attributes.
|
72 |
* <li>Can obtain the envelope (extent) of the default geometry attribute.
|
73 |
* <li>Can obtain the editable instance of the Feature.
|
74 |
* <li>Has a set of utility methods to read attributes when their type is known,
|
75 |
* by both index and name.
|
76 |
* </ul>
|
77 |
*
|
78 |
*/
|
79 |
public interface Feature extends GetItemByKeyWithSizeAndGetKeys<String, Object>, SupportToJson { |
80 |
|
81 |
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 |
/**
|
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 |
|
93 |
/**
|
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 |
|
100 |
/**
|
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 |
|
107 |
public void validate(int mode) throws DataException; |
108 |
|
109 |
/**
|
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 |
|
117 |
public Object getOrDefault(String name, Object defaultValue); |
118 |
|
119 |
public Object getOrDefault(String name, DataType type, Object defaultValue); |
120 |
|
121 |
public Object getOrDefault(String name, int type, Object defaultValue); |
122 |
|
123 |
public String getStringOrDefault(String name, String defaultValue); |
124 |
|
125 |
public int getIntOrDefault(String name, int defaultValue); |
126 |
|
127 |
public long getLongOrDefault(String name, long defaultValue); |
128 |
|
129 |
public float getFloatOrDefault(String name, float defaultValue); |
130 |
|
131 |
public double getDoubleOrDefault(String name, double defaultValue); |
132 |
|
133 |
public BigDecimal getDecimalOrDefault(String name, BigDecimal defaultValue); |
134 |
|
135 |
public Date getDateOrDefault(String name, Date defaultValue); |
136 |
|
137 |
public Object getOrDefault(int index, Object defaultValue); |
138 |
|
139 |
public String getStringOrDefault(int index, String defaultValue); |
140 |
|
141 |
public int getIntOrDefault(int index, int defaultValue); |
142 |
|
143 |
public long getLongOrDefault(int index, long defaultValue); |
144 |
|
145 |
public float getFloatOrDefault(int index, float defaultValue); |
146 |
|
147 |
public double getDoubleOrDefault(int index, double defaultValue); |
148 |
|
149 |
public BigDecimal getDecimalOrDefault(int index, BigDecimal defaultValue); |
150 |
|
151 |
public Date getDateOrDefault(int index, Date defaultValue); |
152 |
|
153 |
/**
|
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 |
|
162 |
/**
|
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 |
|
170 |
public boolean isNull(int index); |
171 |
|
172 |
public boolean isNull(String name); |
173 |
|
174 |
/**
|
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 |
|
182 |
/**
|
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 |
|
190 |
/**
|
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 |
public boolean getBooleanOrDefault(String name, boolean defaultValue); |
198 |
|
199 |
/**
|
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 |
public boolean getBooleanOrDefault(int index, boolean defaultValue); |
207 |
|
208 |
/**
|
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 |
|
216 |
/**
|
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 |
|
224 |
/**
|
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 |
|
232 |
/**
|
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 |
|
240 |
/**
|
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 |
|
248 |
/**
|
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 |
|
256 |
/**
|
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 |
|
264 |
/**
|
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 |
|
272 |
/**
|
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 |
public java.sql.Date getDate(String name); |
279 |
|
280 |
/**
|
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 |
public java.sql.Date getDate(int index); |
287 |
|
288 |
public java.sql.Time getTime(String name); |
289 |
public java.sql.Time getTime(int index); |
290 |
|
291 |
public java.sql.Timestamp getTimestamp(String name); |
292 |
public java.sql.Timestamp getTimestamp(int index); |
293 |
|
294 |
/**
|
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 |
|
302 |
/**
|
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 |
|
310 |
/**
|
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 |
|
318 |
/**
|
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 |
|
326 |
/**
|
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 |
|
334 |
/**
|
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 |
|
342 |
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 |
// 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 |
|
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 |
|
483 |
public void setExtraValue(String name, Object value); |
484 |
|
485 |
public boolean hasValue(String name); |
486 |
// public Feature getRelatedFeature(String name);
|
487 |
//
|
488 |
// public List<Feature> getRelatedFeatures(String name);
|
489 |
|
490 |
public String format(String name); |
491 |
|
492 |
public String format(int index); |
493 |
} |