Revision 43610 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/DefaultEditableFeatureType.java
DefaultEditableFeatureType.java | ||
---|---|---|
139 | 139 |
return source; |
140 | 140 |
} |
141 | 141 |
|
142 |
private long getCRC() { |
|
143 |
StringBuffer buffer = new StringBuffer(); |
|
144 |
for (int i = 0; i < this.size(); i++) { |
|
145 |
FeatureAttributeDescriptor x = this.getAttributeDescriptor(i); |
|
146 |
buffer.append(x.getName()); |
|
147 |
buffer.append(x.getDataTypeName()); |
|
148 |
buffer.append(x.getSize()); |
|
149 |
} |
|
150 |
CRC32 crc = new CRC32(); |
|
151 |
byte[] data = buffer.toString().getBytes(); |
|
152 |
crc.update(data); |
|
153 |
return crc.getValue(); |
|
154 |
} |
|
155 |
|
|
156 | 142 |
public FeatureType getNotEditableCopy() { |
157 | 143 |
this.fixAll(); |
158 | 144 |
DefaultFeatureType copy = new DefaultFeatureType(this, false); |
... | ... | |
259 | 245 |
return attr; |
260 | 246 |
} |
261 | 247 |
|
248 |
@Override |
|
262 | 249 |
protected void fixAll() { |
263 |
int i = 0; |
|
264 |
Iterator iter = super.iterator(); |
|
265 |
DefaultFeatureAttributeDescriptor attr; |
|
266 |
|
|
267 |
while (iter.hasNext()) { |
|
268 |
attr = (DefaultFeatureAttributeDescriptor) iter |
|
269 |
.next(); |
|
270 |
attr.setIndex(i++); |
|
271 |
if (attr instanceof DefaultEditableFeatureAttributeDescriptor) { |
|
272 |
((DefaultEditableFeatureAttributeDescriptor) attr).fixAll(); |
|
273 |
} |
|
274 |
if (attr.getEvaluator() != null) { |
|
275 |
this.hasEvaluators = true; |
|
276 |
} |
|
277 |
if (attr.getFeatureAttributeEmulator() != null) { |
|
278 |
this.hasEmulators = true; |
|
279 |
} |
|
280 |
if (this.defaultGeometryAttributeName == null && attr.getType() == DataTypes.GEOMETRY) { |
|
281 |
this.defaultGeometryAttributeName = attr.getName(); |
|
282 |
} |
|
283 |
} |
|
284 |
if (this.defaultGeometryAttributeName != null) { |
|
285 |
this.defaultGeometryAttributeIndex = this.getIndex(this.defaultGeometryAttributeName); |
|
286 |
} |
|
287 |
this.internalID = Long.toHexString(this.getCRC()); |
|
250 |
super.fixAll(); |
|
288 | 251 |
} |
289 | 252 |
|
290 | 253 |
public void checkIntegrity() throws DataListException { |
... | ... | |
385 | 348 |
this.allowAtomaticValues = value; |
386 | 349 |
} |
387 | 350 |
|
388 |
public void setDefaultTimeAttributeName(String name) { |
|
389 |
if (name == null || name.length() == 0) { |
|
390 |
this.defaultTimeAttributeIndex = -1; |
|
391 |
return; |
|
392 |
} |
|
393 |
DefaultFeatureAttributeDescriptor attr = (DefaultFeatureAttributeDescriptor) this |
|
394 |
.get(name); |
|
395 |
if (attr == null) { |
|
396 |
throw new IllegalArgumentException("Attribute '" + name |
|
397 |
+ "' not found."); |
|
398 |
} |
|
399 |
|
|
400 |
this.defaultTimeAttributeIndex = attr.getIndex(); |
|
401 |
} |
|
402 | 351 |
} |
Also available in: Unified diff