Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / DefaultEditableFeatureAttributeDescriptor.java @ 37297

History | View | Annotate | Download (5.03 KB)

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

    
3
import java.util.HashMap;
4

    
5
import org.cresques.cts.IProjection;
6

    
7
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
8
import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeIntegrityException;
9
import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeSizeException;
10
import org.gvsig.tools.ToolsLocator;
11
import org.gvsig.tools.evaluator.Evaluator;
12

    
13
public class DefaultEditableFeatureAttributeDescriptor extends
14
                DefaultFeatureAttributeDescriptor implements
15
                EditableFeatureAttributeDescriptor {
16

    
17
        private DefaultFeatureAttributeDescriptor source;
18
        private boolean hasStrongChanges;
19

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

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

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

    
40
        public DefaultFeatureAttributeDescriptor getSource() {
41
                return this.source;
42
        }
43

    
44
        public void fixAll() {
45
        }
46

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

    
54
                // TODO: a?adir resto de comprobaciones de integridad.
55

    
56
                if (ex.size() > 0) {
57
                        throw ex;
58
                }
59
        }
60

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

    
69
        public EditableFeatureAttributeDescriptor setDataType(int type) {
70
                this.dataType  = ToolsLocator.getDataTypesManager().get(type);
71
                if( this.evaluator != null ) {
72
                        hasStrongChanges=true;
73
                }
74
                return this;
75
        }
76

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

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

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

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

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

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

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

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

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

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

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

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

    
177
        public boolean hasStrongChanges() {
178
                return hasStrongChanges;
179
        }
180

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

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

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

    
200
        public EditableFeatureAttributeDescriptor setIsTime(boolean isTime) {
201
                this.isTime = isTime;
202
                if( this.evaluator != null ) {
203
            hasStrongChanges=true;
204
        }
205
                return this;
206
        }
207
}