Jochen Wiedmann wrote:
As I said, the TypedValue isn't used in the classes generating static content, like enumerations, or default values. A typical use case is for the ArrayPropertySG. Suggest the following element definition:
<xs:element name="foo" type="xs:int" maxOccurs="unbounded"/>
Suggest the code, which converts the string value "5" into an int and adds the value to an internal list. This code could look like the following:
String sValue = "5"; TypedValue value = simpleTypeSG.getCastFromString(jm, sValue, pData); if (value.getType().isPrimitive()) { value = ...; // Code that converts the primitive into an object } jm.addLine(field, ".add(", value, ");");
I am, of course, simplifying a little bit. For example, because the Unmarshaller doesn't access the internal list. However, in general that's how things look.
Ok. I understand.
Consider the following attribute definition from an element's definition:
As for JAXME-47, I would think that it can be solved by implementing UnionTypeSG.getCastFromString(pController, pValue) like this:
for (int i = 0; i < listOfInternalTypes.length; i++) { try { return listOfInternalTypes[i].getCastFromString((pValue); } catch (Throwable ignore) {} } throw new IllegalArgumentException("Unable to convert value: " + pValue);
...
<xs:attribute name="a" default="1" type="xs:decimal" />
<xs:attribute name="b" default="01" type="xs:hexBinary" />
<xs:attribute name="d" default="1" type="xs:integer" />
<xs:attribute name="e" default="-1" type="xs:nonPositiveInteger" />
<xs:attribute name="f" default="1" type="xs:positiveInteger" />
<xs:attribute name="g" default="1" type="xs:unsignedLong" />
<xs:attribute name="h" default="1" type="xs:long" />
...
The generated sources look like this: ... private java.math.BigDecimal _a = 1; private byte[] _b = 01; private java.math.BigInteger _d = 1; private java.math.BigInteger _e = -1; private java.math.BigInteger _f = 1; private java.math.BigInteger _g = 1; private long _h = 1; ...
So the point that I am trying to address is that all these default values are not correct. The problem is the one we saw yesterday: getXMLField doesn't use getCastFromString to generate the default values. But even if it did use getCastFromString, the only one that would be correctly handled (as of now) would be LongSG.
Anyway I think I know now enough about the issue to tackle it: All SimpleTypeSG should provide the correct getCastFromString and getXMLField should use this. right? I'll include these default values in the defaultValues test as well as some enumerations default values. The thing is that I beleive that enumerations won't have the correct default values as I stated earlier...
Nacho
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
