You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Murphy, Eric" <er...@pfc.cfs.nrcan.gc.ca> on 2004/03/11 19:12:04 UTC
XmlObject set
XmlBeans -
I have created a Document with XmlOptions.setValidateOnSet() as an argument.
When a setter is called with an invalid value an Exception is thrown which
is what I expect. I was surprised to see when I call the associated getter
after calling the setter I also get an Exception.
I would expect just a null value to be returned. When the setter was called
and failed, I would think nothing would be set and we would return to the
condition on line 7.
1 XmlOptions options = new XmlOptions();
2 options.setValidateOnSet();
3 MetadataDocument doc = MetadataDocument.Factory.newInstance(options);
4 MetadataType metaElement = doc.addNewMetadata();
5
6 // This passes as I would expect this to return null
7 assertTrue(metaElement.getType() == null);
8
9 // Set illegal value, this does and should throw an Exception
10 try {
11 metaElement.setType(MetadataTypeEnum.Enum.forString("abc"));
12 } catch (Exception e) { /* do nothing */ }
13
14 metaElement.getType(); // This throws an Exception, I would expect
15 // it to return null.
Eric Murphy
Software Developer (NFIS)
erimurph@pfc.forestry.ca
tel/t�l: 250-363-6038
fax / t�l�copieur 250-363-6004
Natural Resources Canada
Pacific Forestry Centre
506 West Burnside Road
Victoria BC V8Z 1M5
Ressources naturelles Canada
Centre de foresterie du Pacifique
506 rue Burnside ouest
Victoria, Colombie-Britanique V8Z 1M5