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