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