Revision 37328 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java
DefaultFeatureAttributeDescriptor.java | ||
---|---|---|
13 | 13 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
14 | 14 |
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter; |
15 | 15 |
import org.gvsig.fmap.geom.Geometry; |
16 |
import org.gvsig.fmap.geom.GeometryException; |
|
17 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
18 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
16 | 19 |
import org.gvsig.tools.ToolsLocator; |
17 | 20 |
import org.gvsig.tools.dataTypes.DataType; |
18 | 21 |
import org.gvsig.tools.dataTypes.DataTypes; |
... | ... | |
27 | 30 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
28 | 31 |
|
29 | 32 |
public class DefaultFeatureAttributeDescriptor implements |
30 |
FeatureAttributeDescriptor, Persistent, DynField {
|
|
33 |
FeatureAttributeDescriptor, Persistent, DynField {
|
|
31 | 34 |
|
32 |
protected boolean allowNull; |
|
33 |
protected DataType dataType; |
|
34 |
protected DateFormat dateFormat; |
|
35 |
protected Object defaultValue; |
|
36 |
protected int index; |
|
37 |
protected int maximumOccurrences; |
|
38 |
protected int minimumOccurrences; |
|
39 |
protected int size; |
|
40 |
protected String name; |
|
41 |
protected Class objectClass; |
|
42 |
protected int precision; |
|
43 |
protected Evaluator evaluator; |
|
44 |
protected boolean primaryKey; |
|
45 |
protected boolean readOnly; |
|
46 |
protected IProjection SRS; |
|
47 |
protected int geometryType; |
|
48 |
protected int geometrySubType; |
|
49 |
protected Map additionalInfo; |
|
50 |
protected boolean isAutomatic; |
|
35 |
protected boolean allowNull; |
|
36 |
protected DataType dataType; |
|
37 |
protected DateFormat dateFormat; |
|
38 |
protected Object defaultValue; |
|
39 |
protected int index; |
|
40 |
protected int maximumOccurrences; |
|
41 |
protected int minimumOccurrences; |
|
42 |
protected int size; |
|
43 |
protected String name; |
|
44 |
protected Class objectClass; |
|
45 |
protected int precision; |
|
46 |
protected Evaluator evaluator; |
|
47 |
protected boolean primaryKey; |
|
48 |
protected boolean readOnly; |
|
49 |
protected IProjection SRS; |
|
50 |
protected GeometryType geomType; |
|
51 |
protected int geometryType; |
|
52 |
protected int geometrySubType; |
|
53 |
protected Map additionalInfo; |
|
54 |
protected boolean isAutomatic; |
|
51 | 55 |
protected boolean isTime = false; |
52 | 56 |
protected FeatureAttributeGetter featureAttributeGetter = null; |
53 | 57 |
|
58 |
protected DefaultFeatureAttributeDescriptor() { |
|
59 |
this.allowNull = true; |
|
60 |
this.dataType = null; |
|
61 |
this.dateFormat = null; |
|
62 |
this.defaultValue = null; |
|
63 |
this.index = -1; |
|
64 |
this.maximumOccurrences = 0; |
|
65 |
this.minimumOccurrences = 0; |
|
66 |
this.size = 0; |
|
67 |
this.name = null; |
|
68 |
this.objectClass = null; |
|
69 |
this.precision = 0; |
|
70 |
this.evaluator = null; |
|
71 |
this.primaryKey = false; |
|
72 |
this.readOnly = false; |
|
73 |
this.SRS = null; |
|
74 |
this.geometryType = Geometry.TYPES.NULL; |
|
75 |
this.geometrySubType = Geometry.SUBTYPES.UNKNOWN; |
|
76 |
this.additionalInfo = null; |
|
77 |
this.isAutomatic = false; |
|
78 |
} |
|
54 | 79 |
|
55 |
protected DefaultFeatureAttributeDescriptor() { |
|
56 |
this.allowNull = true; |
|
57 |
this.dataType = null; |
|
58 |
this.dateFormat = null; |
|
59 |
this.defaultValue = null; |
|
60 |
this.index = -1; |
|
61 |
this.maximumOccurrences = 0; |
|
62 |
this.minimumOccurrences = 0; |
|
63 |
this.size = 0; |
|
64 |
this.name = null; |
|
65 |
this.objectClass = null; |
|
66 |
this.precision = 0; |
|
67 |
this.evaluator = null; |
|
68 |
this.primaryKey = false; |
|
69 |
this.readOnly = false; |
|
70 |
this.SRS = null; |
|
71 |
this.geometryType = Geometry.TYPES.NULL; |
|
72 |
this.geometrySubType = Geometry.SUBTYPES.UNKNOWN; |
|
73 |
this.additionalInfo = null; |
|
74 |
this.isAutomatic = false; |
|
75 |
} |
|
76 |
|
|
77 |
protected DefaultFeatureAttributeDescriptor( |
|
78 |
DefaultFeatureAttributeDescriptor other) { |
|
79 |
this.allowNull = other.allowNull; |
|
80 |
this.dataType = other.dataType; |
|
81 |
this.dateFormat = other.dateFormat; |
|
82 |
this.defaultValue = other.defaultValue; |
|
83 |
this.index = other.index; |
|
84 |
this.maximumOccurrences = other.maximumOccurrences; |
|
85 |
this.minimumOccurrences = other.minimumOccurrences; |
|
86 |
this.size = other.size; |
|
87 |
this.name = other.name; |
|
88 |
this.objectClass = other.objectClass; |
|
89 |
this.precision = other.precision; |
|
90 |
this.evaluator = other.evaluator; |
|
91 |
this.primaryKey = other.primaryKey; |
|
92 |
this.readOnly = other.readOnly; |
|
93 |
this.SRS = other.SRS; |
|
94 |
this.geometryType = other.geometryType; |
|
95 |
this.geometrySubType = other.geometrySubType; |
|
96 |
if (other.additionalInfo != null) { |
|
97 |
Iterator iter = other.additionalInfo.entrySet().iterator(); |
|
98 |
Map.Entry entry; |
|
99 |
this.additionalInfo = new HashMap(); |
|
100 |
while (iter.hasNext()) { |
|
101 |
entry = (Entry) iter.next(); |
|
102 |
this.additionalInfo.put(entry.getKey(), entry.getValue()); |
|
103 |
} |
|
104 |
} else { |
|
105 |
this.additionalInfo = null; |
|
106 |
} |
|
107 |
this.isAutomatic = other.isAutomatic; |
|
80 |
protected DefaultFeatureAttributeDescriptor( |
|
81 |
DefaultFeatureAttributeDescriptor other) { |
|
82 |
this.allowNull = other.allowNull; |
|
83 |
this.dataType = other.dataType; |
|
84 |
this.dateFormat = other.dateFormat; |
|
85 |
this.defaultValue = other.defaultValue; |
|
86 |
this.index = other.index; |
|
87 |
this.maximumOccurrences = other.maximumOccurrences; |
|
88 |
this.minimumOccurrences = other.minimumOccurrences; |
|
89 |
this.size = other.size; |
|
90 |
this.name = other.name; |
|
91 |
this.objectClass = other.objectClass; |
|
92 |
this.precision = other.precision; |
|
93 |
this.evaluator = other.evaluator; |
|
94 |
this.primaryKey = other.primaryKey; |
|
95 |
this.readOnly = other.readOnly; |
|
96 |
this.SRS = other.SRS; |
|
97 |
this.geometryType = other.geometryType; |
|
98 |
this.geometrySubType = other.geometrySubType; |
|
99 |
this.geomType = other.geomType; |
|
100 |
if (other.additionalInfo != null) { |
|
101 |
Iterator iter = other.additionalInfo.entrySet().iterator(); |
|
102 |
Map.Entry entry; |
|
103 |
this.additionalInfo = new HashMap(); |
|
104 |
while (iter.hasNext()) { |
|
105 |
entry = (Entry) iter.next(); |
|
106 |
this.additionalInfo.put(entry.getKey(), entry.getValue()); |
|
107 |
} |
|
108 |
} else { |
|
109 |
this.additionalInfo = null; |
|
110 |
} |
|
111 |
this.isAutomatic = other.isAutomatic; |
|
108 | 112 |
this.isTime = other.isTime; |
109 | 113 |
this.featureAttributeGetter = other.featureAttributeGetter; |
110 |
}
|
|
114 |
}
|
|
111 | 115 |
|
112 |
public String getDataTypeName() {
|
|
116 |
public String getDataTypeName() {
|
|
113 | 117 |
if( this.getDataType() == null ) { |
114 |
return "(unknow)";
|
|
115 |
}
|
|
118 |
return "(unknow)";
|
|
119 |
}
|
|
116 | 120 |
return this.getDataType().getName(); |
117 |
}
|
|
121 |
}
|
|
118 | 122 |
|
119 |
public FeatureAttributeDescriptor getCopy() {
|
|
120 |
return new DefaultFeatureAttributeDescriptor(this);
|
|
121 |
}
|
|
123 |
public FeatureAttributeDescriptor getCopy() {
|
|
124 |
return new DefaultFeatureAttributeDescriptor(this);
|
|
125 |
}
|
|
122 | 126 |
|
123 |
public boolean allowNull() {
|
|
124 |
return allowNull;
|
|
125 |
}
|
|
127 |
public boolean allowNull() {
|
|
128 |
return allowNull;
|
|
129 |
}
|
|
126 | 130 |
|
127 |
public DataType getDataType() {
|
|
131 |
public DataType getDataType() {
|
|
128 | 132 |
if (featureAttributeGetter != null){ |
129 | 133 |
return featureAttributeGetter.getDataType(); |
130 | 134 |
} |
131 |
return this.dataType;
|
|
132 |
}
|
|
135 |
return this.dataType;
|
|
136 |
}
|
|
133 | 137 |
|
134 |
public DateFormat getDateFormat() {
|
|
135 |
return this.dateFormat;
|
|
136 |
}
|
|
138 |
public DateFormat getDateFormat() {
|
|
139 |
return this.dateFormat;
|
|
140 |
}
|
|
137 | 141 |
|
138 |
public Object getDefaultValue() {
|
|
139 |
return this.defaultValue;
|
|
140 |
}
|
|
142 |
public Object getDefaultValue() {
|
|
143 |
return this.defaultValue;
|
|
144 |
}
|
|
141 | 145 |
|
142 |
public Evaluator getEvaluator() {
|
|
143 |
return this.evaluator;
|
|
144 |
}
|
|
146 |
public Evaluator getEvaluator() {
|
|
147 |
return this.evaluator;
|
|
148 |
}
|
|
145 | 149 |
|
146 |
public int getGeometryType() {
|
|
147 |
return this.geometryType;
|
|
148 |
}
|
|
150 |
public int getGeometryType() {
|
|
151 |
return this.geometryType;
|
|
152 |
}
|
|
149 | 153 |
|
150 |
public int getGeometrySubType() {
|
|
151 |
return this.geometrySubType;
|
|
152 |
}
|
|
154 |
public int getGeometrySubType() {
|
|
155 |
return this.geometrySubType;
|
|
156 |
}
|
|
153 | 157 |
|
154 |
public int getIndex() { |
|
155 |
return this.index; |
|
156 |
} |
|
158 |
public GeometryType getGeomType() { |
|
159 |
if (this.geomType == null) { |
|
160 |
try { |
|
161 |
this.geomType = |
|
162 |
GeometryLocator.getGeometryManager().getGeometryType( |
|
163 |
this.geometryType, this.geometrySubType); |
|
164 |
} catch (GeometryException e) { |
|
165 |
throw new RuntimeException( |
|
166 |
"Error getting geometry type with type = " |
|
167 |
+ Geometry.TYPES.NULL + ", subtype = " |
|
168 |
+ Geometry.SUBTYPES.GEOM2D, e); |
|
169 |
} |
|
170 |
} |
|
171 |
return this.geomType; |
|
172 |
} |
|
157 | 173 |
|
158 |
protected FeatureAttributeDescriptor setIndex(int index) { |
|
159 |
this.index = index; |
|
160 |
return this; |
|
161 |
} |
|
174 |
public int getIndex() { |
|
175 |
return this.index; |
|
176 |
} |
|
162 | 177 |
|
163 |
public int getMaximumOccurrences() { |
|
164 |
return this.maximumOccurrences; |
|
165 |
} |
|
178 |
protected FeatureAttributeDescriptor setIndex(int index) { |
|
179 |
this.index = index; |
|
180 |
return this; |
|
181 |
} |
|
166 | 182 |
|
167 |
public int getMinimumOccurrences() {
|
|
168 |
return this.minimumOccurrences;
|
|
169 |
}
|
|
183 |
public int getMaximumOccurrences() {
|
|
184 |
return this.maximumOccurrences;
|
|
185 |
}
|
|
170 | 186 |
|
171 |
public String getName() {
|
|
172 |
return this.name;
|
|
173 |
}
|
|
187 |
public int getMinimumOccurrences() {
|
|
188 |
return this.minimumOccurrences;
|
|
189 |
}
|
|
174 | 190 |
|
175 |
public Class getObjectClass() { |
|
191 |
public String getName() { |
|
192 |
return this.name; |
|
193 |
} |
|
194 |
|
|
195 |
public Class getObjectClass() { |
|
176 | 196 |
if (getDataType().getType() == DataTypes.OBJECT) { |
177 |
return objectClass;
|
|
178 |
}
|
|
197 |
return objectClass;
|
|
198 |
}
|
|
179 | 199 |
return getDataType().getDefaultClass(); |
180 |
}
|
|
200 |
}
|
|
181 | 201 |
|
182 |
public int getPrecision() {
|
|
183 |
return this.precision;
|
|
184 |
}
|
|
202 |
public int getPrecision() {
|
|
203 |
return this.precision;
|
|
204 |
}
|
|
185 | 205 |
|
186 |
public IProjection getSRS() {
|
|
187 |
return this.SRS;
|
|
188 |
}
|
|
206 |
public IProjection getSRS() {
|
|
207 |
return this.SRS;
|
|
208 |
}
|
|
189 | 209 |
|
190 |
public int getSize() {
|
|
191 |
return this.size;
|
|
192 |
}
|
|
210 |
public int getSize() {
|
|
211 |
return this.size;
|
|
212 |
}
|
|
193 | 213 |
|
194 |
public boolean isPrimaryKey() {
|
|
195 |
return this.primaryKey;
|
|
196 |
}
|
|
214 |
public boolean isPrimaryKey() {
|
|
215 |
return this.primaryKey;
|
|
216 |
}
|
|
197 | 217 |
|
198 |
public boolean isReadOnly() {
|
|
199 |
return this.readOnly;
|
|
200 |
}
|
|
218 |
public boolean isReadOnly() {
|
|
219 |
return this.readOnly;
|
|
220 |
}
|
|
201 | 221 |
|
202 |
public Object getAdditionalInfo(String infoName) {
|
|
203 |
if (this.additionalInfo == null) {
|
|
204 |
return null;
|
|
205 |
}
|
|
206 |
return this.additionalInfo.get(infoName);
|
|
207 |
}
|
|
222 |
public Object getAdditionalInfo(String infoName) {
|
|
223 |
if (this.additionalInfo == null) {
|
|
224 |
return null;
|
|
225 |
}
|
|
226 |
return this.additionalInfo.get(infoName);
|
|
227 |
}
|
|
208 | 228 |
|
209 |
public boolean isAutomatic() {
|
|
210 |
return this.isAutomatic;
|
|
211 |
}
|
|
229 |
public boolean isAutomatic() {
|
|
230 |
return this.isAutomatic;
|
|
231 |
}
|
|
212 | 232 |
|
233 |
private boolean compareObject(Object a, Object b) { |
|
234 |
if (a != b) { |
|
235 |
if (a == null) { |
|
236 |
return false; |
|
237 |
} |
|
238 |
return a.equals(b); |
|
239 |
} |
|
240 |
return true; |
|
213 | 241 |
|
214 |
private boolean compareObject(Object a, Object b) { |
|
215 |
if (a != b) { |
|
216 |
if (a == null) { |
|
217 |
return false; |
|
218 |
} |
|
219 |
return a.equals(b); |
|
220 |
} |
|
221 |
return true; |
|
242 |
} |
|
222 | 243 |
|
223 |
} |
|
244 |
public boolean equals(Object obj) { |
|
245 |
if (this == obj) { |
|
246 |
return true; |
|
247 |
} |
|
248 |
if (!(obj instanceof DefaultFeatureAttributeDescriptor)) { |
|
249 |
return false; |
|
250 |
} |
|
251 |
DefaultFeatureAttributeDescriptor other = |
|
252 |
(DefaultFeatureAttributeDescriptor) obj; |
|
224 | 253 |
|
225 |
public boolean equals(Object obj) { |
|
226 |
if (this == obj) { |
|
227 |
return true; |
|
228 |
} |
|
229 |
if (!(obj instanceof DefaultFeatureAttributeDescriptor)) { |
|
230 |
return false; |
|
231 |
} |
|
232 |
DefaultFeatureAttributeDescriptor other = (DefaultFeatureAttributeDescriptor) obj; |
|
254 |
if (this.allowNull != other.allowNull) { |
|
255 |
return false; |
|
256 |
} |
|
233 | 257 |
|
234 |
if (this.allowNull != other.allowNull) {
|
|
235 |
return false;
|
|
236 |
}
|
|
258 |
if (this.index != other.index) {
|
|
259 |
return false;
|
|
260 |
}
|
|
237 | 261 |
|
238 |
if (this.index != other.index) {
|
|
239 |
return false;
|
|
240 |
}
|
|
262 |
if (!compareObject(this.name, other.name)) {
|
|
263 |
return false;
|
|
264 |
}
|
|
241 | 265 |
|
242 |
if (!compareObject(this.name, other.name)) { |
|
243 |
return false; |
|
244 |
} |
|
245 |
|
|
246 | 266 |
if (this.getDataType() != other.getDataType()) { |
247 |
return false;
|
|
248 |
}
|
|
267 |
return false;
|
|
268 |
}
|
|
249 | 269 |
|
250 |
if (this.size != other.size) {
|
|
251 |
return false;
|
|
252 |
}
|
|
270 |
if (this.size != other.size) {
|
|
271 |
return false;
|
|
272 |
}
|
|
253 | 273 |
|
254 |
if (!compareObject(this.defaultValue, other.defaultValue)) {
|
|
255 |
return false;
|
|
256 |
}
|
|
274 |
if (!compareObject(this.defaultValue, other.defaultValue)) {
|
|
275 |
return false;
|
|
276 |
}
|
|
257 | 277 |
|
258 |
if (!compareObject(this.defaultValue, other.defaultValue)) {
|
|
259 |
return false;
|
|
260 |
}
|
|
278 |
if (!compareObject(this.defaultValue, other.defaultValue)) {
|
|
279 |
return false;
|
|
280 |
}
|
|
261 | 281 |
|
262 |
if (this.primaryKey != other.primaryKey) {
|
|
263 |
return false;
|
|
264 |
}
|
|
282 |
if (this.primaryKey != other.primaryKey) {
|
|
283 |
return false;
|
|
284 |
}
|
|
265 | 285 |
|
266 |
if (this.isAutomatic != other.isAutomatic) {
|
|
267 |
return false;
|
|
268 |
}
|
|
286 |
if (this.isAutomatic != other.isAutomatic) {
|
|
287 |
return false;
|
|
288 |
}
|
|
269 | 289 |
|
270 |
if (this.readOnly != other.readOnly) {
|
|
271 |
return false;
|
|
272 |
}
|
|
290 |
if (this.readOnly != other.readOnly) {
|
|
291 |
return false;
|
|
292 |
}
|
|
273 | 293 |
|
274 |
if (this.precision != other.precision) {
|
|
275 |
return false;
|
|
276 |
}
|
|
294 |
if (this.precision != other.precision) {
|
|
295 |
return false;
|
|
296 |
}
|
|
277 | 297 |
|
278 |
if (this.maximumOccurrences != other.maximumOccurrences) {
|
|
279 |
return false;
|
|
280 |
}
|
|
298 |
if (this.maximumOccurrences != other.maximumOccurrences) {
|
|
299 |
return false;
|
|
300 |
}
|
|
281 | 301 |
|
282 |
if (this.minimumOccurrences != other.minimumOccurrences) { |
|
283 |
return false; |
|
284 |
} |
|
285 |
if (this.geometryType != other.geometryType) { |
|
286 |
return false; |
|
287 |
} |
|
302 |
if (this.minimumOccurrences != other.minimumOccurrences) { |
|
303 |
return false; |
|
304 |
} |
|
288 | 305 |
|
289 |
if (this.geometrySubType != other.geometrySubType) {
|
|
290 |
return false;
|
|
291 |
}
|
|
306 |
if (this.geometryType != other.geometryType) {
|
|
307 |
return false;
|
|
308 |
}
|
|
292 | 309 |
|
293 |
if (!compareObject(this.evaluator, other.evaluator)) {
|
|
294 |
return false;
|
|
295 |
}
|
|
310 |
if (this.geometrySubType != other.geometrySubType) {
|
|
311 |
return false;
|
|
312 |
}
|
|
296 | 313 |
|
297 |
if (!compareObject(this.SRS, other.SRS)) {
|
|
298 |
return false;
|
|
299 |
}
|
|
314 |
if (!compareObject(this.evaluator, other.evaluator)) {
|
|
315 |
return false;
|
|
316 |
}
|
|
300 | 317 |
|
301 |
if (!compareObject(this.dateFormat, other.dateFormat)) {
|
|
302 |
return false;
|
|
303 |
}
|
|
318 |
if (!compareObject(this.SRS, other.SRS)) {
|
|
319 |
return false;
|
|
320 |
}
|
|
304 | 321 |
|
305 |
if (!compareObject(this.objectClass, other.objectClass)) {
|
|
306 |
return false;
|
|
307 |
}
|
|
322 |
if (!compareObject(this.dateFormat, other.dateFormat)) {
|
|
323 |
return false;
|
|
324 |
}
|
|
308 | 325 |
|
309 |
return true; |
|
310 |
} |
|
326 |
if (!compareObject(this.objectClass, other.objectClass)) { |
|
327 |
return false; |
|
328 |
} |
|
311 | 329 |
|
312 |
public void loadFromState(PersistentState state) |
|
313 |
throws PersistenceException { |
|
314 |
allowNull = state.getBoolean("allowNull"); |
|
315 |
dataType = ToolsLocator.getDataTypesManager().get(state.getInt("dataType")); |
|
316 |
// FIXME how persist dateFormat ??? |
|
317 |
// dateFormat; |
|
318 |
defaultValue = state.get("defaultValue"); |
|
330 |
return true; |
|
331 |
} |
|
319 | 332 |
|
320 |
index = state.getInt("index"); |
|
321 |
maximumOccurrences = state.getInt("maximumOccurrences"); |
|
322 |
minimumOccurrences = state.getInt("minimumOccurrences"); |
|
323 |
size = state.getInt("size"); |
|
324 |
name = state.getString("name"); |
|
325 |
try { |
|
326 |
objectClass = Class.forName(state.getString("objectClass")); |
|
327 |
} catch (ClassNotFoundException e) { |
|
328 |
throw new PersistenceException(e); |
|
329 |
} |
|
330 |
precision = state.getInt("precision"); |
|
331 |
evaluator = (Evaluator) state.get("evaluator"); |
|
332 |
primaryKey = state.getBoolean("primaryKey"); |
|
333 |
readOnly = state.getBoolean("readOnly"); |
|
334 |
String srsId = state.getString("srsId"); |
|
335 |
if (srsId != null){ |
|
336 |
SRS = CRSFactory.getCRS(srsId); |
|
337 |
} |
|
338 |
geometryType = state.getInt("geometryType"); |
|
339 |
geometrySubType = state.getInt("geometrySubType"); |
|
340 |
additionalInfo = (Map) state.get("aditionalInfo"); |
|
341 |
isAutomatic = state.getBoolean("isAutomatic"); |
|
342 |
} |
|
333 |
public void loadFromState(PersistentState state) |
|
334 |
throws PersistenceException { |
|
335 |
allowNull = state.getBoolean("allowNull"); |
|
336 |
dataType = |
|
337 |
ToolsLocator.getDataTypesManager().get(state.getInt("dataType")); |
|
338 |
// FIXME how persist dateFormat ??? |
|
339 |
// dateFormat; |
|
340 |
defaultValue = state.get("defaultValue"); |
|
343 | 341 |
|
344 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
345 |
state.set("allowNull", allowNull); |
|
346 |
state.set("dataType", dataType); |
|
347 |
// FIXME how persist dateFormat ??? |
|
348 |
// dateFormat; |
|
342 |
index = state.getInt("index"); |
|
343 |
maximumOccurrences = state.getInt("maximumOccurrences"); |
|
344 |
minimumOccurrences = state.getInt("minimumOccurrences"); |
|
345 |
size = state.getInt("size"); |
|
346 |
name = state.getString("name"); |
|
347 |
try { |
|
348 |
objectClass = Class.forName(state.getString("objectClass")); |
|
349 |
} catch (ClassNotFoundException e) { |
|
350 |
throw new PersistenceException(e); |
|
351 |
} |
|
352 |
precision = state.getInt("precision"); |
|
353 |
evaluator = (Evaluator) state.get("evaluator"); |
|
354 |
primaryKey = state.getBoolean("primaryKey"); |
|
355 |
readOnly = state.getBoolean("readOnly"); |
|
356 |
String srsId = state.getString("srsId"); |
|
357 |
if (srsId != null) { |
|
358 |
SRS = CRSFactory.getCRS(srsId); |
|
359 |
} |
|
360 |
geometryType = state.getInt("geometryType"); |
|
361 |
geometrySubType = state.getInt("geometrySubType"); |
|
362 |
additionalInfo = (Map) state.get("aditionalInfo"); |
|
363 |
isAutomatic = state.getBoolean("isAutomatic"); |
|
364 |
} |
|
349 | 365 |
|
350 |
defaultValue = state.get("defaultValue"); |
|
366 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
367 |
state.set("allowNull", allowNull); |
|
368 |
state.set("dataType", dataType); |
|
369 |
// FIXME how persist dateFormat ??? |
|
370 |
// dateFormat; |
|
351 | 371 |
|
352 |
index = state.getInt("index"); |
|
353 |
maximumOccurrences = state.getInt("maximumOccurrences"); |
|
354 |
minimumOccurrences = state.getInt("minimumOccurrences"); |
|
355 |
size = state.getInt("size"); |
|
356 |
name = state.getString("name"); |
|
357 |
try { |
|
358 |
objectClass = Class.forName(state.getString("objectClass")); |
|
359 |
} catch (ClassNotFoundException e) { |
|
360 |
throw new PersistenceException(e); |
|
361 |
} |
|
362 |
precision = state.getInt("precision"); |
|
363 |
evaluator = (Evaluator) state.get("evaluator"); |
|
364 |
primaryKey = state.getBoolean("primaryKey"); |
|
365 |
readOnly = state.getBoolean("readOnly"); |
|
366 |
String srsId = state.getString("srsId"); |
|
367 |
if (srsId != null) { |
|
368 |
SRS = CRSFactory.getCRS(srsId); |
|
369 |
} |
|
370 |
geometryType = state.getInt("geometryType"); |
|
371 |
geometrySubType = state.getInt("geometrySubType"); |
|
372 |
additionalInfo = (Map) state.get("aditionalInfo"); |
|
373 |
isAutomatic = state.getBoolean("isAutomatic"); |
|
374 |
} |
|
372 |
defaultValue = state.get("defaultValue"); |
|
375 | 373 |
|
376 |
/** |
|
377 |
* Start of DynField interface Implementation |
|
378 |
* READONLY |
|
379 |
*/ |
|
374 |
index = state.getInt("index"); |
|
375 |
maximumOccurrences = state.getInt("maximumOccurrences"); |
|
376 |
minimumOccurrences = state.getInt("minimumOccurrences"); |
|
377 |
size = state.getInt("size"); |
|
378 |
name = state.getString("name"); |
|
379 |
try { |
|
380 |
objectClass = Class.forName(state.getString("objectClass")); |
|
381 |
} catch (ClassNotFoundException e) { |
|
382 |
throw new PersistenceException(e); |
|
383 |
} |
|
384 |
precision = state.getInt("precision"); |
|
385 |
evaluator = (Evaluator) state.get("evaluator"); |
|
386 |
primaryKey = state.getBoolean("primaryKey"); |
|
387 |
readOnly = state.getBoolean("readOnly"); |
|
388 |
String srsId = state.getString("srsId"); |
|
389 |
if (srsId != null) { |
|
390 |
SRS = CRSFactory.getCRS(srsId); |
|
391 |
} |
|
392 |
geometryType = state.getInt("geometryType"); |
|
393 |
geometrySubType = state.getInt("geometrySubType"); |
|
394 |
additionalInfo = (Map) state.get("aditionalInfo"); |
|
395 |
isAutomatic = state.getBoolean("isAutomatic"); |
|
396 |
} |
|
380 | 397 |
|
398 |
/** |
|
399 |
* Start of DynField interface Implementation |
|
400 |
* READONLY |
|
401 |
*/ |
|
381 | 402 |
|
382 |
public DynObjectValueItem[] getAvailableValues() {
|
|
383 |
return null;
|
|
384 |
}
|
|
403 |
public DynObjectValueItem[] getAvailableValues() {
|
|
404 |
return null;
|
|
405 |
}
|
|
385 | 406 |
|
386 |
public String getDescription() {
|
|
407 |
public String getDescription() {
|
|
387 | 408 |
return getName(); |
388 |
}
|
|
409 |
}
|
|
389 | 410 |
|
390 |
public Object getMaxValue() {
|
|
391 |
return null;
|
|
392 |
}
|
|
411 |
public Object getMaxValue() {
|
|
412 |
return null;
|
|
413 |
}
|
|
393 | 414 |
|
394 |
public Object getMinValue() {
|
|
395 |
return null;
|
|
396 |
}
|
|
415 |
public Object getMinValue() {
|
|
416 |
return null;
|
|
417 |
}
|
|
397 | 418 |
|
398 |
public int getTheTypeOfAvailableValues() {
|
|
399 |
return 0;
|
|
400 |
}
|
|
419 |
public int getTheTypeOfAvailableValues() {
|
|
420 |
return 0;
|
|
421 |
}
|
|
401 | 422 |
|
402 |
public int getType() {
|
|
423 |
public int getType() {
|
|
403 | 424 |
if (featureAttributeGetter != null){ |
404 | 425 |
return featureAttributeGetter.getDataType().getType(); |
405 | 426 |
} |
406 |
return getDataType().getType();
|
|
407 |
}
|
|
427 |
return getDataType().getType();
|
|
428 |
}
|
|
408 | 429 |
|
409 |
public boolean isMandatory() {
|
|
410 |
return !allowNull() || isPrimaryKey();
|
|
411 |
}
|
|
430 |
public boolean isMandatory() {
|
|
431 |
return !allowNull() || isPrimaryKey();
|
|
432 |
}
|
|
412 | 433 |
|
413 |
public boolean isPersistent() {
|
|
414 |
return false;
|
|
415 |
}
|
|
434 |
public boolean isPersistent() {
|
|
435 |
return false;
|
|
436 |
}
|
|
416 | 437 |
|
417 |
public DynField setAvailableValues(DynObjectValueItem[] values) {
|
|
418 |
throw new UnsupportedOperationException();
|
|
419 |
}
|
|
438 |
public DynField setAvailableValues(DynObjectValueItem[] values) {
|
|
439 |
throw new UnsupportedOperationException();
|
|
440 |
}
|
|
420 | 441 |
|
421 |
public DynField setDescription(String description) {
|
|
422 |
throw new UnsupportedOperationException();
|
|
423 |
}
|
|
442 |
public DynField setDescription(String description) {
|
|
443 |
throw new UnsupportedOperationException();
|
|
444 |
}
|
|
424 | 445 |
|
425 |
public DynField setMandatory(boolean mandatory) {
|
|
426 |
throw new UnsupportedOperationException();
|
|
427 |
}
|
|
446 |
public DynField setMandatory(boolean mandatory) {
|
|
447 |
throw new UnsupportedOperationException();
|
|
448 |
}
|
|
428 | 449 |
|
429 |
public DynField setMaxValue(Object maxValue) {
|
|
430 |
throw new UnsupportedOperationException();
|
|
431 |
}
|
|
450 |
public DynField setMaxValue(Object maxValue) {
|
|
451 |
throw new UnsupportedOperationException();
|
|
452 |
}
|
|
432 | 453 |
|
433 |
public DynField setMinValue(Object minValue) {
|
|
434 |
throw new UnsupportedOperationException();
|
|
435 |
}
|
|
454 |
public DynField setMinValue(Object minValue) {
|
|
455 |
throw new UnsupportedOperationException();
|
|
456 |
}
|
|
436 | 457 |
|
437 |
public DynField setPersistent(boolean persistent) {
|
|
438 |
throw new UnsupportedOperationException();
|
|
439 |
}
|
|
458 |
public DynField setPersistent(boolean persistent) {
|
|
459 |
throw new UnsupportedOperationException();
|
|
460 |
}
|
|
440 | 461 |
|
441 |
public DynField setTheTypeOfAvailableValues(int type) {
|
|
442 |
throw new UnsupportedOperationException();
|
|
443 |
}
|
|
462 |
public DynField setTheTypeOfAvailableValues(int type) {
|
|
463 |
throw new UnsupportedOperationException();
|
|
464 |
}
|
|
444 | 465 |
|
445 |
public DynField setType(int type) {
|
|
446 |
throw new UnsupportedOperationException();
|
|
447 |
}
|
|
466 |
public DynField setType(int type) {
|
|
467 |
throw new UnsupportedOperationException();
|
|
468 |
}
|
|
448 | 469 |
|
449 |
public DynField setDefaultDynValue(Object defaultValue) {
|
|
450 |
throw new UnsupportedOperationException();
|
|
451 |
}
|
|
470 |
public DynField setDefaultDynValue(Object defaultValue) {
|
|
471 |
throw new UnsupportedOperationException();
|
|
472 |
}
|
|
452 | 473 |
|
453 |
public DynField addElementsType() throws DynFieldIsNotAContainerException {
|
|
454 |
throw new UnsupportedOperationException();
|
|
455 |
}
|
|
474 |
public DynField addElementsType() throws DynFieldIsNotAContainerException {
|
|
475 |
throw new UnsupportedOperationException();
|
|
476 |
}
|
|
456 | 477 |
|
457 |
public Class getClassOfValue() {
|
|
458 |
return null;
|
|
459 |
}
|
|
478 |
public Class getClassOfValue() {
|
|
479 |
return null;
|
|
480 |
}
|
|
460 | 481 |
|
461 |
public DynField getElementsType() { |
|
462 |
return null; |
|
463 |
} |
|
464 |
|
|
465 |
public DynField setClassOfValue(Class theClass) |
|
466 |
throws DynFieldIsNotAContainerException { |
|
467 |
throw new UnsupportedOperationException(); |
|
468 |
} |
|
482 |
public DynField getElementsType() { |
|
483 |
return null; |
|
484 |
} |
|
469 | 485 |
|
470 |
public DynField setElementsType(DynStruct type) |
|
471 |
throws DynFieldIsNotAContainerException { |
|
472 |
throw new UnsupportedOperationException(); |
|
473 |
} |
|
474 |
|
|
475 |
public DynField setElementsType(int type) |
|
476 |
throws DynFieldIsNotAContainerException { |
|
477 |
throw new UnsupportedOperationException(); |
|
478 |
} |
|
479 |
|
|
480 |
public DynField setSubtype(String subtype) { |
|
481 |
throw new UnsupportedOperationException(); |
|
482 |
} |
|
486 |
public DynField setClassOfValue(Class theClass) |
|
487 |
throws DynFieldIsNotAContainerException { |
|
488 |
throw new UnsupportedOperationException(); |
|
489 |
} |
|
483 | 490 |
|
484 |
public void validate(Object value) throws DynFieldValidateException { |
|
485 |
// Do nothing |
|
486 |
} |
|
491 |
public DynField setElementsType(DynStruct type) |
|
492 |
throws DynFieldIsNotAContainerException { |
|
493 |
throw new UnsupportedOperationException(); |
|
494 |
} |
|
487 | 495 |
|
488 |
public String getSubtype() { |
|
496 |
public DynField setElementsType(int type) |
|
497 |
throws DynFieldIsNotAContainerException { |
|
498 |
throw new UnsupportedOperationException(); |
|
499 |
} |
|
500 |
|
|
501 |
public DynField setSubtype(String subtype) { |
|
502 |
throw new UnsupportedOperationException(); |
|
503 |
} |
|
504 |
|
|
505 |
public void validate(Object value) throws DynFieldValidateException { |
|
506 |
// Do nothing |
|
507 |
} |
|
508 |
|
|
509 |
public String getSubtype() { |
|
489 | 510 |
if (featureAttributeGetter != null){ |
490 | 511 |
return featureAttributeGetter.getDataType().getSubtype(); |
491 | 512 |
} |
492 |
return this.dataType.getSubtype();
|
|
493 |
}
|
|
513 |
return this.dataType.getSubtype();
|
|
514 |
}
|
|
494 | 515 |
|
495 |
public Object coerce(Object value) {
|
|
496 |
throw new UnsupportedOperationException();
|
|
497 |
}
|
|
516 |
public Object coerce(Object value) {
|
|
517 |
throw new UnsupportedOperationException();
|
|
518 |
}
|
|
498 | 519 |
|
499 |
public DynField setAvailableValues(List values) {
|
|
500 |
throw new UnsupportedOperationException();
|
|
501 |
}
|
|
520 |
public DynField setAvailableValues(List values) {
|
|
521 |
throw new UnsupportedOperationException();
|
|
522 |
}
|
|
502 | 523 |
|
503 |
public String getGroup() {
|
|
504 |
return null;
|
|
505 |
}
|
|
524 |
public String getGroup() {
|
|
525 |
return null;
|
|
526 |
}
|
|
506 | 527 |
|
507 |
public int getOder() {
|
|
508 |
return 0;
|
|
509 |
}
|
|
528 |
public int getOder() {
|
|
529 |
return 0;
|
|
530 |
}
|
|
510 | 531 |
|
511 |
public DynField setGroup(String groupName) {
|
|
512 |
throw new UnsupportedOperationException();
|
|
513 |
}
|
|
532 |
public DynField setGroup(String groupName) {
|
|
533 |
throw new UnsupportedOperationException();
|
|
534 |
}
|
|
514 | 535 |
|
515 |
public DynField setOrder(int order) {
|
|
516 |
throw new UnsupportedOperationException();
|
|
517 |
}
|
|
536 |
public DynField setOrder(int order) {
|
|
537 |
throw new UnsupportedOperationException();
|
|
538 |
}
|
|
518 | 539 |
|
519 |
public DynField setHidden(boolean hidden) {
|
|
520 |
throw new UnsupportedOperationException();
|
|
521 |
}
|
|
540 |
public DynField setHidden(boolean hidden) {
|
|
541 |
throw new UnsupportedOperationException();
|
|
542 |
}
|
|
522 | 543 |
|
523 |
public boolean isHidden() {
|
|
524 |
return false;
|
|
525 |
}
|
|
544 |
public boolean isHidden() {
|
|
545 |
return false;
|
|
546 |
}
|
|
526 | 547 |
|
527 |
public DynField setReadOnly(boolean arg0) {
|
|
528 |
throw new UnsupportedOperationException();
|
|
529 |
}
|
|
548 |
public DynField setReadOnly(boolean arg0) {
|
|
549 |
throw new UnsupportedOperationException();
|
|
550 |
}
|
|
530 | 551 |
|
531 |
public boolean isContainer() {
|
|
532 |
return false;
|
|
533 |
}
|
|
552 |
public boolean isContainer() {
|
|
553 |
return false;
|
|
554 |
}
|
|
534 | 555 |
|
535 |
public Class getClassOfItems() {
|
|
536 |
return null;
|
|
537 |
}
|
|
556 |
public Class getClassOfItems() {
|
|
557 |
return null;
|
|
558 |
}
|
|
538 | 559 |
|
539 |
public DynField setDefaultFieldValue(Object defaultValue) {
|
|
540 |
throw new UnsupportedOperationException();
|
|
541 |
}
|
|
560 |
public DynField setDefaultFieldValue(Object defaultValue) {
|
|
561 |
throw new UnsupportedOperationException();
|
|
562 |
}
|
|
542 | 563 |
|
543 |
public DynField setClassOfItems(Class theClass) {
|
|
544 |
throw new UnsupportedOperationException();
|
|
545 |
}
|
|
564 |
public DynField setClassOfItems(Class theClass) {
|
|
565 |
throw new UnsupportedOperationException();
|
|
566 |
}
|
|
546 | 567 |
|
547 |
public DynField setType(DataType type) {
|
|
548 |
throw new UnsupportedOperationException();
|
|
549 |
}
|
|
568 |
public DynField setType(DataType type) {
|
|
569 |
throw new UnsupportedOperationException();
|
|
570 |
}
|
|
550 | 571 |
|
551 | 572 |
public boolean isTime() { |
552 | 573 |
return isTime; |
Also available in: Unified diff