// Build the entire union with all branches, etc. Then read info from the XML Event Reader
StartElement branchElement = reader.peek().asStartElement();
String branchName = branchElement.getName().getLocalPart();
List<Unionbranch> branches = unionType.getUnionbranch();
for (Iterator<Unionbranch> iter = branches.iterator(); iter.hasNext();) {
Unionbranch branch = iter.next();
CorbaObjectHandler branchObj = null;
if (branch.getName().equals(branchName)) {
branchObj = readObjectFromStax(reader, branch.getIdltype(), true);
// We also need to set the discriminator since this is the branch with the actual
// union value
CorbaObjectHandler discObj =
CorbaHandlerUtils.createTypeHandler(orb, new QName("discriminator"),
unionType.getDiscriminator(), typeMaps);
obj.setDiscriminator(discObj);
// Determine the value of the discriminator.
List<CaseType> branchCases = branch.getCase();
String discValue = null;
if (branchCases.size() != 0) {
// This represents a union case. Set the discriminator based on the first
// label value associated with the branch (since we don't have this information)
// from the Stax representation of the Celtix object).
CaseType caseLabel = branchCases.get(0);
discValue = caseLabel.getLabel();
} else {
// This represents the default case. Since Celtix does not provide a
// discriminator value, we'll create one.
discValue = obj.createDefaultDiscriminatorLabel();
}
obj.setDiscriminatorValueFromData(discValue);
obj.setValue(branchName, branchObj);
} else {
// Create an object holder with no value
branchObj = CorbaHandlerUtils.createTypeHandler(orb, new QName(branch.getName()),
branch.getIdltype(), typeMaps);
}
obj.addCase(branchObj);
}
reader.nextEvent().asEndElement();
} catch (java.lang.Exception ex) {