I'd like to unmarshall a class that has a couple of arrays as fields, and
I'm 99% certain a custom class descriptor is required.
A snippet from the class:
public final class PointSectionUnion
implements org.omg.CORBA.portable.IDLEntity
{
private com.gcmtravel.LinearLocationType discriminator;
private com.gcmtravel.SectionLocationProfile[] section;
public PointSectionUnion () { }
public com.gcmtravel.SectionLocationProfile[] section ()
{
if( discriminator !=
com.gcmtravel.LinearLocationType.SECTION_LINEAR)
throw new org.omg.CORBA.BAD_OPERATION();
return section;
}
public void section (com.gcmtravel.SectionLocationProfile[] _x)
{
discriminator =
com.gcmtravel.LinearLocationType.SECTION_LINEAR;
section = _x;
}
.......
the fact that section() will throw if discriminator isn't SECTION_LINEAR
leads me to believe a custom class descriptor is required.
But that's beside the point. Here's the class descriptor I've come up with
so far:
public class PointSectionUnionDescriptor
extends XMLClassDescriptorImpl
{
public PointSectionUnionDescriptor() {
super(com.gcmtravel.PointSectionUnion.class,
"pointLocationProfile");
XMLFieldDescriptorImpl contentDescriptor =
new
XMLFieldDescriptorImpl(com.gcmtravel.PointLocationProfile.class,
"point", "point", NodeType.Element);
contentDescriptor.setHandler(new PointFieldHandler());
addFieldDescriptor(contentDescriptor);
contentDescriptor =
new
XMLFieldDescriptorImpl(com.gcmtravel.SectionLocationProfile.class,
"section", "section",
NodeType.Element);
contentDescriptor.setHandler(new SectionFieldHandler());
addFieldDescriptor(contentDescriptor);
}
.......
This works fine for marshalling-if the PointSectionUnion happens to have
multiple sections, multiple <section> elements are marshalled.
However, when unmarshalling, an error is thrown after the second point is
unmarshalled-
ValidationException: element "point" occurs more than once.
(XMLFieldDesciptor:
point AS point){file: [not available]; line: 115; column: 33}
ValidationException: element "point" occurs more than once.
(XMLFieldDesciptor:
point AS point)
at org.exolab.castor.xml.UnmarshalHandler.endElement(Unknown Source)
I've tried a few different things, such as setContainer(true) and using
"com.gcmtravel.SectionLocationProfile[].class", but those just cause
problems somewhere else.
Can someone point out the right way to specify an array collection in a
custom class descriptor?
Thanks,
Joe
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev