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 / DefaultFeatureAttributeDescriptor.java @ 42634

History | View | Annotate | Download (24.7 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 modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal.feature.impl;
24

    
25
import java.text.DateFormat;
26
import java.util.HashMap;
27
import java.util.Iterator;
28
import java.util.List;
29
import java.util.Map;
30
import java.util.Map.Entry;
31
import org.apache.commons.lang3.ArrayUtils;
32
import org.cresques.cts.IProjection;
33
import org.gvsig.fmap.crs.CRSFactory;
34
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
35
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator;
36
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter;
37
import org.gvsig.fmap.geom.Geometry;
38
import org.gvsig.fmap.geom.GeometryException;
39
import org.gvsig.fmap.geom.GeometryLocator;
40
import org.gvsig.fmap.geom.type.GeometryType;
41
import org.gvsig.tools.ToolsLocator;
42
import org.gvsig.tools.dataTypes.CoercionException;
43
import org.gvsig.tools.dataTypes.DataType;
44
import org.gvsig.tools.dataTypes.DataTypes;
45
import org.gvsig.tools.dynobject.DynField;
46
import org.gvsig.tools.dynobject.DynField_LabelAttribute;
47
import org.gvsig.tools.dynobject.DynField_v2;
48
import org.gvsig.tools.dynobject.DynObject;
49
import org.gvsig.tools.dynobject.DynObjectValueItem;
50
import org.gvsig.tools.dynobject.DynStruct;
51
import org.gvsig.tools.dynobject.Tags;
52
import org.gvsig.tools.dynobject.exception.DynFieldIsNotAContainerException;
53
import org.gvsig.tools.dynobject.exception.DynFieldValidateException;
54
import org.gvsig.tools.dynobject.impl.DefaultTags;
55
import org.gvsig.tools.evaluator.AbstractEvaluator;
56
import org.gvsig.tools.evaluator.Evaluator;
57
import org.gvsig.tools.evaluator.EvaluatorData;
58
import org.gvsig.tools.evaluator.EvaluatorException;
59
import org.gvsig.tools.persistence.Persistent;
60
import org.gvsig.tools.persistence.PersistentState;
61
import org.gvsig.tools.persistence.exception.PersistenceException;
62

    
63
public class DefaultFeatureAttributeDescriptor implements
64
        FeatureAttributeDescriptor, Persistent, DynField_v2, DynField_LabelAttribute {
65

    
66
    protected boolean allowNull;
67
    protected DataType dataType;
68
    protected DateFormat dateFormat;
69
    protected Object defaultValue;
70
    protected int index;
71
    protected int maximumOccurrences;
72
    protected int minimumOccurrences;
73
    protected int size;
74
    protected String name;
75
    protected Class objectClass;
76
    protected int precision;
77
    protected Evaluator evaluator;
78
    protected boolean primaryKey;
79
    protected boolean readOnly;
80
    protected IProjection SRS;
81
    protected GeometryType geomType;
82
    protected int geometryType;
83
    protected int geometrySubType;
84
    protected Map additionalInfo;
85
    protected boolean isAutomatic;
86
    protected boolean isTime = false;
87
    protected FeatureAttributeGetter featureAttributeGetter = null;
88
    protected FeatureAttributeEmulator featureAttributeEmulator = null;
89
    protected boolean indexed = false;
90
    protected boolean isIndexAscending = true;
91
    protected boolean allowIndexDuplicateds = true;
92

    
93
    protected DynObjectValueItem[] availableValues;
94
    protected String description;
95
    protected Object minValue;
96
    protected Object maxValue;
97
    protected String label;
98
    protected int order;
99
    protected boolean hidden;
100
    protected String groupName;
101
    protected Tags tags = new DefaultTags();
102
    private AvailableValuesProvider availableValuesProvider;
103

    
104
    protected DefaultFeatureAttributeDescriptor() {
105
        this.allowNull = true;
106
        this.dataType = null;
107
        this.dateFormat = null;
108
        this.defaultValue = null;
109
        this.index = -1;
110
        this.maximumOccurrences = 0;
111
        this.minimumOccurrences = 0;
112
        this.size = 0;
113
        this.name = null;
114
        this.objectClass = null;
115
        this.precision = 0;
116
        this.evaluator = null;
117
        this.primaryKey = false;
118
        this.readOnly = false;
119
        this.SRS = null;
120
        this.geometryType = Geometry.TYPES.NULL;
121
        this.geometrySubType = Geometry.SUBTYPES.UNKNOWN;
122
        this.additionalInfo = null;
123
        this.isAutomatic = false;
124
    }
125

    
126
    protected DefaultFeatureAttributeDescriptor(
127
            DefaultFeatureAttributeDescriptor other) {
128
        this.allowNull = other.allowNull;
129
        this.dataType = other.dataType;
130
        this.dateFormat = other.dateFormat;
131
        this.defaultValue = other.defaultValue;
132
        this.index = other.index;
133
        this.maximumOccurrences = other.maximumOccurrences;
134
        this.minimumOccurrences = other.minimumOccurrences;
135
        this.size = other.size;
136
        this.name = other.name;
137
        this.objectClass = other.objectClass;
138
        this.precision = other.precision;
139
        this.evaluator = other.evaluator;
140
        this.primaryKey = other.primaryKey;
141
        this.readOnly = other.readOnly;
142
        this.SRS = other.SRS;
143
        this.geometryType = other.geometryType;
144
        this.geometrySubType = other.geometrySubType;
145
        this.geomType = other.geomType;
146
        if (other.additionalInfo != null) {
147
            Iterator iter = other.additionalInfo.entrySet().iterator();
148
            Map.Entry entry;
149
            this.additionalInfo = new HashMap();
150
            while (iter.hasNext()) {
151
                entry = (Entry) iter.next();
152
                this.additionalInfo.put(entry.getKey(), entry.getValue());
153
            }
154
        } else {
155
            this.additionalInfo = null;
156
        }
157
        this.isAutomatic = other.isAutomatic;
158
        this.isTime = other.isTime;
159
        this.featureAttributeEmulator = other.featureAttributeEmulator;
160
        this.indexed = other.indexed;
161
        this.isIndexAscending = other.isIndexAscending;
162
        this.allowIndexDuplicateds = other.allowIndexDuplicateds;
163
    }
164

    
165
    @Override
166
    public String getDataTypeName() {
167
        if (this.getDataType() == null) {
168
            return "(unknow)";
169
        }
170
        return this.getDataType().getName();
171
    }
172

    
173
    @Override
174
    public FeatureAttributeDescriptor getCopy() {
175
        return new DefaultFeatureAttributeDescriptor(this);
176
    }
177

    
178
    @Override
179
    public boolean allowNull() {
180
        return allowNull;
181
    }
182

    
183
    @Override
184
    public DataType getDataType() {
185
        if (featureAttributeGetter != null) {
186
            return featureAttributeGetter.getDataType();
187
        }
188
        return this.dataType;
189
    }
190

    
191
    @Override
192
    public DateFormat getDateFormat() {
193
        return this.dateFormat;
194
    }
195

    
196
    @Override
197
    public Object getDefaultValue() {
198
        return this.defaultValue;
199
    }
200

    
201
    @Override
202
    public Evaluator getEvaluator() {
203
        return this.evaluator;
204
    }
205

    
206
    @Override
207
    public int getGeometryType() {
208
        return this.geometryType;
209
    }
210

    
211
    @Override
212
    public int getGeometrySubType() {
213
        return this.geometrySubType;
214
    }
215

    
216
    @Override
217
    public GeometryType getGeomType() {
218
        if (this.geomType == null) {
219
            try {
220
                this.geomType
221
                        = GeometryLocator.getGeometryManager().getGeometryType(
222
                                this.geometryType, this.geometrySubType);
223
            } catch (GeometryException e) {
224
                throw new RuntimeException(
225
                        "Error getting geometry type with type = "
226
                        + this.geometryType + ", subtype = "
227
                        + this.geometrySubType, e);
228
            }
229
        }
230
        return this.geomType;
231
    }
232

    
233
    @Override
234
    public int getIndex() {
235
        return this.index;
236
    }
237

    
238
    protected FeatureAttributeDescriptor setIndex(int index) {
239
        this.index = index;
240
        return this;
241
    }
242

    
243
    @Override
244
    public int getMaximumOccurrences() {
245
        return this.maximumOccurrences;
246
    }
247

    
248
    @Override
249
    public int getMinimumOccurrences() {
250
        return this.minimumOccurrences;
251
    }
252

    
253
    @Override
254
    public String getName() {
255
        return this.name;
256
    }
257

    
258
    @Override
259
    public Class getObjectClass() {
260
        if (getDataType().getType() == DataTypes.OBJECT) {
261
            return objectClass;
262
        }
263
        return getDataType().getDefaultClass();
264
    }
265

    
266
    @Override
267
    public int getPrecision() {
268
        return this.precision;
269
    }
270

    
271
    @Override
272
    public IProjection getSRS() {
273
        return this.SRS;
274
    }
275

    
276
    @Override
277
    public int getSize() {
278
        return this.size;
279
    }
280

    
281
    @Override
282
    public boolean isPrimaryKey() {
283
        return this.primaryKey;
284
    }
285

    
286
    @Override
287
    public boolean isReadOnly() {
288
        if (this.readOnly) {
289
            return true;
290
        }
291
        if (this.getEvaluator() != null) {
292
            return true;
293
        }
294
        if (this.featureAttributeEmulator != null) {
295
            return !this.featureAttributeEmulator.allowSetting();
296
        }
297
        return false;
298
    }
299

    
300
    @Override
301
    public Object getAdditionalInfo(String infoName) {
302
        if (this.additionalInfo == null) {
303
            return null;
304
        }
305
        return this.additionalInfo.get(infoName);
306
    }
307

    
308
    @Override
309
    public boolean isAutomatic() {
310
        return this.isAutomatic;
311
    }
312

    
313
    private boolean compareObject(Object a, Object b) {
314
        if (a != b) {
315
            if (a == null) {
316
                return false;
317
            }
318
            return a.equals(b);
319
        }
320
        return true;
321

    
322
    }
323

    
324
    @Override
325
    public boolean equals(Object obj) {
326
        if (this == obj) {
327
            return true;
328
        }
329
        if (!(obj instanceof DefaultFeatureAttributeDescriptor)) {
330
            return false;
331
        }
332
        DefaultFeatureAttributeDescriptor other
333
                = (DefaultFeatureAttributeDescriptor) obj;
334

    
335
        if (this.allowNull != other.allowNull) {
336
            return false;
337
        }
338

    
339
        if (this.index != other.index) {
340
            return false;
341
        }
342

    
343
        if (!compareObject(this.name, other.name)) {
344
            return false;
345
        }
346

    
347
        if (this.getDataType() != other.getDataType()) {
348
            return false;
349
        }
350

    
351
        if (this.size != other.size) {
352
            return false;
353
        }
354

    
355
        if (!compareObject(this.defaultValue, other.defaultValue)) {
356
            return false;
357
        }
358

    
359
        if (!compareObject(this.defaultValue, other.defaultValue)) {
360
            return false;
361
        }
362

    
363
        if (this.primaryKey != other.primaryKey) {
364
            return false;
365
        }
366

    
367
        if (this.isAutomatic != other.isAutomatic) {
368
            return false;
369
        }
370

    
371
        if (this.readOnly != other.readOnly) {
372
            return false;
373
        }
374

    
375
        if (this.precision != other.precision) {
376
            return false;
377
        }
378

    
379
        if (this.maximumOccurrences != other.maximumOccurrences) {
380
            return false;
381
        }
382

    
383
        if (this.minimumOccurrences != other.minimumOccurrences) {
384
            return false;
385
        }
386

    
387
        if (this.geometryType != other.geometryType) {
388
            return false;
389
        }
390

    
391
        if (this.geometrySubType != other.geometrySubType) {
392
            return false;
393
        }
394

    
395
        if (!compareObject(this.evaluator, other.evaluator)) {
396
            return false;
397
        }
398

    
399
        if (!compareObject(this.SRS, other.SRS)) {
400
            return false;
401
        }
402

    
403
        if (!compareObject(this.dateFormat, other.dateFormat)) {
404
            return false;
405
        }
406

    
407
        if (!compareObject(this.objectClass, other.objectClass)) {
408
            return false;
409
        }
410

    
411
        return true;
412
    }
413

    
414
    @Override
415
    public void loadFromState(PersistentState state)
416
            throws PersistenceException {
417
        allowNull = state.getBoolean("allowNull");
418
        dataType
419
                = ToolsLocator.getDataTypesManager().get(state.getInt("dataType"));
420
        // FIXME how persist dateFormat ???
421
        // dateFormat;
422
        defaultValue = state.get("defaultValue");
423

    
424
        index = state.getInt("index");
425
        maximumOccurrences = state.getInt("maximumOccurrences");
426
        minimumOccurrences = state.getInt("minimumOccurrences");
427
        size = state.getInt("size");
428
        name = state.getString("name");
429
        try {
430
            objectClass = Class.forName(state.getString("objectClass"));
431
        } catch (ClassNotFoundException e) {
432
            throw new PersistenceException(e);
433
        }
434
        precision = state.getInt("precision");
435
        evaluator = (Evaluator) state.get("evaluator");
436
        primaryKey = state.getBoolean("primaryKey");
437
        readOnly = state.getBoolean("readOnly");
438
        String srsId = state.getString("srsId");
439
        if (srsId != null) {
440
            SRS = CRSFactory.getCRS(srsId);
441
        }
442
        geometryType = state.getInt("geometryType");
443
        geometrySubType = state.getInt("geometrySubType");
444
        additionalInfo = (Map) state.get("aditionalInfo");
445
        isAutomatic = state.getBoolean("isAutomatic");
446
    }
447

    
448
    @Override
449
    public void saveToState(PersistentState state) throws PersistenceException {
450
        state.set("allowNull", allowNull);
451
        state.set("dataType", dataType);
452
        // FIXME how persist dateFormat ???
453
        // dateFormat;
454

    
455
        defaultValue = state.get("defaultValue");
456

    
457
        index = state.getInt("index");
458
        maximumOccurrences = state.getInt("maximumOccurrences");
459
        minimumOccurrences = state.getInt("minimumOccurrences");
460
        size = state.getInt("size");
461
        name = state.getString("name");
462
        try {
463
            objectClass = Class.forName(state.getString("objectClass"));
464
        } catch (ClassNotFoundException e) {
465
            throw new PersistenceException(e);
466
        }
467
        precision = state.getInt("precision");
468
        evaluator = (Evaluator) state.get("evaluator");
469
        primaryKey = state.getBoolean("primaryKey");
470
        readOnly = state.getBoolean("readOnly");
471
        String srsId = state.getString("srsId");
472
        if (srsId != null) {
473
            SRS = CRSFactory.getCRS(srsId);
474
        }
475
        geometryType = state.getInt("geometryType");
476
        geometrySubType = state.getInt("geometrySubType");
477
        additionalInfo = (Map) state.get("aditionalInfo");
478
        isAutomatic = state.getBoolean("isAutomatic");
479
    }
480

    
481
    /*
482
     * Start of DynField interface Implementation
483
     *
484
     */
485

    
486
    public Tags getTags() {
487
        return tags;
488
    }
489

    
490
    @Override
491
    public DynObjectValueItem[] getAvailableValues() {
492
        return this.availableValues;
493
    }
494

    
495
    @Override
496
    public String getDescription() {
497
        if( this.description == null ) {
498
            return getName();
499
        }
500
        return this.description;
501
    }
502

    
503
    @Override
504
    public Object getMaxValue() {
505
        return this.maxValue;
506
    }
507

    
508
    @Override
509
    public Object getMinValue() {
510
        return this.minValue;
511
    }
512

    
513
    @Override
514
    public int getTheTypeOfAvailableValues() {
515
        return 1;
516
    }
517

    
518
    @Override
519
    public int getType() {
520
        if (featureAttributeGetter != null) {
521
            return featureAttributeGetter.getDataType().getType();
522
        }
523
        return getDataType().getType();
524
    }
525

    
526
    @Override
527
    public boolean isMandatory() {
528
        return !allowNull() || isPrimaryKey();
529
    }
530

    
531
    @Override
532
    public boolean isPersistent() {
533
        return false;
534
    }
535

    
536
    @Override
537
    public DynField setAvailableValues(DynObjectValueItem[] values) {
538
        if ( ArrayUtils.isEmpty(values) ) {
539
            this.availableValues = null;
540
        } else {
541
            this.availableValues = values;
542
        }
543
        return this;
544
    }
545

    
546
    @Override
547
    public DynField setDescription(String description) {
548
        this.description = description;
549
        return this;
550
    }
551

    
552
    @Override
553
    public DynField setMandatory(boolean mandatory) {
554
        throw new UnsupportedOperationException();
555
    }
556

    
557
    @Override
558
    public DynField setMaxValue(Object maxValue) {
559
        try {
560
            this.maxValue = this.coerce(maxValue);
561
        } catch (CoercionException e) {
562
            throw new IllegalArgumentException(e);
563
        }
564
        return this;
565
    }
566

    
567
    @Override
568
    public DynField setMinValue(Object minValue) {
569
        try {
570
            this.maxValue = this.coerce(minValue);
571
        } catch (CoercionException e) {
572
            throw new IllegalArgumentException(e);
573
        }
574
        return this;
575
    }
576

    
577
    @Override
578
    public DynField setPersistent(boolean persistent) {
579
        throw new UnsupportedOperationException();
580
    }
581

    
582
    @Override
583
    public DynField setTheTypeOfAvailableValues(int type) {
584
        throw new UnsupportedOperationException();
585
    }
586

    
587
    @Override
588
    public DynField setType(int type) {
589
        throw new UnsupportedOperationException();
590
    }
591

    
592
    @Override
593
    public DynField setDefaultDynValue(Object defaultValue) {
594
        throw new UnsupportedOperationException();
595
    }
596

    
597
    @Override
598
    public Class getClassOfValue() {
599
        return null;
600
    }
601

    
602
    @Override
603
    public DynField getElementsType() {
604
        return null;
605
    }
606

    
607
    @Override
608
    public DynField setClassOfValue(Class theClass)
609
            throws DynFieldIsNotAContainerException {
610
        throw new UnsupportedOperationException();
611
    }
612

    
613
    @Override
614
    public DynField setElementsType(DynStruct type)
615
            throws DynFieldIsNotAContainerException {
616
        throw new UnsupportedOperationException();
617
    }
618

    
619
    @Override
620
    public DynField setElementsType(int type)
621
            throws DynFieldIsNotAContainerException {
622
        throw new UnsupportedOperationException();
623
    }
624

    
625
    @Override
626
    public DynField setSubtype(String subtype) {
627
        throw new UnsupportedOperationException();
628
    }
629

    
630
    @Override
631
    public void validate(Object value) throws DynFieldValidateException {
632

    
633
        if (value == null && !this.allowNull()) {
634
            throw new DynFieldValidateException(value, this, null);
635
        }
636

    
637
        try {
638
            this.dataType.coerce(value);
639
        } catch (CoercionException e) {
640
            throw new DynFieldValidateException(value, this, e);
641
        }
642

    
643
        /*
644
         * Other checks will be needed
645
         */
646
    }
647

    
648
    @Override
649
    public String getSubtype() {
650
        if (featureAttributeGetter != null) {
651
            return featureAttributeGetter.getDataType().getSubtype();
652
        }
653
        return this.dataType.getSubtype();
654
    }
655

    
656
    @Override
657
    public Object coerce(Object value) throws CoercionException {
658
        if ( value == null ) {
659
            return value; // O debe devolver this.defaultValue
660
        }
661
        try {
662
            return this.getDataType().coerce(value);
663
        } catch(Exception ex){
664
            throw new RuntimeException(ex);
665
        }
666
    }
667

    
668
    @Override
669
    public DynField setAvailableValues(List values) {
670
        if (  values == null || values.isEmpty() ) {
671
            this.availableValues = null;
672
        } else {
673
            this.availableValues = (DynObjectValueItem[]) values.toArray(
674
                new DynObjectValueItem[values.size()]
675
            );
676
        }
677
        return this;
678
    }
679

    
680
    @Override
681
    public String getGroup() {
682
        return this.groupName;
683
    }
684

    
685
    @Override
686
    public int getOder() {
687
        return this.order;
688
    }
689

    
690
    @Override
691
    public String getLabel() {
692
        if( this.label == null ) {
693
            return this.getName();
694
        }
695
        return this.label;
696
    }
697

    
698
    @Override
699
    public DynField setLabel(String label) {
700
        this.label = label;
701
        return this;
702
    }
703

    
704
    @Override
705
    public DynField setGroup(String groupName) {
706
        this.groupName = groupName;
707
        return this;
708
    }
709

    
710
    @Override
711
    public DynField setOrder(int order) {
712
        this.order = order;
713
        return this;
714
    }
715

    
716
    @Override
717
    public DynField setHidden(boolean hidden) {
718
        this.hidden = hidden;
719
        return this;
720
    }
721

    
722
    @Override
723
    public boolean isHidden() {
724
        return this.hidden;
725
    }
726

    
727
    @Override
728
    public DynField setReadOnly(boolean arg0) {
729
        throw new UnsupportedOperationException();
730
    }
731

    
732
    @Override
733
    public boolean isContainer() {
734
        return false;
735
    }
736

    
737
    @Override
738
    public Class getClassOfItems() {
739
        return null;
740
    }
741

    
742
    @Override
743
    public DynField setDefaultFieldValue(Object defaultValue) {
744
        throw new UnsupportedOperationException();
745
    }
746

    
747
    @Override
748
    public DynField setClassOfItems(Class theClass) {
749
        throw new UnsupportedOperationException();
750
    }
751

    
752
    @Override
753
    public DynField setType(DataType type) {
754
        throw new UnsupportedOperationException();
755
    }
756

    
757
    @Override
758
    public boolean isTime() {
759
        return isTime;
760
    }
761

    
762
    @Override
763
    public FeatureAttributeGetter getFeatureAttributeGetter() {
764
        return featureAttributeGetter;
765
    }
766

    
767
    @Override
768
    public void setFeatureAttributeGetter(
769
            FeatureAttributeGetter featureAttributeTransform) {
770
        this.featureAttributeGetter = featureAttributeTransform;
771
    }
772

    
773
    @Override
774
    public FeatureAttributeEmulator getFeatureAttributeEmulator() {
775
        return this.featureAttributeEmulator;
776
    }
777

    
778
    @Override
779
    public boolean isIndexed() {
780
        return this.indexed;
781
    }
782

    
783
    @Override
784
    public boolean allowIndexDuplicateds() {
785
        return this.allowIndexDuplicateds;
786
    }
787

    
788
    @Override
789
    public boolean isIndexAscending() {
790
        return this.isIndexAscending;
791
    }
792

    
793
    @Override
794
    public DynField setClassOfValue(DynStruct dynStrct) {
795
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
796
    }
797

    
798
    @Override
799
    public DynField setClassOfValue(String theClassNameOfValue) {
800
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
801
    }
802

    
803
    @Override
804
    public String getClassNameOfValue() {
805
        return null;
806
    }
807

    
808
    @Override
809
    public DynStruct getDynClassOfValue() {
810
        return null;
811
    }
812

    
813
    @Override
814
    public DynField setTypeOfItems(int type) {
815
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
816
    }
817

    
818
    @Override
819
    public int getTypeOfItems() {
820
        return DataTypes.INVALID;
821
    }
822

    
823
    @Override
824
    public DynField setClassOfItems(DynStruct dynStrct) {
825
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
826
    }
827

    
828
    @Override
829
    public DynField setClassOfItems(String theClassNameOfValue) {
830
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
831
    }
832

    
833
    @Override
834
    public String getClassNameOfItems() {
835
        return null;
836
    }
837

    
838
    @Override
839
    public DynStruct getDynClassOfItems() {
840
        return null;
841
    }
842

    
843
    @Override
844
    public DynField setRelationType(int relationType) {
845
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
846
    }
847

    
848
    @Override
849
    public int getRelationType() {
850
        return RELATION_TYPE_NONE;
851
    }
852

    
853
    @Override
854
    public void setAvailableValuesProvider(AvailableValuesProvider provider) {
855
        this.availableValuesProvider = provider;
856
    }
857

    
858
    @Override
859
    public DynObjectValueItem[] getAvailableValues(DynObject dynObject) {
860
        if( this.availableValuesProvider != null ) {
861
            DynObjectValueItem[] values = this.availableValuesProvider.getValues(this, dynObject);
862
            if( values != null ) {
863
                return values;
864
            }
865
        }
866
        return this.availableValues;
867
    }
868

    
869
    private class ConstantValueEvaluator extends AbstractEvaluator {
870

    
871
        @Override
872
        public Object evaluate(EvaluatorData data) throws EvaluatorException {
873
            return defaultValue;
874
        }
875

    
876
        @Override
877
        public String getName() {
878
            return "Constant attribute " + name;
879
        }
880
    }
881

    
882
    public void setConstantValue(boolean isConstantValue) {
883
        if (isConstantValue) {
884
            /* Cuando un attributo tiene asociado un evaluador, este se interpreta
885
             * como que no debe cargarse de la fuente de datos subyacente, siendo
886
             * el evaluador el que se encarga de proporcionar su valor.
887
             * Nos limitamos a asignar un evaluador que retorna simpre el valor
888
             * por defecto para ese attributo.
889
             */
890
            this.evaluator = new ConstantValueEvaluator();
891
        } else {
892
            this.evaluator = null;
893
        }
894
    }
895

    
896
}