Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / DefaultEditableFeatureAttributeDescriptor.java @ 30266

History | View | Annotate | Download (4.74 KB)

1
package org.gvsig.fmap.dal.feature.impl;
2

    
3
import java.util.HashMap;
4

    
5
import org.cresques.cts.IProjection;
6
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
7
import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeIntegrityException;
8
import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeSizeException;
9
import org.gvsig.tools.evaluator.Evaluator;
10

    
11
public class DefaultEditableFeatureAttributeDescriptor extends
12
                DefaultFeatureAttributeDescriptor implements
13
                EditableFeatureAttributeDescriptor {
14

    
15
        private DefaultFeatureAttributeDescriptor source;
16
        private boolean hasStrongChanges;
17

    
18
        protected DefaultEditableFeatureAttributeDescriptor(
19
                        DefaultFeatureAttributeDescriptor other) {
20
                super(other);
21
                this.source = other;
22
                hasStrongChanges=false;
23
        }
24

    
25
        protected DefaultEditableFeatureAttributeDescriptor(
26
                        DefaultEditableFeatureAttributeDescriptor other) {
27
                super(other);
28
                this.source = other.getSource();
29
                hasStrongChanges = false;
30
        }
31

    
32
        public DefaultEditableFeatureAttributeDescriptor() {
33
                super();
34
                this.source = null;
35
                hasStrongChanges = false;
36
        }
37

    
38
        public DefaultFeatureAttributeDescriptor getSource() {
39
                return this.source;
40
        }
41

    
42
        public void fixAll() {
43
        }
44

    
45
        public void checkIntegrity() throws AttributeFeatureTypeIntegrityException {
46
                AttributeFeatureTypeIntegrityException ex = new AttributeFeatureTypeIntegrityException(
47
                                getName());
48
                if (this.size < 0) {
49
                        ex.add(new AttributeFeatureTypeSizeException(this.size));
50
                }
51

    
52
                // TODO: a?adir resto de comprobaciones de integridad.
53

    
54
                if (ex.size() > 0) {
55
                        throw ex;
56
                }
57
        }
58

    
59
        public EditableFeatureAttributeDescriptor setAllowNull(boolean allowNull) {
60
                this.allowNull = allowNull;
61
                if( this.evaluator != null ) {
62
                        hasStrongChanges=true;
63
                }
64
                return this;
65
        }
66

    
67
        public EditableFeatureAttributeDescriptor setDataType(int type) {
68
                this.dataType  = type;
69
                if( this.evaluator != null ) {
70
                        hasStrongChanges=true;
71
                }
72
                return this;
73
        }
74

    
75
        public EditableFeatureAttributeDescriptor setDefaultValue(
76
                        Object defaultValue) {
77
                this.defaultValue = defaultValue;
78
                if( this.evaluator != null ) {
79
                        hasStrongChanges=true;
80
                }
81
                return this;
82
        }
83

    
84
        public EditableFeatureAttributeDescriptor setEvaluator(Evaluator evaluator) {
85
                this.evaluator = evaluator;
86
                if( this.evaluator != null ) {
87
                        hasStrongChanges=true;
88
                }
89
                return this;
90
        }
91

    
92
        public EditableFeatureAttributeDescriptor setGeometryType(int geometryType) {
93
                this.geometryType= geometryType;
94
                if( this.evaluator != null ) {
95
                        hasStrongChanges=true;
96
                }
97
                return this;
98
        }
99

    
100
        public EditableFeatureAttributeDescriptor setIsPrimaryKey(
101
                        boolean isPrimaryKey) {
102
                this.primaryKey = isPrimaryKey;
103
                if( this.evaluator != null ) {
104
                        hasStrongChanges=true;
105
                }
106
                return this;
107
        }
108

    
109
        public EditableFeatureAttributeDescriptor setIsReadOnly(boolean isReadOnly) {
110
                this.readOnly = isReadOnly;
111
                if( this.evaluator != null ) {
112
                        hasStrongChanges=true;
113
                }
114
                return this;
115
        }
116

    
117
        public EditableFeatureAttributeDescriptor setMaximumOccurrences(
118
                        int maximumOccurrences) {
119
                this.maximumOccurrences = maximumOccurrences;
120
                if( this.evaluator != null ) {
121
                        hasStrongChanges=true;
122
                }
123
                return this;
124
        }
125

    
126
        public EditableFeatureAttributeDescriptor setMinimumOccurrences(
127
                        int minimumOccurrences) {
128
                this.minimumOccurrences = minimumOccurrences;
129
                if( this.evaluator != null ) {
130
                        hasStrongChanges=true;
131
                }
132
                return this;
133
        }
134

    
135
        public EditableFeatureAttributeDescriptor setName(String name) {
136
                this.name = name;
137
                if( this.evaluator != null ) {
138
                        hasStrongChanges=true;
139
                }
140
                return this;
141
        }
142

    
143
        public EditableFeatureAttributeDescriptor setObjectClass(Class theClass) {
144
                this.objectClass = theClass;
145
                if( this.evaluator != null ) {
146
                        hasStrongChanges=true;
147
                }
148
                return this;
149
        }
150

    
151
        public EditableFeatureAttributeDescriptor setPrecision(int precision) {
152
                this.precision = precision;
153
                if( this.evaluator != null ) {
154
                        hasStrongChanges=true;
155
                }
156
                return this;
157
        }
158

    
159
        public EditableFeatureAttributeDescriptor setSRS(IProjection SRS) {
160
                this.SRS = SRS;
161
                if( this.evaluator != null ) {
162
                        hasStrongChanges=true;
163
                }
164
                return this;
165
        }
166

    
167
        public EditableFeatureAttributeDescriptor setSize(int size) {
168
                this.size = size;
169
                if( this.evaluator != null ) {
170
                        hasStrongChanges=true;
171
                }
172
                return this;
173
        }
174

    
175
        public boolean hasStrongChanges() {
176
                return hasStrongChanges;
177
        }
178

    
179
        public EditableFeatureAttributeDescriptor setAdditionalInfo(String infoName, Object value) {
180
                if (this.additionalInfo == null) {
181
                        this.additionalInfo = new HashMap();
182
                }
183
                this.additionalInfo.put(infoName, value);
184
                return this;
185
        }
186

    
187
        public EditableFeatureAttributeDescriptor setIsAutomatic(boolean isAutomatic) {
188
                this.isAutomatic = isAutomatic;
189
                return this;
190
        }
191

    
192
        public EditableFeatureAttributeDescriptor setGeometrySubType(
193
                        int geometrySubType) {
194
                this.geometrySubType = geometrySubType;
195
                return this;
196
        }
197

    
198

    
199
}