Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / DefaultFeature.java @ 43983

History | View | Annotate | Download (23.4 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.impl;
25

    
26
import java.lang.ref.WeakReference;
27
import java.util.ArrayList;
28
import java.util.Date;
29
import java.util.Iterator;
30
import java.util.List;
31
import java.util.Map;
32

    
33
import org.cresques.cts.IProjection;
34

    
35
import org.gvsig.fmap.dal.DataTypes;
36
import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException;
37
import org.gvsig.fmap.dal.exception.DataException;
38
import org.gvsig.fmap.dal.feature.EditableFeature;
39
import org.gvsig.fmap.dal.feature.Feature;
40
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
41
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator;
42
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter;
43
import org.gvsig.fmap.dal.feature.FeatureReference;
44
import org.gvsig.fmap.dal.feature.FeatureStore;
45
import org.gvsig.fmap.dal.feature.FeatureType;
46
import org.gvsig.fmap.dal.feature.exception.IllegalValueException;
47
import org.gvsig.fmap.dal.feature.exception.SetReadOnlyAttributeException;
48
import org.gvsig.fmap.dal.feature.impl.dynobjectutils.DynObjectFeatureFacade;
49
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider;
50
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
51
import org.gvsig.fmap.geom.Geometry;
52
import org.gvsig.fmap.geom.primitive.Envelope;
53
import org.gvsig.timesupport.Instant;
54
import org.gvsig.timesupport.Interval;
55
import org.gvsig.tools.ToolsLocator;
56
import org.gvsig.tools.dataTypes.CoercionException;
57
import org.gvsig.tools.dataTypes.DataTypesManager;
58
import org.gvsig.tools.dynobject.DynObject;
59
import org.gvsig.tools.evaluator.Evaluator;
60
import org.gvsig.tools.evaluator.EvaluatorData;
61
import org.gvsig.tools.evaluator.EvaluatorException;
62
import org.gvsig.tools.exception.BaseException;
63
import org.gvsig.tools.exception.BaseRuntimeException;
64
import org.gvsig.tools.lang.Cloneable;
65

    
66
public class DefaultFeature implements Feature, EvaluatorData, Cloneable {
67

    
68
        private static DataTypesManager dataTypesManager = null;
69
        protected FeatureProvider data;
70
        protected FeatureReference reference;
71
        private WeakReference storeRef;
72

    
73
        private boolean inserted = false;
74

    
75
    /*
76
         * Usar con mucha precaucion o mejor no usar. Lo precisa el
77
         * DefaultFeatureSet en la ordenacion.
78
         */
79
        public DefaultFeature(FeatureStore store) {
80
                this.storeRef = new WeakReference(store);
81
                this.reference = null;
82
        }
83

    
84
        public DefaultFeature(FeatureStore store, FeatureProvider data) {
85
                this.data = data;
86
                this.storeRef = new WeakReference(store);
87
                this.reference = null;
88
                this.inserted = !data.isNew();
89
        }
90

    
91
        DefaultFeature(DefaultFeature feature) {
92
                this.data = feature.data.getCopy();
93
                this.storeRef = feature.storeRef;
94
                this.reference = feature.reference;
95
                this.inserted = feature.isInserted();
96
        }
97

    
98
    public DefaultFeature(FeatureType targetType, Feature sourceFeature) {
99
        DefaultFeature defaultFeature = (DefaultFeature)sourceFeature;
100
        this.data = new DefaultFeatureProvider(targetType, (DefaultFeatureProvider)defaultFeature.getData());
101
        this.storeRef = defaultFeature.storeRef;
102
        this.reference = defaultFeature.reference;
103
        this.inserted = defaultFeature.isInserted();
104

    
105
        FeatureType sourceType = sourceFeature.getType();
106

    
107
        for (FeatureAttributeDescriptor targetAttrDescriptor : targetType) {
108
            if ( targetAttrDescriptor.isAutomatic() ||
109
                 targetAttrDescriptor.isReadOnly() ||
110
                 targetAttrDescriptor.getEvaluator() != null) {
111
                 continue;
112
            }
113
            int sourceIndex = sourceType.getIndex(targetAttrDescriptor.getName());
114
            if (sourceIndex<0){
115
                continue;
116
            }
117
            Object value = sourceFeature.get(sourceIndex);
118
            if (value == null && !targetAttrDescriptor.allowNull()) {
119
                continue;
120
            }
121
            this.set(targetAttrDescriptor,value);
122
        }
123
    }
124

    
125
        public void setData(FeatureProvider data) {
126
                this.data = data;
127
                this.reference = null;
128
                this.inserted = true;
129
        }
130

    
131
        public FeatureProvider getData() {
132
                return this.data;
133
        }
134

    
135
        protected DataTypesManager getDataTypesManager() {
136
                if( dataTypesManager==null ) {
137
                        dataTypesManager = ToolsLocator.getDataTypesManager();
138
                }
139
                return dataTypesManager;
140
        }
141

    
142
    void set(FeatureAttributeDescriptor attribute, Object value) {
143
        int i = attribute.getIndex();
144

    
145
        if ( attribute.isReadOnly() ) {
146
            throw new SetReadOnlyAttributeException(attribute.getName(), this.getType());
147
        }
148
        FeatureAttributeEmulator emulator = attribute.getFeatureAttributeEmulator();
149
        if( emulator!= null ) {
150
            emulator.set((EditableFeature) this,value);
151
            return;
152
        }
153

    
154
        if ( value == null ) {
155
            if ( !attribute.allowNull() ) {
156
                if ( !attribute.isAutomatic() ) {
157
                    throw new IllegalValueException(attribute, value);
158
                }
159
            }
160
            this.data.set(i, null);
161
            return;
162

    
163
        }
164

    
165
        if ( attribute.getFeatureAttributeGetter() != null ) {
166
            value = attribute.getFeatureAttributeGetter().setter(value);
167
        }
168

    
169
        Class objectClass = attribute.getObjectClass();
170
        if( objectClass!=null ) {
171
            if ( objectClass.isInstance(value) ) {
172
                this.data.set(i, value);
173
                return;
174
            }
175

    
176
            if ( !objectClass.isInstance(value) ) {
177
                try {
178
                    value
179
                            = this.getDataTypesManager().coerce(attribute.getType(),
180
                                    value);
181
                } catch (CoercionException e) {
182
                    throw new IllegalArgumentException("Can't convert to "
183
                            + this.getDataTypesManager().getTypeName(
184
                                    attribute.getType()) + " from '"
185
                            + value.getClass().getName() + "' with value '"
186
                            + value.toString() + "'.");
187
                }
188
            }
189
        }
190
        this.data.set(i, value);
191
    }
192

    
193
    private Object get(int index,Class theClass, int type) {
194
        Object value = this.get(index);
195
        if( theClass.isInstance(value) ) {
196
            return value;
197
        }
198

    
199

    
200
        try {
201
            return this.getDataTypesManager().coerce(type, value);
202
        } catch (CoercionException e) {
203

    
204
            if (value == null) {
205
                return null;
206
            }
207
            throw new IllegalArgumentException(
208
                    "Can't convert to "+theClass.getName()+
209
                    " from '"+value.getClass().getName()+
210
                    "' with value '"+value.toString()+"'.");
211
        }
212
    }
213

    
214
//  private Object getNumberByType(Number value, int type) {
215
//      if (type==DataTypes.DOUBLE){
216
//          return new Double(value.doubleValue());
217
//      }else if (type==DataTypes.FLOAT){
218
//          return new Float(value.floatValue());
219
//      }else if (type==DataTypes.LONG){
220
//          return new Long(value.longValue());
221
//      }else if (type==DataTypes.INT){
222
//          return new Integer(value.intValue());
223
//      }else if (type==DataTypes.STRING){
224
//          return value.toString();
225
//      }
226
//      return value;
227
//  }
228

    
229
    public void initializeValues() {
230
        FeatureType type = this.getType();
231
        Iterator iterator = type.iterator();
232

    
233
        while (iterator.hasNext()) {
234
            FeatureAttributeDescriptor attribute = (FeatureAttributeDescriptor) iterator
235
            .next();
236
            if (attribute.isAutomatic() || attribute.isReadOnly()
237
                    || attribute.getEvaluator() != null) {
238
                continue;
239
            }
240
            if (attribute.getDefaultValue() == null && !attribute.allowNull()) {
241
                continue;
242
            }
243
            this.set(attribute, attribute.getDefaultValue());
244
        }
245
    }
246

    
247
    public void clear() {
248
        initializeValues();
249
    }
250

    
251
    public void initializeValues(Feature feature) {
252
        FeatureType myType=this.getType();
253
        FeatureType type =feature.getType();
254
        Iterator iterator = type.iterator();
255

    
256
        while (iterator.hasNext()) {
257
            FeatureAttributeDescriptor attribute = (FeatureAttributeDescriptor) iterator
258
            .next();
259
            FeatureAttributeDescriptor myAttribute=myType.getAttributeDescriptor(attribute.getName());
260
            if (myAttribute != null) {
261
                this.set(myAttribute, feature.get(attribute.getIndex()));
262
            }
263
        }
264
    }
265

    
266

    
267
    public FeatureStore getStore() {
268
        return (FeatureStore) this.storeRef.get();
269
    }
270

    
271
    public FeatureType getType() {
272
        return this.data.getType();
273
    }
274

    
275
    public EditableFeature getEditable() {
276
        return new DefaultEditableFeature(this);
277
    }
278

    
279
    public Feature getCopy() {
280
        return new DefaultFeature(this);
281
    }
282

    
283
    public Object clone() throws CloneNotSupportedException {
284
        return new DefaultFeature(this);
285
    }
286

    
287
    public FeatureReference getReference() {
288
        if (this.reference == null) {
289
            if (!isInserted()) {
290
                return null;
291
            }
292
            reference = new DefaultFeatureReference(this);
293
        }
294
        return this.reference;
295
    }
296

    
297
    class UnableToGetReferenceException extends BaseRuntimeException {
298

    
299
        /**
300
         *
301
         */
302
        private static final long serialVersionUID = 1812805035204824163L;
303

    
304
        /**
305
         * @param exception
306
         */
307
        public UnableToGetReferenceException(BaseException exception) {
308
            super("Unable to get reference", "_UnableToGetReferenceException",
309
                serialVersionUID);
310
            this.initCause(exception);
311

    
312
        }
313

    
314
    }
315

    
316
    public void validate(int mode) throws DataException  {
317
        ((DefaultFeatureType) this.data.getType()).validateFeature(this, mode);
318
    }
319

    
320
    public List getSRSs() {
321
        // TODO Auto-generated method stub
322
        return null;
323
    }
324

    
325
    public Envelope getDefaultEnvelope() {
326
        Envelope envelope = this.data.getDefaultEnvelope();
327
        if( envelope == null ) {
328
            Geometry geom = this.getDefaultGeometry();
329
            if( geom!=null ) {
330
                envelope = geom.getEnvelope();
331
            }
332
        }
333
        return envelope;
334
    }
335

    
336
    public Geometry getDefaultGeometry() {
337
            Geometry geom = this.data.getDefaultGeometry();
338
            if( geom!=null ) {
339
                    return geom;
340
            }
341
            int i = this.data.getType().getDefaultGeometryAttributeIndex();
342
        Object x = this.get(i);
343
        if( x instanceof Geometry ) {
344
            return (Geometry) x;
345
        }
346
        return this.getGeometry(i);
347
    }
348

    
349
    public IProjection getDefaultSRS() {
350
        return this.data.getType().getDefaultSRS();
351
    }
352

    
353
    public List getGeometries() {
354
        // TODO Auto-generated method stub
355
        return null;
356
    }
357

    
358
    public Object get(String name) {
359
        int index = this.data.getType().getIndex(name);
360
        if( index < 0 ) {
361
            throw new IllegalArgumentException("Attribute name '"+name+"' not found in the feature.");
362
        }
363
        return this.get(index);
364
    }
365

    
366
    public boolean has_key(String key) {
367
        Object x = this.getType().get(key);
368
        return x != null;
369
    }
370

    
371
    public List<String> keys() {
372
        List<String> ks = new ArrayList<>();
373
        for( FeatureAttributeDescriptor attr : this.getType()) {
374
            ks.add(attr.getName());
375
        }
376
        return ks;
377
    }
378

    
379
    public Iterator<String> iterkeys() {
380
        final Iterator it = this.getType().iterator();
381
        return new Iterator<String>() {
382
            @Override
383
            public boolean hasNext() {
384
                return it.hasNext();
385
            }
386

    
387
            @Override
388
            public String next() {
389
                return ((FeatureAttributeDescriptor)it.next()).getName();
390
            }
391

    
392
            @Override
393
            public void remove() {
394
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
395
            }
396
        };
397
    }
398

    
399
    public Iterator iteritems() {
400
        final Iterator it = this.getType().iterator();
401
        return new Iterator<Map.Entry>() {
402
            @Override
403
            public boolean hasNext() {
404
                return it.hasNext();
405
            }
406

    
407
            @Override
408
            public Map.Entry next() {
409
                final String name = ((FeatureAttributeDescriptor)it.next()).getName();
410
                return new Map.Entry<String, Object>() {
411
                    @Override
412
                    public String getKey() {
413
                        return name;
414
                    }
415

    
416
                    @Override
417
                    public Object getValue() {
418
                        return get(name);
419
                    }
420

    
421
                    @Override
422
                    public Object setValue(Object value) {
423
                        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
424
                    }
425

    
426
                };
427
            }
428

    
429
            @Override
430
            public void remove() {
431
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
432
            }
433
        };
434
    }
435

    
436
    @Override
437
    public Object get(int index) {
438
        FeatureType type = this.data.getType();
439
        if( index <0 || index >= type.size() ) {
440
            throw new IllegalArgumentException("Attribute index '"+index+"' out of range (0 to "+this.data.getType().size()+".");
441
        }
442
        FeatureAttributeDescriptor attribute = type.getAttributeDescriptor(index);
443
        if (!this.data.getType().hasEvaluators()) {
444
            return get(attribute, this.data.get(index));
445
        }
446
        Evaluator eval = attribute.getEvaluator();
447
        if (eval == null) {
448
            return this.data.get(index);
449
        } else {
450
            Object value = this.data.get(index);
451
            if (value != null) { // FIXME: para comprobar si esta calculado usar
452
                // un array
453
                // especifico.
454
                return get(attribute, this.data.get(index));
455
            }
456
            try {
457
                value = eval.evaluate(this);
458
            } catch (EvaluatorException e) {
459
                throw new DataEvaluatorRuntimeException(e);
460
            }
461
            this.data.set(index, value);
462
            return  get(attribute, value);
463
        }
464
    }
465

    
466
    private Object get(FeatureAttributeDescriptor featureAttributeDescriptor, Object value){
467
        FeatureAttributeEmulator emulator = featureAttributeDescriptor.getFeatureAttributeEmulator();
468
        if( emulator != null ) {
469
            return emulator.get(this);
470
        }
471
        FeatureAttributeGetter getter = featureAttributeDescriptor.getFeatureAttributeGetter();
472
        if( getter != null ) {
473
            return getter.getter(value);
474
        }
475
        return value;
476
    }
477

    
478
    public Object[] getArray(String name) {
479
        return this.getArray(this.data.getType().getIndex(name));
480
    }
481

    
482
    public Object[] getArray(int index) {
483
        return (Object[]) this.get(index);
484
    }
485

    
486
    public boolean getBoolean(String name) {
487
        return this.getBoolean(this.data.getType().getIndex(name));
488
    }
489

    
490
    public boolean getBoolean(int index) {
491
        Boolean value = ((Boolean) this.get(index,Boolean.class,DataTypes.BOOLEAN));
492
        if (value == null) {
493
            return false;
494
        }
495
        return value.booleanValue();
496
    }
497

    
498
    public byte getByte(String name) {
499
        return this.getByte(this.data.getType().getIndex(name));
500
    }
501

    
502
    public byte getByte(int index) {
503
        Byte value = ((Byte) this.get(index,Byte.class,DataTypes.BYTE));
504
        if (value == null) {
505
            return 0;
506
        }
507
        return value.byteValue();
508
    }
509

    
510
    public Date getDate(String name) {
511
        return this.getDate(this.data.getType().getIndex(name));
512
    }
513

    
514
    public Date getDate(int index) {
515
        Date value = ((Date) this.get(index,Date.class,DataTypes.DATE));
516

    
517
        return value;
518
    }
519

    
520
    public double getDouble(String name) {
521
        return this.getDouble(this.data.getType().getIndex(name));
522
    }
523

    
524
    public double getDouble(int index) {
525

    
526
        Double value = ((Double) this.get(index,Double.class,DataTypes.DOUBLE));
527
        if (value == null) {
528
            return 0;
529
        }
530
        return value.doubleValue();
531
    }
532

    
533
    public Feature getFeature(String name) {
534
        return this.getFeature(this.data.getType().getIndex(name));
535
    }
536

    
537
    public Feature getFeature(int index) {
538
        return (Feature) this.get(index);
539
    }
540

    
541
    public float getFloat(String name) {
542
        return this.getFloat(this.data.getType().getIndex(name));
543
    }
544

    
545
    public float getFloat(int index) {
546
        Float value = ((Float) this.get(index,Float.class,DataTypes.FLOAT));
547
        if (value == null) {
548
            return 0;
549
        }
550
        return value.floatValue();
551
    }
552

    
553
    public Geometry getGeometry(String name) {
554
        return this.getGeometry(this.data.getType().getIndex(name));
555
    }
556

    
557
    public Geometry getGeometry(int index) {
558
        return (Geometry) this.get(index,Geometry.class,DataTypes.GEOMETRY);
559
    }
560

    
561
    public int getInt(String name) {
562
        return this.getInt(this.data.getType().getIndex(name));
563
    }
564

    
565
    public int getInt(int index) {
566
        Integer value = ((Integer) this.get(index,Integer.class,DataTypes.INT));
567
        if (value == null) {
568
            return 0;
569
        }
570
        return ((Integer)value).intValue();
571
    }
572

    
573
    public long getLong(String name) {
574
        return this.getLong(this.data.getType().getIndex(name));
575
    }
576

    
577
    public long getLong(int index) {
578
        Long value = ((Long) this.get(index,Long.class,DataTypes.LONG));
579
        if (value == null) {
580
            return 0;
581
        }
582
        return value.longValue();
583
    }
584

    
585
    public String getString(String name) {
586
        return this.getString(this.data.getType().getIndex(name));
587
    }
588

    
589
    public String getString(int index) {
590
        return (String) this.get(index,String.class,DataTypes.STRING);
591
    }
592

    
593
    public Object getContextValue(String name) {
594
        name = name.toLowerCase();
595
        if (name.equals("store")) {
596
            return this.getStore();
597
        }
598

    
599
        if (name.equals("featuretype")) {
600
            return this.data.getType();
601
        }
602

    
603
        if (name.equals("feature")) {
604
            return this;
605
        }
606

    
607
        throw new IllegalArgumentException(name);
608
    }
609

    
610
    public Iterator getDataNames() {
611
        class DataNamesIterator implements Iterator {
612
            Iterator attributeIteraror;
613

    
614
            DataNamesIterator(DefaultFeature feature) {
615
                this.attributeIteraror = feature.getType().iterator();
616
            }
617

    
618
            public boolean hasNext() {
619
                return this.attributeIteraror.hasNext();
620
            }
621

    
622
            public Object next() {
623
                return ((FeatureAttributeDescriptor) this.attributeIteraror
624
                        .next()).getName();
625
            }
626

    
627
            public void remove() {
628
                throw new UnsupportedOperationException();
629
            }
630

    
631
        }
632
        return new DataNamesIterator(this);
633
    }
634

    
635
    public Object getDataValue(String name) {
636
        name = name.toLowerCase();
637
        try {
638
            return get(name);
639
        } catch (IllegalArgumentException ex) {
640
            if( "defaultgeometry".equalsIgnoreCase(name )) {
641
                return this.getDefaultGeometry();
642
            }
643
            throw ex;
644
        }
645
    }
646

    
647
    public Iterator getDataValues() {
648
        class DataValuesIterator implements Iterator {
649
            DefaultFeature feature;
650
            int current = 0;
651

    
652
            DataValuesIterator(DefaultFeature feature) {
653
                this.feature = feature;
654
            }
655

    
656
            public boolean hasNext() {
657
                return current < feature.getType().size() - 1;
658
            }
659

    
660
            public Object next() {
661
                return feature.get(current++);
662
            }
663

    
664
            public void remove() {
665
                throw new UnsupportedOperationException();
666
            }
667

    
668
        }
669
        return new DataValuesIterator(this);
670
    }
671

    
672
    public boolean hasContextValue(String name) {
673
        name = name.toLowerCase();
674
        if (name.equals("store")) {
675
            return true;
676
        }
677

    
678
        if (name.equals("featuretype")) {
679
            return true;
680
        }
681

    
682
        if (name.equals("feature")) {
683
            return true;
684
        }
685
        return false;
686
    }
687

    
688
    public boolean hasDataValue(String name) {
689
        name = name.toLowerCase();
690
        return this.data.getType().getIndex(name) >= 0;
691
    }
692

    
693
    public Instant getInstant(int index) {
694
        return ((Instant) this.get(index,Date.class,DataTypes.INSTANT));
695
    }
696

    
697
    public Instant getInstant(String name) {
698
        return this.getInstant(this.data.getType().getIndex(name));
699
    }
700

    
701
    public Interval getInterval(int index) {
702
        return ((Interval) this.get(index,Date.class,DataTypes.INTERVAL));
703
    }
704

    
705
    public Interval getInterval(String name) {
706
        return this.getInterval(this.data.getType().getIndex(name));
707
    }
708

    
709
    @Override
710
    public DynObject getAsDynObject() {
711
        DynObjectFeatureFacade facade = new DynObjectFeatureFacade(this);
712
        return facade;
713
    }
714

    
715
    public String toString() {
716
       // StringBuffer buffer = new StringBuffer("Feature with values: ");
717
            StringBuffer buffer = new StringBuffer("");
718
        FeatureAttributeDescriptor[] attributeDescriptors =
719
            getType().getAttributeDescriptors();
720
        for (int i = 0; i < attributeDescriptors.length; i++) {
721
            String name = attributeDescriptors[i].getName();
722
            //buffer.append(name).append("=").append(get(name));
723
            buffer.append(get(name));
724
            if (i < attributeDescriptors.length - 1) {
725
                buffer.append(", ");
726
            }
727
        }
728
        return buffer.toString();
729
    }
730

    
731

    
732

    
733

    
734
        /**
735
     * @return the inserted
736
     */
737
    public boolean isInserted() {
738
        return inserted;
739
    }
740

    
741

    
742
    /**
743
     * @param inserted the inserted to set
744
     */
745
    public void setInserted(boolean inserted) {
746
        this.inserted = inserted;
747
    }
748

    
749
        @Override
750
    public EvaluatorData getEvaluatorData() {
751
        return this;
752
    }
753

    
754
    public int size() {
755
        return this.data.getType().size();
756
    }
757
    
758
    public boolean isEmpty() {
759
        return false;
760
    }
761

    
762
    public Iterator<String> iterator() {
763
        final Iterator<FeatureAttributeDescriptor> x = this.data.getType().iterator();
764
        return new Iterator<String>() {
765
            @Override
766
            public boolean hasNext() {
767
                return x.hasNext();
768
            }
769

    
770
            @Override
771
            public String next() {
772
                return x.next().getName();
773
            }
774
        };
775
    }
776
    
777
    public boolean containsKey(String key) {
778
        return this.data.getType().get(key)!=null;
779
    }
780
}