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 | 24496 | jmvivo | package org.gvsig.fmap.dal.feature.impl; |
---|---|---|---|
2 | 23754 | jjdelcerro | |
3 | 27439 | jmvivo | import java.util.HashMap; |
4 | |||
5 | 26717 | jmvivo | import org.cresques.cts.IProjection; |
6 | 37297 | jpiera | |
7 | 24496 | jmvivo | import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
8 | 24505 | jmvivo | import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeIntegrityException; |
9 | import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeSizeException; |
||
10 | 37328 | cordinyana | import org.gvsig.fmap.geom.type.GeometryType; |
11 | 33331 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
12 | 23754 | jjdelcerro | import org.gvsig.tools.evaluator.Evaluator; |
13 | |||
14 | public class DefaultEditableFeatureAttributeDescriptor extends |
||
15 | 37328 | cordinyana | DefaultFeatureAttributeDescriptor implements
|
16 | EditableFeatureAttributeDescriptor { |
||
17 | 23754 | jjdelcerro | |
18 | 37328 | cordinyana | private DefaultFeatureAttributeDescriptor source;
|
19 | private boolean hasStrongChanges; |
||
20 | 23754 | jjdelcerro | |
21 | 37328 | cordinyana | protected DefaultEditableFeatureAttributeDescriptor(
|
22 | DefaultFeatureAttributeDescriptor other) { |
||
23 | super(other);
|
||
24 | this.source = other;
|
||
25 | hasStrongChanges = false;
|
||
26 | } |
||
27 | 23754 | jjdelcerro | |
28 | 37328 | cordinyana | protected DefaultEditableFeatureAttributeDescriptor(
|
29 | DefaultEditableFeatureAttributeDescriptor other) { |
||
30 | super(other);
|
||
31 | this.source = other.getSource();
|
||
32 | hasStrongChanges = false;
|
||
33 | } |
||
34 | 23754 | jjdelcerro | |
35 | 37328 | cordinyana | public DefaultEditableFeatureAttributeDescriptor() {
|
36 | super();
|
||
37 | this.source = null; |
||
38 | hasStrongChanges = false;
|
||
39 | } |
||
40 | 23754 | jjdelcerro | |
41 | 37328 | cordinyana | public DefaultFeatureAttributeDescriptor getSource() {
|
42 | return this.source; |
||
43 | } |
||
44 | 23754 | jjdelcerro | |
45 | 37328 | cordinyana | public void fixAll() { |
46 | } |
||
47 | 23754 | jjdelcerro | |
48 | 37328 | cordinyana | 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 | 23772 | jjdelcerro | |
55 | 37328 | cordinyana | // TODO: a?adir resto de comprobaciones de integridad.
|
56 | 23772 | jjdelcerro | |
57 | 37328 | cordinyana | if (ex.size() > 0) { |
58 | throw ex;
|
||
59 | } |
||
60 | } |
||
61 | 23754 | jjdelcerro | |
62 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setAllowNull(boolean allowNull) { |
63 | this.allowNull = allowNull;
|
||
64 | if (this.evaluator != null) { |
||
65 | hasStrongChanges = true;
|
||
66 | } |
||
67 | return this; |
||
68 | } |
||
69 | 23754 | jjdelcerro | |
70 | 37328 | cordinyana | 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 | 23754 | jjdelcerro | |
78 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setDefaultValue(
|
79 | Object defaultValue) {
|
||
80 | this.defaultValue = defaultValue;
|
||
81 | if (this.evaluator != null) { |
||
82 | hasStrongChanges = true;
|
||
83 | } |
||
84 | return this; |
||
85 | } |
||
86 | 23754 | jjdelcerro | |
87 | 37328 | cordinyana | 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 | 23754 | jjdelcerro | |
95 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setGeometryType(int type) { |
96 | this.geometryType = type;
|
||
97 | this.geomType = null; |
||
98 | return this; |
||
99 | } |
||
100 | 23754 | jjdelcerro | |
101 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setGeometrySubType(int subType) { |
102 | this.geometrySubType = subType;
|
||
103 | this.geomType = null; |
||
104 | return this; |
||
105 | } |
||
106 | 23754 | jjdelcerro | |
107 | 37328 | cordinyana | 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 | 23754 | jjdelcerro | |
118 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setIsPrimaryKey(
|
119 | boolean isPrimaryKey) {
|
||
120 | this.primaryKey = isPrimaryKey;
|
||
121 | if (this.evaluator != null) { |
||
122 | hasStrongChanges = true;
|
||
123 | } |
||
124 | return this; |
||
125 | } |
||
126 | 23754 | jjdelcerro | |
127 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setIsReadOnly(boolean isReadOnly) { |
128 | this.readOnly = isReadOnly;
|
||
129 | if (this.evaluator != null) { |
||
130 | hasStrongChanges = true;
|
||
131 | } |
||
132 | return this; |
||
133 | } |
||
134 | 23754 | jjdelcerro | |
135 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setMaximumOccurrences(
|
136 | int maximumOccurrences) {
|
||
137 | this.maximumOccurrences = maximumOccurrences;
|
||
138 | if (this.evaluator != null) { |
||
139 | hasStrongChanges = true;
|
||
140 | } |
||
141 | return this; |
||
142 | } |
||
143 | 23754 | jjdelcerro | |
144 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setMinimumOccurrences(
|
145 | int minimumOccurrences) {
|
||
146 | this.minimumOccurrences = minimumOccurrences;
|
||
147 | if (this.evaluator != null) { |
||
148 | hasStrongChanges = true;
|
||
149 | } |
||
150 | return this; |
||
151 | } |
||
152 | 23754 | jjdelcerro | |
153 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setName(String name) { |
154 | this.name = name;
|
||
155 | if (this.evaluator != null) { |
||
156 | hasStrongChanges = true;
|
||
157 | } |
||
158 | return this; |
||
159 | } |
||
160 | 23754 | jjdelcerro | |
161 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setObjectClass(Class theClass) { |
162 | this.objectClass = theClass;
|
||
163 | if (this.evaluator != null) { |
||
164 | hasStrongChanges = true;
|
||
165 | } |
||
166 | return this; |
||
167 | } |
||
168 | 23754 | jjdelcerro | |
169 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setPrecision(int precision) { |
170 | this.precision = precision;
|
||
171 | if (this.evaluator != null) { |
||
172 | hasStrongChanges = true;
|
||
173 | } |
||
174 | return this; |
||
175 | } |
||
176 | 23754 | jjdelcerro | |
177 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setSRS(IProjection SRS) {
|
178 | this.SRS = SRS;
|
||
179 | if (this.evaluator != null) { |
||
180 | hasStrongChanges = true;
|
||
181 | } |
||
182 | return this; |
||
183 | } |
||
184 | 23754 | jjdelcerro | |
185 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setSize(int size) { |
186 | this.size = size;
|
||
187 | if (this.evaluator != null) { |
||
188 | hasStrongChanges = true;
|
||
189 | } |
||
190 | return this; |
||
191 | } |
||
192 | 27439 | jmvivo | |
193 | 37328 | cordinyana | public boolean hasStrongChanges() { |
194 | return hasStrongChanges;
|
||
195 | } |
||
196 | 27550 | jmvivo | |
197 | 37328 | cordinyana | 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 | 27550 | jmvivo | |
206 | 37328 | cordinyana | public EditableFeatureAttributeDescriptor setIsAutomatic(boolean isAutomatic) { |
207 | this.isAutomatic = isAutomatic;
|
||
208 | return this; |
||
209 | } |
||
210 | |||
211 | 37297 | jpiera | public EditableFeatureAttributeDescriptor setIsTime(boolean isTime) { |
212 | this.isTime = isTime;
|
||
213 | if( this.evaluator != null ) { |
||
214 | hasStrongChanges=true;
|
||
215 | } |
||
216 | return this; |
||
217 | } |
||
218 | 23754 | jjdelcerro | } |