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 @ 40559
History | View | Annotate | Download (12.2 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 | import java.util.Date; |
||
27 | import java.util.List; |
||
28 | |||
29 | import org.cresques.cts.IProjection; |
||
30 | |||
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.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 | */
|
||
116 | public void validate(int mode); |
||
117 | |||
118 | /**
|
||
119 | * Returns the editable instance of this Feature.
|
||
120 | * EditableFeature offers methods for Feature editing.
|
||
121 | *
|
||
122 | * @return
|
||
123 | * EditableFeature of this
|
||
124 | */
|
||
125 | public EditableFeature getEditable();
|
||
126 | |||
127 | /**
|
||
128 | * Returns the value of an attribute given its name.
|
||
129 | *
|
||
130 | * @param name
|
||
131 | * a string containing the name of the attribute
|
||
132 | * @return
|
||
133 | * value of the specified attribute
|
||
134 | */
|
||
135 | public Object get(String name); |
||
136 | |||
137 | /**
|
||
138 | * Returns the value of an attribute given its position.
|
||
139 | *
|
||
140 | * @param index
|
||
141 | * position of the attribute
|
||
142 | * @return
|
||
143 | * value of the specified attribute
|
||
144 | */
|
||
145 | public Object get(int index); |
||
146 | |||
147 | /**
|
||
148 | * Returns the int value of an attribute given its name.
|
||
149 | *
|
||
150 | * @param name
|
||
151 | * a string containing the name of the attribute
|
||
152 | * @return
|
||
153 | * value of the specified attribute
|
||
154 | */
|
||
155 | public int getInt(String name); |
||
156 | |||
157 | /**
|
||
158 | * Returns the int value of an attribute given its position.
|
||
159 | *
|
||
160 | * @param index
|
||
161 | * position of the attribute
|
||
162 | * @return
|
||
163 | * value of the specified attribute
|
||
164 | */
|
||
165 | public int getInt(int index); |
||
166 | |||
167 | /**
|
||
168 | * Returns the Boolean value of an attribute given its name.
|
||
169 | *
|
||
170 | * @param name
|
||
171 | * name of the attribute
|
||
172 | * @return
|
||
173 | * value of the specified attribute
|
||
174 | */
|
||
175 | public boolean getBoolean(String name); |
||
176 | |||
177 | /**
|
||
178 | * Returns the Boolean value of an attribute given its position.
|
||
179 | *
|
||
180 | * @param index
|
||
181 | * position of the attribute
|
||
182 | * @return
|
||
183 | * value of the specified attribute
|
||
184 | */
|
||
185 | public boolean getBoolean(int index); |
||
186 | |||
187 | /**
|
||
188 | * Returns the long value of an attribute given its name.
|
||
189 | *
|
||
190 | * @param name
|
||
191 | * name of the attribute
|
||
192 | * @return
|
||
193 | * value of the specified attribute
|
||
194 | */
|
||
195 | public long getLong(String name); |
||
196 | |||
197 | /**
|
||
198 | * Returns the long value of an attribute given its position.
|
||
199 | *
|
||
200 | * @param index
|
||
201 | * position of the attribute
|
||
202 | * @return
|
||
203 | * value of the specified attribute
|
||
204 | */
|
||
205 | public long getLong(int index); |
||
206 | |||
207 | /**
|
||
208 | * Returns the float value of an attribute given its name.
|
||
209 | *
|
||
210 | * @param name
|
||
211 | * name of the attribute
|
||
212 | * @return
|
||
213 | * value of the specified attribute
|
||
214 | */
|
||
215 | public float getFloat(String name); |
||
216 | |||
217 | /**
|
||
218 | * Returns the float value of an attribute given its position.
|
||
219 | *
|
||
220 | * @param index
|
||
221 | * position of the attribute
|
||
222 | * @return
|
||
223 | * value of the specified attribute
|
||
224 | */
|
||
225 | public float getFloat(int index); |
||
226 | |||
227 | /**
|
||
228 | * Returns the double value of an attribute given its name.
|
||
229 | *
|
||
230 | * @param name
|
||
231 | * name of the attribute
|
||
232 | * @return
|
||
233 | * value of the specified attribute
|
||
234 | */
|
||
235 | public double getDouble(String name); |
||
236 | |||
237 | /**
|
||
238 | * Returns the double value of an attribute given its position.
|
||
239 | *
|
||
240 | * @param index
|
||
241 | * position of the attribute
|
||
242 | * @return
|
||
243 | * value of the specified attribute
|
||
244 | */
|
||
245 | public double getDouble(int index); |
||
246 | |||
247 | /**
|
||
248 | * Returns the Date value of an attribute given its name.
|
||
249 | *
|
||
250 | * @param name
|
||
251 | * name of the attribute
|
||
252 | * @return
|
||
253 | * value of the specified attribute
|
||
254 | */
|
||
255 | public Date getDate(String name); |
||
256 | |||
257 | /**
|
||
258 | * Returns the Date value of an attribute given its position.
|
||
259 | *
|
||
260 | * @param index
|
||
261 | * position of the attribute
|
||
262 | * @return
|
||
263 | * value of the specified attribute
|
||
264 | */
|
||
265 | public Date getDate(int index); |
||
266 | |||
267 | /**
|
||
268 | * Returns the String value of an attribute given its name.
|
||
269 | *
|
||
270 | * @param name
|
||
271 | * name of the attribute
|
||
272 | * @return
|
||
273 | * value of the specified attribute
|
||
274 | */
|
||
275 | public String getString(String name); |
||
276 | |||
277 | /**
|
||
278 | * Returns the String value of an attribute given its position.
|
||
279 | *
|
||
280 | * @param index
|
||
281 | * position of the attribute
|
||
282 | * @return
|
||
283 | * value of the specified attribute
|
||
284 | */
|
||
285 | public String getString(int index); |
||
286 | |||
287 | /**
|
||
288 | * Returns the byte value of an attribute given its name.
|
||
289 | *
|
||
290 | * @param name
|
||
291 | * name of the attribute
|
||
292 | * @return
|
||
293 | * value of the specified attribute
|
||
294 | */
|
||
295 | public byte getByte(String name); |
||
296 | |||
297 | /**
|
||
298 | * Returns the byte value of an attribute given its position.
|
||
299 | *
|
||
300 | * @param index
|
||
301 | * position of the attribute
|
||
302 | * @return
|
||
303 | * value of the specified attribute
|
||
304 | */
|
||
305 | public byte getByte(int index); |
||
306 | |||
307 | /**
|
||
308 | * Returns the Geometry value of an attribute given its name.
|
||
309 | *
|
||
310 | * @param name
|
||
311 | * name of the attribute
|
||
312 | * @return
|
||
313 | * value of the specified attribute
|
||
314 | */
|
||
315 | public Geometry getGeometry(String name); |
||
316 | |||
317 | /**
|
||
318 | * Returns the Geometry value of an attribute given its position.
|
||
319 | *
|
||
320 | * @param index
|
||
321 | * position of the attribute
|
||
322 | * @return
|
||
323 | * value of the specified attribute
|
||
324 | */
|
||
325 | public Geometry getGeometry(int index); |
||
326 | |||
327 | /**
|
||
328 | * Returns the array value of an attribute given its name.
|
||
329 | *
|
||
330 | * @param name
|
||
331 | * name of the attribute
|
||
332 | * @return
|
||
333 | * value of the specified attribute
|
||
334 | */
|
||
335 | public Object[] getArray(String name); |
||
336 | |||
337 | /**
|
||
338 | * Returns the array value of an attribute given its position.
|
||
339 | *
|
||
340 | * @param index
|
||
341 | * position of the attribute
|
||
342 | * @return
|
||
343 | * value of the specified attribute
|
||
344 | */
|
||
345 | public Object[] getArray(int index); |
||
346 | |||
347 | /**
|
||
348 | * Returns the Feature value of an attribute given its name.
|
||
349 | *
|
||
350 | * @param name
|
||
351 | * name of the attribute
|
||
352 | * @return
|
||
353 | * value of the specified attribute
|
||
354 | */
|
||
355 | public Feature getFeature(String name); |
||
356 | |||
357 | /**
|
||
358 | * Returns the Feature value of an attribute given its position.
|
||
359 | *
|
||
360 | * @param index
|
||
361 | * position of the attribute
|
||
362 | * @return
|
||
363 | * value of the specified attribute
|
||
364 | */
|
||
365 | public Feature getFeature(int index); |
||
366 | |||
367 | |||
368 | /**
|
||
369 | * Envelope (AKA extent or bounding box) of the default
|
||
370 | * geometry attribute.
|
||
371 | *
|
||
372 | * @return Envelope
|
||
373 | * of the default geometry attribute
|
||
374 | */
|
||
375 | public Envelope getDefaultEnvelope();
|
||
376 | |||
377 | /**
|
||
378 | * Returns the value of the default geometry attribute,
|
||
379 | * which is a {@link Geometry}.
|
||
380 | *
|
||
381 | * @return
|
||
382 | * value of the default geometry attribute
|
||
383 | */
|
||
384 | public Geometry getDefaultGeometry();
|
||
385 | |||
386 | /**
|
||
387 | * Returns a list with the values of this Feature's
|
||
388 | * geometry attributes.
|
||
389 | *
|
||
390 | * @return
|
||
391 | * a list with the values of this Feature's geometry attributes
|
||
392 | */
|
||
393 | public List getGeometries(); |
||
394 | |||
395 | /**
|
||
396 | * Returns the Spatial Reference System in which is
|
||
397 | * expressed the default geometry attribute.
|
||
398 | *
|
||
399 | * @return
|
||
400 | * A string containing the default geometry attribute SRS.
|
||
401 | */
|
||
402 | public IProjection getDefaultSRS();
|
||
403 | |||
404 | /**
|
||
405 | * Returns a list with the Spatial Reference Systems in which
|
||
406 | * are expressed this Feature's geometry attributes.
|
||
407 | *
|
||
408 | * @return
|
||
409 | * a list with the Spatial Reference Systems.
|
||
410 | */
|
||
411 | public List getSRSs(); |
||
412 | |||
413 | /**
|
||
414 | * Returns the instant value of an attribute given its position.
|
||
415 | *
|
||
416 | * @param index
|
||
417 | * position of the attribute
|
||
418 | * @return
|
||
419 | * value of the specified attribute
|
||
420 | */
|
||
421 | public Instant getInstant(int index); |
||
422 | |||
423 | /**
|
||
424 | * Returns the instant value of an attribute given its name.
|
||
425 | *
|
||
426 | * @param name
|
||
427 | * a string containing the name of the attribute
|
||
428 | * @return
|
||
429 | * value of the specified attribute
|
||
430 | */
|
||
431 | public Instant getInstant(String name); |
||
432 | |||
433 | /**
|
||
434 | * Returns the interval value of an attribute given its position.
|
||
435 | *
|
||
436 | * @param index
|
||
437 | * position of the attribute
|
||
438 | * @return
|
||
439 | * value of the specified attribute
|
||
440 | */
|
||
441 | public Interval getInterval(int index); |
||
442 | |||
443 | /**
|
||
444 | * Returns the interval value of an attribute given its name.
|
||
445 | *
|
||
446 | * @param name
|
||
447 | * a string containing the name of the attribute
|
||
448 | * @return
|
||
449 | * value of the specified attribute
|
||
450 | */
|
||
451 | public Interval getInterval(String name); |
||
452 | |||
453 | public DynObject getAsDynObject();
|
||
454 | |||
455 | /**
|
||
456 | * This lets Feature be used eaily with {@link Evaluator}
|
||
457 | *
|
||
458 | * @return
|
||
459 | * An instance of {@link EvaluatorData} which returns the data
|
||
460 | * of this feature
|
||
461 | */
|
||
462 | public EvaluatorData getEvaluatorData();
|
||
463 | } |