root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / DefaultFeature.java @ 38192
History | View | Annotate | Download (15.6 KB)
1 | 24496 | jmvivo | package org.gvsig.fmap.dal.feature.impl; |
---|---|---|---|
2 | 23754 | jjdelcerro | |
3 | import java.lang.ref.WeakReference; |
||
4 | import java.util.Date; |
||
5 | import java.util.Iterator; |
||
6 | import java.util.List; |
||
7 | |||
8 | 26777 | jmvivo | import org.cresques.cts.IProjection; |
9 | 36356 | cordinyana | |
10 | 24496 | jmvivo | import org.gvsig.fmap.dal.DataTypes; |
11 | 24505 | jmvivo | import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException; |
12 | 24496 | jmvivo | import org.gvsig.fmap.dal.feature.EditableFeature; |
13 | import org.gvsig.fmap.dal.feature.Feature; |
||
14 | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
||
15 | import org.gvsig.fmap.dal.feature.FeatureReference; |
||
16 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
17 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
18 | 28908 | jmvivo | import org.gvsig.fmap.dal.feature.exception.IllegalValueException; |
19 | import org.gvsig.fmap.dal.feature.exception.SetReadOnlyAttributeException; |
||
20 | 36721 | fdiaz | import org.gvsig.fmap.dal.feature.impl.featureset.DynObjectFeatureFacade; |
21 | 29289 | jmvivo | import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
22 | 23754 | jjdelcerro | import org.gvsig.fmap.geom.Geometry; |
23 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
24 | 37297 | jpiera | import org.gvsig.timesupport.Instant; |
25 | import org.gvsig.timesupport.Interval; |
||
26 | 34690 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
27 | import org.gvsig.tools.dataTypes.CoercionException; |
||
28 | import org.gvsig.tools.dataTypes.DataTypesManager; |
||
29 | 36721 | fdiaz | import org.gvsig.tools.dynobject.DynObject; |
30 | 23754 | jjdelcerro | import org.gvsig.tools.evaluator.Evaluator; |
31 | import org.gvsig.tools.evaluator.EvaluatorData; |
||
32 | 24433 | jjdelcerro | import org.gvsig.tools.evaluator.EvaluatorException; |
33 | 23754 | jjdelcerro | |
34 | 33205 | cordinyana | public class DefaultFeature implements Feature, EvaluatorData { |
35 | 23754 | jjdelcerro | |
36 | 34690 | jjdelcerro | private static DataTypesManager dataTypesManager = null; |
37 | 29289 | jmvivo | protected FeatureProvider data;
|
38 | 24248 | jjdelcerro | protected FeatureReference reference;
|
39 | 23754 | jjdelcerro | private WeakReference storeRef; |
40 | |||
41 | 34690 | jjdelcerro | |
42 | 23820 | jjdelcerro | /*
|
43 | * Usar con mucha precaucion o mejor no usar. Lo precisa el
|
||
44 | * DefaultFeatureSet en la ordenacion.
|
||
45 | */
|
||
46 | public DefaultFeature(FeatureStore store) {
|
||
47 | this.storeRef = new WeakReference(store); |
||
48 | 24248 | jjdelcerro | this.reference = null; |
49 | 23820 | jjdelcerro | } |
50 | |||
51 | 29289 | jmvivo | public DefaultFeature(FeatureStore store, FeatureProvider data) {
|
52 | 23754 | jjdelcerro | this.data = data;
|
53 | this.storeRef = new WeakReference(store); |
||
54 | 24248 | jjdelcerro | this.reference = null; |
55 | 23754 | jjdelcerro | } |
56 | |||
57 | 23820 | jjdelcerro | DefaultFeature(DefaultFeature feature) { |
58 | 23754 | jjdelcerro | this.data = feature.data.getCopy();
|
59 | this.storeRef = feature.storeRef;
|
||
60 | 24248 | jjdelcerro | this.reference = feature.reference;
|
61 | 23754 | jjdelcerro | } |
62 | |||
63 | 29289 | jmvivo | public void setData(FeatureProvider data) { |
64 | 23820 | jjdelcerro | this.data = data;
|
65 | 25230 | jmvivo | this.reference = null; |
66 | 23820 | jjdelcerro | } |
67 | |||
68 | 29289 | jmvivo | public FeatureProvider getData() {
|
69 | 23820 | jjdelcerro | return this.data; |
70 | } |
||
71 | |||
72 | 34690 | jjdelcerro | protected DataTypesManager getDataTypesManager() {
|
73 | if( dataTypesManager==null ) { |
||
74 | dataTypesManager = ToolsLocator.getDataTypesManager(); |
||
75 | } |
||
76 | return dataTypesManager;
|
||
77 | } |
||
78 | |||
79 | 23820 | jjdelcerro | void set(FeatureAttributeDescriptor attribute, Object value) { |
80 | 23754 | jjdelcerro | int i = attribute.getIndex();
|
81 | |||
82 | if (attribute.isReadOnly()) {
|
||
83 | 28908 | jmvivo | throw new SetReadOnlyAttributeException(); |
84 | 23754 | jjdelcerro | } |
85 | |||
86 | if (attribute.getEvaluator() != null) { |
||
87 | 28908 | jmvivo | throw new SetReadOnlyAttributeException(); |
88 | 23754 | jjdelcerro | } |
89 | |||
90 | 25684 | jmvivo | if (value == null) { |
91 | 28908 | jmvivo | if (!attribute.allowNull()) {
|
92 | if (!attribute.isAutomatic()) {
|
||
93 | throw new IllegalValueException(attribute, value); |
||
94 | } |
||
95 | 25684 | jmvivo | } |
96 | this.data.set(i, null); |
||
97 | return;
|
||
98 | 23754 | jjdelcerro | |
99 | 37297 | jpiera | } |
100 | |||
101 | if (attribute.getFeatureAttributeGetter() != null){ |
||
102 | value = attribute.getFeatureAttributeGetter().setter(value); |
||
103 | } |
||
104 | |||
105 | if (attribute.getObjectClass().isInstance(value)) {
|
||
106 | this.data.set(i, value);
|
||
107 | return;
|
||
108 | } |
||
109 | 27992 | vcaballero | |
110 | 36356 | cordinyana | if (!attribute.getObjectClass().isInstance(value)) {
|
111 | try {
|
||
112 | value = |
||
113 | this.getDataTypesManager().coerce(attribute.getType(),
|
||
114 | value); |
||
115 | } catch (CoercionException e) {
|
||
116 | throw new IllegalArgumentException("Can't convert to " |
||
117 | + this.getDataTypesManager().getTypeName(
|
||
118 | attribute.getType()) + " from '"
|
||
119 | + value.getClass().getName() + "' with value '"
|
||
120 | + value.toString() + "'.", e);
|
||
121 | } |
||
122 | 23754 | jjdelcerro | } |
123 | 34690 | jjdelcerro | |
124 | 36356 | cordinyana | this.data.set(i, value);
|
125 | 37297 | jpiera | } |
126 | 34690 | jjdelcerro | |
127 | 37297 | jpiera | private Object get(int index,Class theClass, int type) { |
128 | Object value = this.get(index); |
||
129 | if( theClass.isInstance(value) ) {
|
||
130 | return value;
|
||
131 | } |
||
132 | try {
|
||
133 | return this.getDataTypesManager().coerce(type, value); |
||
134 | } catch (CoercionException e) {
|
||
135 | throw new IllegalArgumentException( |
||
136 | "Can't convert to "+theClass.getSimpleName()+" from '"+value.getClass().getName()+"' with value '"+value.toString()+"'.", |
||
137 | e); |
||
138 | } |
||
139 | } |
||
140 | |||
141 | // private Object getNumberByType(Number value, int type) {
|
||
142 | // if (type==DataTypes.DOUBLE){
|
||
143 | // return new Double(value.doubleValue());
|
||
144 | // }else if (type==DataTypes.FLOAT){
|
||
145 | // return new Float(value.floatValue());
|
||
146 | // }else if (type==DataTypes.LONG){
|
||
147 | // return new Long(value.longValue());
|
||
148 | // }else if (type==DataTypes.INT){
|
||
149 | // return new Integer(value.intValue());
|
||
150 | // }else if (type==DataTypes.STRING){
|
||
151 | // return value.toString();
|
||
152 | // }
|
||
153 | // return value;
|
||
154 | // }
|
||
155 | 23754 | jjdelcerro | |
156 | 37297 | jpiera | public void initializeValues() { |
157 | FeatureType type = this.getType();
|
||
158 | Iterator iterator = type.iterator();
|
||
159 | 23754 | jjdelcerro | |
160 | 37297 | jpiera | while (iterator.hasNext()) {
|
161 | FeatureAttributeDescriptor attribute = (FeatureAttributeDescriptor) iterator |
||
162 | .next(); |
||
163 | if (attribute.isAutomatic() || attribute.isReadOnly()
|
||
164 | || attribute.getEvaluator() != null) {
|
||
165 | continue;
|
||
166 | } |
||
167 | if (attribute.getDefaultValue() == null && !attribute.allowNull()) { |
||
168 | continue;
|
||
169 | } |
||
170 | this.set(attribute, attribute.getDefaultValue());
|
||
171 | } |
||
172 | } |
||
173 | 23754 | jjdelcerro | |
174 | 37297 | jpiera | public void clear() { |
175 | initializeValues(); |
||
176 | } |
||
177 | 31699 | cordinyana | |
178 | 37297 | jpiera | public void initializeValues(Feature feature) { |
179 | FeatureType myType=this.getType();
|
||
180 | FeatureType type =feature.getType(); |
||
181 | Iterator iterator = type.iterator();
|
||
182 | 23754 | jjdelcerro | |
183 | 37297 | jpiera | while (iterator.hasNext()) {
|
184 | FeatureAttributeDescriptor attribute = (FeatureAttributeDescriptor) iterator |
||
185 | .next(); |
||
186 | FeatureAttributeDescriptor myAttribute=myType.getAttributeDescriptor(attribute.getName()); |
||
187 | if (myAttribute != null) { |
||
188 | this.set(myAttribute, feature.get(attribute.getIndex()));
|
||
189 | } |
||
190 | } |
||
191 | } |
||
192 | 23754 | jjdelcerro | |
193 | |||
194 | 37297 | jpiera | public FeatureStore getStore() {
|
195 | return (FeatureStore) this.storeRef.get(); |
||
196 | } |
||
197 | 23754 | jjdelcerro | |
198 | 37297 | jpiera | public FeatureType getType() {
|
199 | return this.data.getType(); |
||
200 | } |
||
201 | 23754 | jjdelcerro | |
202 | 37297 | jpiera | public EditableFeature getEditable() {
|
203 | return new DefaultEditableFeature(this); |
||
204 | } |
||
205 | 23754 | jjdelcerro | |
206 | 37297 | jpiera | public Feature getCopy() {
|
207 | return new DefaultFeature(this); |
||
208 | } |
||
209 | 23754 | jjdelcerro | |
210 | 37297 | jpiera | public FeatureReference getReference() {
|
211 | if (this.reference == null) { |
||
212 | this.reference = new DefaultFeatureReference(this); |
||
213 | } |
||
214 | return this.reference; |
||
215 | } |
||
216 | 23754 | jjdelcerro | |
217 | 37297 | jpiera | public void validate(int mode) { |
218 | ((DefaultFeatureType) this.data.getType()).validateFeature(this, mode); |
||
219 | } |
||
220 | 23754 | jjdelcerro | |
221 | 37297 | jpiera | public List getSRSs() { |
222 | // TODO Auto-generated method stub
|
||
223 | return null; |
||
224 | } |
||
225 | 23754 | jjdelcerro | |
226 | 37297 | jpiera | public Envelope getDefaultEnvelope() {
|
227 | return this.data.getDefaultEnvelope(); |
||
228 | } |
||
229 | 23754 | jjdelcerro | |
230 | 37297 | jpiera | public Geometry getDefaultGeometry() {
|
231 | return this.data.getDefaultGeometry(); |
||
232 | } |
||
233 | 23754 | jjdelcerro | |
234 | 37297 | jpiera | public IProjection getDefaultSRS() {
|
235 | return this.data.getType().getDefaultSRS(); |
||
236 | } |
||
237 | 23754 | jjdelcerro | |
238 | 37297 | jpiera | public List getGeometries() { |
239 | // TODO Auto-generated method stub
|
||
240 | return null; |
||
241 | } |
||
242 | 23754 | jjdelcerro | |
243 | 37297 | jpiera | public Object get(String name) { |
244 | int index = this.data.getType().getIndex(name); |
||
245 | if( index < 0 ) { |
||
246 | throw new IllegalArgumentException("Attribute name '"+name+"' not found in the feature."); |
||
247 | } |
||
248 | return this.get(index); |
||
249 | } |
||
250 | 23754 | jjdelcerro | |
251 | |||
252 | 37297 | jpiera | public Object get(int index) { |
253 | FeatureType type = this.data.getType();
|
||
254 | if( index <0 || index >= type.size() ) { |
||
255 | throw new IllegalArgumentException("Attribute index '"+index+"' out of range (0 to "+this.data.getType().size()+"."); |
||
256 | } |
||
257 | FeatureAttributeDescriptor attribute = type.getAttributeDescriptor(index); |
||
258 | if (!this.data.getType().hasEvaluators()) { |
||
259 | return get(attribute, this.data.get(index)); |
||
260 | } |
||
261 | Evaluator eval = attribute.getEvaluator(); |
||
262 | if (eval == null) { |
||
263 | return this.data.get(index); |
||
264 | } else {
|
||
265 | Object value = this.data.get(index); |
||
266 | if (value != null) { // FIXME: para comprobar si esta calculado usar |
||
267 | // un array
|
||
268 | // especifico.
|
||
269 | return get(attribute, this.data.get(index)); |
||
270 | } |
||
271 | try {
|
||
272 | value = eval.evaluate(this);
|
||
273 | } catch (EvaluatorException e) {
|
||
274 | throw new DataEvaluatorRuntimeException(e); |
||
275 | } |
||
276 | this.data.set(index, value);
|
||
277 | return get(attribute, value);
|
||
278 | } |
||
279 | } |
||
280 | 23754 | jjdelcerro | |
281 | 37297 | jpiera | private Object get(FeatureAttributeDescriptor featureAttributeDescriptor, Object value){ |
282 | if (featureAttributeDescriptor.getFeatureAttributeGetter() == null){ |
||
283 | return value;
|
||
284 | }else{
|
||
285 | return featureAttributeDescriptor.getFeatureAttributeGetter().getter(value);
|
||
286 | } |
||
287 | } |
||
288 | 23754 | jjdelcerro | |
289 | 37297 | jpiera | public Object[] getArray(String name) { |
290 | return this.getArray(this.data.getType().getIndex(name)); |
||
291 | } |
||
292 | 23754 | jjdelcerro | |
293 | 37297 | jpiera | public Object[] getArray(int index) { |
294 | return (Object[]) this.get(index); |
||
295 | } |
||
296 | 23754 | jjdelcerro | |
297 | 37297 | jpiera | public boolean getBoolean(String name) { |
298 | return this.getBoolean(this.data.getType().getIndex(name)); |
||
299 | } |
||
300 | 23754 | jjdelcerro | |
301 | 37297 | jpiera | public boolean getBoolean(int index) { |
302 | Boolean value = ((Boolean) this.get(index,Boolean.class,DataTypes.BOOLEAN)); |
||
303 | if (value == null) { |
||
304 | return false; |
||
305 | } |
||
306 | return value.booleanValue();
|
||
307 | } |
||
308 | 23754 | jjdelcerro | |
309 | 37297 | jpiera | public byte getByte(String name) { |
310 | return this.getByte(this.data.getType().getIndex(name)); |
||
311 | } |
||
312 | 34916 | fdiaz | |
313 | 37297 | jpiera | public byte getByte(int index) { |
314 | Byte value = ((Byte) this.get(index,Byte.class,DataTypes.BYTE)); |
||
315 | if (value == null) { |
||
316 | return 0; |
||
317 | } |
||
318 | return value.byteValue();
|
||
319 | } |
||
320 | 23754 | jjdelcerro | |
321 | 37297 | jpiera | public Date getDate(String name) { |
322 | return this.getDate(this.data.getType().getIndex(name)); |
||
323 | } |
||
324 | 23754 | jjdelcerro | |
325 | 37297 | jpiera | public Date getDate(int index) { |
326 | Date value = ((Date) this.get(index,Date.class,DataTypes.DATE)); |
||
327 | 23754 | jjdelcerro | |
328 | 37297 | jpiera | return value;
|
329 | } |
||
330 | 23754 | jjdelcerro | |
331 | 37297 | jpiera | public double getDouble(String name) { |
332 | return this.getDouble(this.data.getType().getIndex(name)); |
||
333 | } |
||
334 | 23754 | jjdelcerro | |
335 | 37297 | jpiera | public double getDouble(int index) { |
336 | |||
337 | Double value = ((Double) this.get(index,Double.class,DataTypes.DOUBLE)); |
||
338 | if (value == null) { |
||
339 | return 0; |
||
340 | } |
||
341 | return value.doubleValue();
|
||
342 | } |
||
343 | 23754 | jjdelcerro | |
344 | 37297 | jpiera | public Feature getFeature(String name) { |
345 | return this.getFeature(this.data.getType().getIndex(name)); |
||
346 | } |
||
347 | 23754 | jjdelcerro | |
348 | 37297 | jpiera | public Feature getFeature(int index) { |
349 | return (Feature) this.get(index); |
||
350 | } |
||
351 | 23754 | jjdelcerro | |
352 | 37297 | jpiera | public float getFloat(String name) { |
353 | return this.getFloat(this.data.getType().getIndex(name)); |
||
354 | } |
||
355 | 23754 | jjdelcerro | |
356 | 37297 | jpiera | public float getFloat(int index) { |
357 | Float value = ((Float) this.get(index,Float.class,DataTypes.FLOAT)); |
||
358 | if (value == null) { |
||
359 | return 0; |
||
360 | } |
||
361 | return value.floatValue();
|
||
362 | } |
||
363 | 23754 | jjdelcerro | |
364 | 37297 | jpiera | public Geometry getGeometry(String name) { |
365 | return this.getGeometry(this.data.getType().getIndex(name)); |
||
366 | } |
||
367 | 23754 | jjdelcerro | |
368 | 37297 | jpiera | public Geometry getGeometry(int index) { |
369 | return (Geometry) this.get(index,Geometry.class,DataTypes.GEOMETRY); |
||
370 | } |
||
371 | 23754 | jjdelcerro | |
372 | 37297 | jpiera | public int getInt(String name) { |
373 | return this.getInt(this.data.getType().getIndex(name)); |
||
374 | } |
||
375 | 23754 | jjdelcerro | |
376 | 37297 | jpiera | public int getInt(int index) { |
377 | Integer value = ((Integer) this.get(index,Integer.class,DataTypes.INT)); |
||
378 | if (value == null) { |
||
379 | return 0; |
||
380 | } |
||
381 | return ((Integer)value).intValue(); |
||
382 | } |
||
383 | 23754 | jjdelcerro | |
384 | 37297 | jpiera | public long getLong(String name) { |
385 | return this.getLong(this.data.getType().getIndex(name)); |
||
386 | } |
||
387 | 23754 | jjdelcerro | |
388 | 37297 | jpiera | public long getLong(int index) { |
389 | Long value = ((Long) this.get(index,Long.class,DataTypes.LONG)); |
||
390 | if (value == null) { |
||
391 | return 0; |
||
392 | } |
||
393 | return value.longValue();
|
||
394 | } |
||
395 | 23754 | jjdelcerro | |
396 | 37297 | jpiera | public String getString(String name) { |
397 | return this.getString(this.data.getType().getIndex(name)); |
||
398 | } |
||
399 | 23754 | jjdelcerro | |
400 | 37297 | jpiera | public String getString(int index) { |
401 | return (String) this.get(index,String.class,DataTypes.STRING); |
||
402 | } |
||
403 | 23754 | jjdelcerro | |
404 | 37297 | jpiera | public Object getContextValue(String name) { |
405 | name = name.toLowerCase(); |
||
406 | if (name.equals("store")) { |
||
407 | return this.getStore(); |
||
408 | } |
||
409 | 23754 | jjdelcerro | |
410 | 37297 | jpiera | if (name.equals("featuretype")) { |
411 | return this.data.getType(); |
||
412 | } |
||
413 | 23754 | jjdelcerro | |
414 | 37297 | jpiera | if (name.equals("feature")) { |
415 | return this; |
||
416 | } |
||
417 | 23754 | jjdelcerro | |
418 | 37297 | jpiera | throw new IllegalArgumentException(name); |
419 | } |
||
420 | 23754 | jjdelcerro | |
421 | 37297 | jpiera | public Iterator getDataNames() { |
422 | class DataNamesIterator implements Iterator { |
||
423 | Iterator attributeIteraror;
|
||
424 | 23754 | jjdelcerro | |
425 | 37297 | jpiera | DataNamesIterator(DefaultFeature feature) { |
426 | this.attributeIteraror = feature.getType().iterator();
|
||
427 | } |
||
428 | 23754 | jjdelcerro | |
429 | 37297 | jpiera | public boolean hasNext() { |
430 | return this.attributeIteraror.hasNext(); |
||
431 | } |
||
432 | 23754 | jjdelcerro | |
433 | 37297 | jpiera | public Object next() { |
434 | return ((FeatureAttributeDescriptor) this.attributeIteraror |
||
435 | .next()).getName(); |
||
436 | } |
||
437 | 23754 | jjdelcerro | |
438 | 37297 | jpiera | public void remove() { |
439 | throw new UnsupportedOperationException(); |
||
440 | } |
||
441 | 23754 | jjdelcerro | |
442 | 37297 | jpiera | } |
443 | return new DataNamesIterator(this); |
||
444 | } |
||
445 | 23754 | jjdelcerro | |
446 | 37297 | jpiera | public Object getDataValue(String name) { |
447 | name = name.toLowerCase(); |
||
448 | return get(name);
|
||
449 | } |
||
450 | 23754 | jjdelcerro | |
451 | 37297 | jpiera | public Iterator getDataValues() { |
452 | class DataValuesIterator implements Iterator { |
||
453 | DefaultFeature feature; |
||
454 | int current = 0; |
||
455 | 23754 | jjdelcerro | |
456 | 37297 | jpiera | DataValuesIterator(DefaultFeature feature) { |
457 | this.feature = feature;
|
||
458 | } |
||
459 | 23754 | jjdelcerro | |
460 | 37297 | jpiera | public boolean hasNext() { |
461 | return current < feature.getType().size() - 1; |
||
462 | } |
||
463 | 23754 | jjdelcerro | |
464 | 37297 | jpiera | public Object next() { |
465 | return feature.get(current++);
|
||
466 | } |
||
467 | 24433 | jjdelcerro | |
468 | 37297 | jpiera | public void remove() { |
469 | throw new UnsupportedOperationException(); |
||
470 | } |
||
471 | 24433 | jjdelcerro | |
472 | 37297 | jpiera | } |
473 | return new DataValuesIterator(this); |
||
474 | } |
||
475 | 24433 | jjdelcerro | |
476 | 37297 | jpiera | public boolean hasContextValue(String name) { |
477 | name = name.toLowerCase(); |
||
478 | if (name.equals("store")) { |
||
479 | return true; |
||
480 | } |
||
481 | 36721 | fdiaz | |
482 | 37297 | jpiera | if (name.equals("featuretype")) { |
483 | return true; |
||
484 | } |
||
485 | |||
486 | if (name.equals("feature")) { |
||
487 | return true; |
||
488 | } |
||
489 | return false; |
||
490 | } |
||
491 | |||
492 | public boolean hasDataValue(String name) { |
||
493 | name = name.toLowerCase(); |
||
494 | return this.data.getType().getIndex(name) >= 0; |
||
495 | } |
||
496 | |||
497 | public Instant getInstant(int index) { |
||
498 | return ((Instant) this.get(index,Date.class,DataTypes.INSTANT)); |
||
499 | } |
||
500 | |||
501 | public Instant getInstant(String name) { |
||
502 | return this.getInstant(this.data.getType().getIndex(name)); |
||
503 | } |
||
504 | |||
505 | public Interval getInterval(int index) { |
||
506 | return ((Interval) this.get(index,Date.class,DataTypes.INTERVAL)); |
||
507 | } |
||
508 | |||
509 | public Interval getInterval(String name) { |
||
510 | return this.getInterval(this.data.getType().getIndex(name)); |
||
511 | } |
||
512 | |||
513 | public DynObject getAsDynObject() {
|
||
514 | DynObjectFeatureFacade facade = new DynObjectFeatureFacade();
|
||
515 | facade.setFeature(this);
|
||
516 | return facade;
|
||
517 | } |
||
518 | 37327 | cordinyana | |
519 | public String toString() { |
||
520 | StringBuffer buffer = new StringBuffer("Feature with values: "); |
||
521 | FeatureAttributeDescriptor[] attributeDescriptors =
|
||
522 | getType().getAttributeDescriptors(); |
||
523 | for (int i = 0; i < attributeDescriptors.length; i++) { |
||
524 | String name = attributeDescriptors[i].getName();
|
||
525 | buffer.append(name).append("=").append(get(name));
|
||
526 | if (i < attributeDescriptors.length - 1) { |
||
527 | buffer.append(", ");
|
||
528 | } |
||
529 | } |
||
530 | return super.toString(); |
||
531 | } |
||
532 | 23754 | jjdelcerro | } |