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