Hi Jochen, after playing around with default values for a while, I have a couple of suggestions.

The JAXB spec. says that data type conversions should be made through the static methods of DatatypeConverter. The method getCastFromString in AtomicTypeSGImpl is actually creating an instance of DataTypeConverter for each generated class (unless it receives it as a parameter). If we decide to go the "static way" then I would suggest not overloading this method and stick with the "simpler" one. For all cases I've inspected this would do:

public TypedValue getCastFromString(SimpleTypeSG pController, String pValue) throws SAXException {
return new TypedValueImpl(new Object[]{"javax.xml.bind.DatatypeConverter", ".parse" + getDatatypeName() + "(\"", pValue, "\")"}, getDatatypeType());
}


In JAXBTypeSG there would be a minor change, that is when the default value is not a string:

jf.addLine(pController.getSimpleTypeSG().getCastFromString(pDefaultValue.toString()));

Now it is the point where you might not like this solution. It is that all TypeSG would have to use AtomicTypeSG's getCastFromString. That is IntegerSG, ShortSG, ...

Tell me what you think. I might not be seeing other places where this is used.

I'll send a patch with the test-case if you like this approach.

Nacho

PD: We'd also need: (taken from DatatypeConverter)
The JAXB provider is responsible to initialize the DatatypeConverter class by invoking setDatatypeConverter(DatatypeConverterInterface) as soon as possible.
Is this being done?


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to