I tried to implement "supporting isSet" and would like to share some issues.

First, I added 

  /** <p>Creates the isSet returning whether the property value is set or
not.</p>
   */
  public JavaMethod getXMLIsSetMethod(JavaSource pSource) throws
SAXException;

to PropertySG.

Next, as you said, all of the JAXBPropertySG's constructors now set a new
field, "generateIsSetMethod" flag from both global bindings and
JAXBProperty. hasIsSetMethod returns this flag value, which
getXMLIsSetMethodName also uses to jugde whether it returns a valid name or
null. forAllNonNullValues method is changed so that it also makes use of
isSet method.

JAXBTypeSG's getXMLSetMethod and getXMLIsSetMethod are concrete parts. The
logics depend on whether the mapped Java type is primitive or not.

Address.xsd, AddressType.java, AddressTypeImpl.java AddressTypeSerializer in
the attached zip file prove how the above implementations work.

According to JAXB 1.0 spec final draft, isSet feature described in section
4.5.4 demands one more additioinal method: unsetProperty() is used to
discard a set value of a property. The real problem is, this unsetProperty
method requires a subsequent call to getProperty to obtain the default value
when the schema in question specifies that. Moreover, section 4.5 states how
a property's value should be set with the schema default value prior to
setting value by unmarshalling or invoking its mutation methods. As far as
I've learned JaxMe 2, there's no way to access "default" attribute of
"<xs:element>" and "<xs:attribute>". One interesting point is actually Sun's
JAXB RI 1.0.1 also doesn't support schema default values.

In conclusion, unsetProperty is necessary for a list property and a simple
property with a non-reference base type along with isSetProperty and the
exact implementation necessitates JaxMe 2 to have an access to schema
default values.

Looking forward to your opinion,

Ias

   

Attachment: todo2.zip
Description: Zip compressed data

Reply via email to