java.math.BigDecimal fixedValue = stream.read_fixed().movePointLeft((int)scale);
fixedHandler.setValue(fixedValue);
}
public void readUnion(CorbaObjectHandler obj) throws CorbaBindingException {
CorbaUnionHandler unionHandler = (CorbaUnionHandler)obj;
CorbaObjectHandler discriminator = unionHandler.getDiscriminator();
this.read(discriminator);
String discLabel = null;
if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
discLabel = ((CorbaEnumHandler)discriminator).getValue();
} else {
discLabel = ((CorbaPrimitiveHandler)discriminator).getValueData();
}
// Now find the label in the union to get the right case
Union unionType = (Union)unionHandler.getType();
List<Unionbranch> branches = unionType.getUnionbranch();
Unionbranch defaultBranch = null;
boolean caseFound = false;
for (Iterator<Unionbranch> iter = branches.iterator(); iter.hasNext();) {
Unionbranch branch = iter.next();
if (branch.isSetDefault() && branch.isDefault()) {
defaultBranch = branch;
}
List<CaseType> cases = branch.getCase();
for (Iterator<CaseType> caseIter = cases.iterator(); caseIter.hasNext();) {
CaseType c = caseIter.next();
if (c.getLabel().equals(discLabel)) {
CorbaObjectHandler branchObj = unionHandler.getBranchByName(branch.getName());
this.read(branchObj);
unionHandler.setValue(branch.getName(), branchObj);
caseFound = true;
break;
}
}
if (caseFound) {
break;
}
}
// If we never find a case that matches the value of the discriminiator, then we must have
// found the default case.
if (!caseFound && defaultBranch != null) {
CorbaObjectHandler branchObj = unionHandler.getBranchByName(defaultBranch.getName());
this.read(branchObj);
unionHandler.setValue(defaultBranch.getName(), branchObj);
}
}