Revision 112 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/impl/DynClassImportHelper.java
DynClassImportHelper.java | ||
---|---|---|
9 | 9 |
import java.util.Map; |
10 | 10 |
|
11 | 11 |
import org.gvsig.tools.ToolsLocator; |
12 |
import org.gvsig.tools.dataTypes.DataTypes;
|
|
12 |
import org.gvsig.tools.dataTypes.CoercionException;
|
|
13 | 13 |
import org.gvsig.tools.dynobject.DynClass; |
14 | 14 |
import org.gvsig.tools.dynobject.DynField; |
15 | 15 |
import org.gvsig.tools.dynobject.DynObjectManager; |
... | ... | |
303 | 303 |
field.setDescription(value); |
304 | 304 |
|
305 | 305 |
} else if( name.equalsIgnoreCase(FIELD_TYPE_TAG)) { |
306 |
field.setType( DataTypes.getType(value) );
|
|
306 |
field.setType( ToolsLocator.getDataTypesManager().getType(value) );
|
|
307 | 307 |
|
308 | 308 |
} else if( name.equalsIgnoreCase(FIELD_SUBTYPE_TAG)) { |
309 | 309 |
field.setSubtype(value); |
... | ... | |
349 | 349 |
} |
350 | 350 |
} |
351 | 351 |
|
352 |
// |
|
353 |
// Coerce the the min/max/default/available values to the type of the field |
|
354 |
// |
|
355 |
for( int i=0; i<availableValues.size(); i++ ) { |
|
356 |
PairValueLabel pair = (PairValueLabel) availableValues.get(i); |
|
357 |
if( pair.label == null ) { |
|
358 |
if( pair.value == null ) { |
|
359 |
pair.label = "null"; |
|
360 |
} else { |
|
361 |
pair.label = pair.value.toString(); |
|
352 |
try { |
|
353 |
// |
|
354 |
// Coerce the the min/max/default/available values to the type of |
|
355 |
// the field |
|
356 |
// |
|
357 |
for (int i = 0; i < availableValues.size(); i++) { |
|
358 |
PairValueLabel pair = (PairValueLabel) availableValues.get(i); |
|
359 |
if (pair.label == null) { |
|
360 |
if (pair.value == null) { |
|
361 |
pair.label = "null"; |
|
362 |
} else { |
|
363 |
pair.label = pair.value.toString(); |
|
364 |
} |
|
362 | 365 |
} |
366 |
availableValues.set(i, new DynObjectValueItem(field.coerce(pair.value), pair.label)); |
|
363 | 367 |
} |
364 |
availableValues.set(i, new DynObjectValueItem( field.coerce(pair.value), pair.label)); |
|
368 |
field.setAvailableValues(availableValues); |
|
369 |
field.setMaxValue(field.coerce(values.get(FIELD_MAXVALUE_TAG))); |
|
370 |
field.setMinValue(field.coerce(values.get(FIELD_MINVALUE_TAG))); |
|
371 |
field.setDefaultDynValue(field.coerce(values.get(FIELD_DEFAULTVALUE_TAG))); |
|
372 |
} catch (CoercionException e) { |
|
373 |
throw new ParseCoerceException(e, parser); |
|
365 | 374 |
} |
366 |
field.setAvailableValues(availableValues); |
|
367 |
field.setMaxValue( field.coerce(values.get(FIELD_MAXVALUE_TAG))); |
|
368 |
field.setMinValue( field.coerce(values.get(FIELD_MINVALUE_TAG)) ); |
|
369 |
field.setDefaultDynValue( field.coerce(values.get(FIELD_DEFAULTVALUE_TAG)) ); |
|
370 | 375 |
} |
371 | 376 |
|
372 | 377 |
private class PairValueLabel { |
... | ... | |
465 | 470 |
public IncompatibleAttributeValueException(XmlPullParser parser, String tagname) { } |
466 | 471 |
} |
467 | 472 |
|
473 |
public static class ParseCoerceException extends RuntimeException { |
|
468 | 474 |
|
475 |
/** |
|
476 |
* |
|
477 |
*/ |
|
478 |
private static final long serialVersionUID = 1447718822981628834L; |
|
479 |
|
|
480 |
public ParseCoerceException(Throwable cause, XmlPullParser parser) { } |
|
481 |
} |
|
482 |
|
|
483 |
|
|
469 | 484 |
} |
Also available in: Unified diff