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 / DefaultEditableFeatureAttributeDescriptor.java @ 40435
History | View | Annotate | Download (6.55 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.fmap.geom.type.GeometryType; |
11 |
import org.gvsig.tools.ToolsLocator; |
12 |
import org.gvsig.tools.evaluator.Evaluator; |
13 |
|
14 |
public class DefaultEditableFeatureAttributeDescriptor extends |
15 |
DefaultFeatureAttributeDescriptor implements
|
16 |
EditableFeatureAttributeDescriptor { |
17 |
|
18 |
private DefaultFeatureAttributeDescriptor source;
|
19 |
private boolean hasStrongChanges; |
20 |
private String originalName = null; |
21 |
|
22 |
protected DefaultEditableFeatureAttributeDescriptor(
|
23 |
DefaultFeatureAttributeDescriptor other) { |
24 |
super(other);
|
25 |
if (other instanceof DefaultEditableFeatureAttributeDescriptor) { |
26 |
DefaultEditableFeatureAttributeDescriptor other_edi = |
27 |
(DefaultEditableFeatureAttributeDescriptor) other; |
28 |
originalName = other_edi.getOriginalName(); |
29 |
this.source = other_edi.getSource();
|
30 |
} else {
|
31 |
this.source = other;
|
32 |
} |
33 |
hasStrongChanges = false;
|
34 |
} |
35 |
|
36 |
public DefaultEditableFeatureAttributeDescriptor() {
|
37 |
super();
|
38 |
this.source = null; |
39 |
hasStrongChanges = false;
|
40 |
} |
41 |
|
42 |
public DefaultFeatureAttributeDescriptor getSource() {
|
43 |
return this.source; |
44 |
} |
45 |
|
46 |
public void fixAll() { |
47 |
} |
48 |
|
49 |
public void checkIntegrity() throws AttributeFeatureTypeIntegrityException { |
50 |
AttributeFeatureTypeIntegrityException ex = |
51 |
new AttributeFeatureTypeIntegrityException(getName());
|
52 |
if (this.size < 0) { |
53 |
ex.add(new AttributeFeatureTypeSizeException(this.size)); |
54 |
} |
55 |
|
56 |
// TODO: a?adir resto de comprobaciones de integridad.
|
57 |
|
58 |
if (ex.size() > 0) { |
59 |
throw ex;
|
60 |
} |
61 |
} |
62 |
|
63 |
public EditableFeatureAttributeDescriptor setAllowNull(boolean allowNull) { |
64 |
this.allowNull = allowNull;
|
65 |
if (this.evaluator != null) { |
66 |
hasStrongChanges = true;
|
67 |
} |
68 |
return this; |
69 |
} |
70 |
|
71 |
public EditableFeatureAttributeDescriptor setDataType(int type) { |
72 |
this.dataType = ToolsLocator.getDataTypesManager().get(type);
|
73 |
if (this.evaluator != null) { |
74 |
hasStrongChanges = true;
|
75 |
} |
76 |
return this; |
77 |
} |
78 |
|
79 |
public EditableFeatureAttributeDescriptor setDefaultValue(
|
80 |
Object defaultValue) {
|
81 |
this.defaultValue = defaultValue;
|
82 |
if (this.evaluator != null) { |
83 |
hasStrongChanges = true;
|
84 |
} |
85 |
return this; |
86 |
} |
87 |
|
88 |
public EditableFeatureAttributeDescriptor setEvaluator(Evaluator evaluator) {
|
89 |
if (this.evaluator != null && evaluator == null) { |
90 |
hasStrongChanges = true;
|
91 |
} |
92 |
this.evaluator = evaluator;
|
93 |
return this; |
94 |
} |
95 |
|
96 |
public EditableFeatureAttributeDescriptor setGeometryType(int type) { |
97 |
this.geometryType = type;
|
98 |
this.geomType = null; |
99 |
return this; |
100 |
} |
101 |
|
102 |
public EditableFeatureAttributeDescriptor setGeometrySubType(int subType) { |
103 |
this.geometrySubType = subType;
|
104 |
this.geomType = null; |
105 |
return this; |
106 |
} |
107 |
|
108 |
public EditableFeatureAttributeDescriptor setGeometryType(
|
109 |
GeometryType geometryType) { |
110 |
this.geomType = geometryType;
|
111 |
this.geometryType = this.geomType.getType(); |
112 |
this.geometrySubType = this.geomType.getSubType(); |
113 |
if (this.evaluator != null) { |
114 |
hasStrongChanges = true;
|
115 |
} |
116 |
return this; |
117 |
} |
118 |
|
119 |
public EditableFeatureAttributeDescriptor setIsPrimaryKey(
|
120 |
boolean isPrimaryKey) {
|
121 |
this.primaryKey = isPrimaryKey;
|
122 |
if (this.evaluator != null) { |
123 |
hasStrongChanges = true;
|
124 |
} |
125 |
return this; |
126 |
} |
127 |
|
128 |
public EditableFeatureAttributeDescriptor setIsReadOnly(boolean isReadOnly) { |
129 |
this.readOnly = isReadOnly;
|
130 |
if (this.evaluator != null) { |
131 |
hasStrongChanges = true;
|
132 |
} |
133 |
return this; |
134 |
} |
135 |
|
136 |
public EditableFeatureAttributeDescriptor setMaximumOccurrences(
|
137 |
int maximumOccurrences) {
|
138 |
this.maximumOccurrences = maximumOccurrences;
|
139 |
if (this.evaluator != null) { |
140 |
hasStrongChanges = true;
|
141 |
} |
142 |
return this; |
143 |
} |
144 |
|
145 |
public EditableFeatureAttributeDescriptor setMinimumOccurrences(
|
146 |
int minimumOccurrences) {
|
147 |
this.minimumOccurrences = minimumOccurrences;
|
148 |
if (this.evaluator != null) { |
149 |
hasStrongChanges = true;
|
150 |
} |
151 |
return this; |
152 |
} |
153 |
|
154 |
public EditableFeatureAttributeDescriptor setName(String name) { |
155 |
if (originalName == null) { |
156 |
originalName = this.name;
|
157 |
hasStrongChanges = true;
|
158 |
} |
159 |
this.name = name;
|
160 |
if (this.evaluator != null) { |
161 |
hasStrongChanges = true;
|
162 |
} |
163 |
return this; |
164 |
} |
165 |
|
166 |
public String getOriginalName() { |
167 |
return originalName;
|
168 |
} |
169 |
|
170 |
public EditableFeatureAttributeDescriptor setObjectClass(Class theClass) { |
171 |
this.objectClass = theClass;
|
172 |
if (this.evaluator != null) { |
173 |
hasStrongChanges = true;
|
174 |
} |
175 |
return this; |
176 |
} |
177 |
|
178 |
public EditableFeatureAttributeDescriptor setPrecision(int precision) { |
179 |
this.precision = precision;
|
180 |
if (this.evaluator != null) { |
181 |
hasStrongChanges = true;
|
182 |
} |
183 |
return this; |
184 |
} |
185 |
|
186 |
public EditableFeatureAttributeDescriptor setSRS(IProjection SRS) {
|
187 |
this.SRS = SRS;
|
188 |
if (this.evaluator != null) { |
189 |
hasStrongChanges = true;
|
190 |
} |
191 |
return this; |
192 |
} |
193 |
|
194 |
public EditableFeatureAttributeDescriptor setSize(int size) { |
195 |
this.size = size;
|
196 |
if (this.evaluator != null) { |
197 |
hasStrongChanges = true;
|
198 |
} |
199 |
return this; |
200 |
} |
201 |
|
202 |
public boolean hasStrongChanges() { |
203 |
return hasStrongChanges;
|
204 |
} |
205 |
|
206 |
public EditableFeatureAttributeDescriptor setAdditionalInfo(
|
207 |
String infoName, Object value) { |
208 |
if (this.additionalInfo == null) { |
209 |
this.additionalInfo = new HashMap(); |
210 |
} |
211 |
this.additionalInfo.put(infoName, value);
|
212 |
return this; |
213 |
} |
214 |
|
215 |
public EditableFeatureAttributeDescriptor setIsAutomatic(boolean isAutomatic) { |
216 |
this.isAutomatic = isAutomatic;
|
217 |
return this; |
218 |
} |
219 |
|
220 |
public EditableFeatureAttributeDescriptor setIsTime(boolean isTime) { |
221 |
this.isTime = isTime;
|
222 |
if( this.evaluator != null ) { |
223 |
hasStrongChanges=true;
|
224 |
} |
225 |
return this; |
226 |
} |
227 |
} |