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 @ 42563

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.DynObjectValueItem;
49
import org.gvsig.tools.dynobject.DynStruct;
50
import org.gvsig.tools.dynobject.Tags;
51
import org.gvsig.tools.dynobject.exception.DynFieldIsNotAContainerException;
52
import org.gvsig.tools.dynobject.exception.DynFieldValidateException;
53
import org.gvsig.tools.dynobject.impl.DefaultTags;
54
import org.gvsig.tools.evaluator.AbstractEvaluator;
55
import org.gvsig.tools.evaluator.Evaluator;
56
import org.gvsig.tools.evaluator.EvaluatorData;
57
import org.gvsig.tools.evaluator.EvaluatorException;
58
import org.gvsig.tools.persistence.Persistent;
59
import org.gvsig.tools.persistence.PersistentState;
60
import org.gvsig.tools.persistence.exception.PersistenceException;
61

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

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

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

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

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

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

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

    
176
    @Override
177
    public boolean allowNull() {
178
        return allowNull;
179
    }
180

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
320
    }
321

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
409
        return true;
410
    }
411

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

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

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

    
453
        defaultValue = state.get("defaultValue");
454

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

    
479
    /*
480
     * Start of DynField interface Implementation
481
     *
482
     */
483
    
484
    public Tags getTags() {
485
        return tags;
486
    }
487
    
488
    @Override
489
    public DynObjectValueItem[] getAvailableValues() {
490
        return this.availableValues;
491
    }
492

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

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

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

    
511
    @Override
512
    public int getTheTypeOfAvailableValues() {
513
        return 1;
514
    }
515

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

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

    
529
    @Override
530
    public boolean isPersistent() {
531
        return false;
532
    }
533

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

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

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

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

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

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

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

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

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

    
595
    @Override
596
    public Class getClassOfValue() {
597
        return null;
598
    }
599

    
600
    @Override
601
    public DynField getElementsType() {
602
        return null;
603
    }
604

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

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

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

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

    
628
    @Override
629
    public void validate(Object value) throws DynFieldValidateException {
630

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

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

    
641
        /*
642
         * Other checks will be needed
643
         */
644
    }
645

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

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

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

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

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

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

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

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

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

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

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

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

    
730
    @Override
731
    public boolean isContainer() {
732
        return false;
733
    }
734

    
735
    @Override
736
    public Class getClassOfItems() {
737
        return null;
738
    }
739

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

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

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

    
755
    @Override
756
    public boolean isTime() {
757
        return isTime;
758
    }
759

    
760
    @Override
761
    public FeatureAttributeGetter getFeatureAttributeGetter() {
762
        return featureAttributeGetter;
763
    }
764

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

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

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

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

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

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

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

    
801
    @Override
802
    public String getClassNameOfValue() {
803
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
804
    }
805

    
806
    @Override
807
    public DynStruct getDynClassOfValue() {
808
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
809
    }
810

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

    
816
    @Override
817
    public int getTypeOfItems() {
818
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
819
    }
820

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

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

    
831
    @Override
832
    public String getClassNameOfItems() {
833
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
834
    }
835

    
836
    @Override
837
    public DynStruct getDynClassOfItems() {
838
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
839
    }
840

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

    
846
    @Override
847
    public int getRelationType() {
848
        return RELATION_TYPE_NONE;
849
    }
850

    
851
    private class ConstantValueEvaluator extends AbstractEvaluator {
852

    
853
        @Override
854
        public Object evaluate(EvaluatorData data) throws EvaluatorException {
855
            return defaultValue;
856
        }
857

    
858
        @Override
859
        public String getName() {
860
            return "Constant attribute " + name;
861
        }
862
    }
863

    
864
    public void setConstantValue(boolean isConstantValue) {
865
        if (isConstantValue) {
866
            /* Cuando un attributo tiene asociado un evaluador, este se interpreta
867
             * como que no debe cargarse de la fuente de datos subyacente, siendo 
868
             * el evaluador el que se encarga de proporcionar su valor.
869
             * Nos limitamos a asignar un evaluador que retorna simpre el valor
870
             * por defecto para ese attributo.
871
             */
872
            this.evaluator = new ConstantValueEvaluator();
873
        } else {
874
            this.evaluator = null;
875
        }
876
    }
877

    
878
}