}
public static TypeCode getUnionTypeCode(ORB orb, Object obj, List<CorbaTypeMap> typeMaps) {
Union unionType = (Union)obj;
TypeCode discTC = getTypeCode(orb, unionType.getDiscriminator(), typeMaps);
Map<String, UnionMember> members = new LinkedHashMap<String, UnionMember>();
List<Unionbranch> branches = unionType.getUnionbranch();
for (Iterator<Unionbranch> branchIter = branches.iterator(); branchIter.hasNext();) {
Unionbranch branch = branchIter.next();
List<CaseType> cases = branch.getCase();
for (Iterator<CaseType> caseIter = cases.iterator(); caseIter.hasNext();) {
CaseType cs = caseIter.next();
UnionMember member = new UnionMember();
member.name = branch.getName();
member.type = getTypeCode(orb, branch.getIdltype(), typeMaps);
member.label = orb.create_any();
// We need to insert the labels in a way that depends on the type of the discriminator.
// According to the CORBA specification, the following types are permissable as
// discriminator types:
// * signed & unsigned short
// * signed & unsigned long
// * signed & unsigned long long
// * char
// * boolean
switch (discTC.kind().value()) {
case TCKind._tk_short:
member.label.insert_short(Short.parseShort(cs.getLabel()));
break;
case TCKind._tk_ushort:
member.label.insert_ushort(Short.parseShort(cs.getLabel()));