/** {@inheritDoc} */ public TypeCode create_union_tc(String id, String name, TypeCode discriminator_type, UnionMember[] members ) { RecordTypeCode r = new RecordTypeCode(TCKind.tk_union); r.setId(id); r.setName(name); r.setDiscriminator_type(discriminator_type); r.setDefaultIndex(0); for (int i = 0; i < members.length; i++) { r.add(members [ i ]); } return r; }
public UnionTypeCode(String repositoryId, String name, TypeCode discriminator_type, org.omg.CORBA.UnionMember[] members) { super(TCKind.tk_union, repositoryId, name); m_discriminator_type = discriminator_type; boolean thereis_default = false; int i = 0; m_default_used = -1; // default_used mecanism not explicited in CORBA // 2.3 TypeCode tc_default = TypeCodeFactory.tc_octet; for (i = 0; i < members.length; i++) { if (tc_default.equal(members[i].label.type())) { m_default_used = i; break; } } m_members = members; }
public TypeCodeImpl(ORB orb, int creationKind, String id, String name, TypeCode discriminator_type, UnionMember[] members) // for unions { this(orb) ; if (creationKind == TCKind._tk_union) { _kind = creationKind; setId(id); _name = name; _memberCount = members.length; _discriminator = convertToNative(_orb, discriminator_type); _memberNames = new String[_memberCount]; _memberTypes = new TypeCodeImpl[_memberCount]; _unionLabels = new AnyImpl[_memberCount]; for (int i = 0 ; i < _memberCount ; i++) { _memberNames[i] = members[i].name; _memberTypes[i] = convertToNative(_orb, members[i].type); _memberTypes[i].setParent(this); _unionLabels[i] = new AnyImpl(_orb, members[i].label); // check whether this is the default branch. if (_unionLabels[i].type().kind() == TCKind.tk_octet) { if (_unionLabels[i].extract_octet() == (byte)0) { _defaultIndex = i; } } } } // else initializes to null }
/** * Create a TypeCode for a union. * * @param id the logical id for the typecode. * @param name the name for the typecode. * @param discriminator_type * the type of the union discriminator. * @param members an array describing the members of the TypeCode. * @return the requested TypeCode. */ public synchronized TypeCode create_union_tc(String id, String name, TypeCode discriminator_type, UnionMember[] members) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_union, id, name, discriminator_type, members); }
public TypeCode create_union_tc(String id, String name, TypeCode discriminator_type, UnionMember[] members) { return new TypeCodeImpl(this, TCKind._tk_union, id, name, discriminator_type, members); }
/** * Adds a new field, taking values from the passed * {@link UnionMember}. */ public void add(UnionMember m) { Field f = field(); f.name = m.name; f.type = m.type; f.label = m.label; }
public void readParams(es.tid.TIDorbj.core.cdr.CDRInputStream input) { super.readParams(input); m_discriminator_type = input.read_TypeCode(); m_default_used = input.read_long(); int length = input.read_ulong(); m_members = new UnionMember[length]; for (int i = 0; i < length; i++) { m_members[i] = new org.omg.CORBA.UnionMember(); // Change, only the the value of label is marshaled //_members[i].label = input.read_any(); m_members[i].label = input.orb().create_any(); m_members[i].label.read_value(input, m_discriminator_type); if (!m_discriminator_type.equal(m_members[i].label.type())) { if (m_members[i].label.type().kind().value() == TCKind._tk_octet) { if (m_default_used != i) throw new MARSHAL( "Bad label: Union does not have any " + "defalt member.", 0, CompletionStatus.COMPLETED_NO); } else { throw new MARSHAL("Invalid Union discriminator TypeCode", 0, CompletionStatus.COMPLETED_NO); } } m_members[i].name = input.read_string(); m_members[i].type = input.read_TypeCode(); } }