public final class JIUnion extends Object implements Serializable
Union data type. Its usage is dictated
by the discriminant which acts as a "switch" to select the correct member to
be serialized\deserialzed.
Sample Usage :-
JIUnion forTypeDesc = new JIUnion(Short.class);
The TypeDesc.VT_PTR is an
JIPointer ptrToTypeDesc = new JIPointer(typeDesc);
JIPointer ptrToArrayDesc = new JIPointer(arrayDesc);
forTypeDesc.addMember(TypeDesc.VT_PTR,ptrToTypeDesc);
forTypeDesc.addMember(TypeDesc.VT_SAFEARRAY,ptrToTypeDesc);
forTypeDesc.addMember(TypeDesc.VT_CARRAY,ptrToArrayDesc);
forTypeDesc.addMember(TypeDesc.VT_USERDEFINED,Integer.class);
Integer and is used as a discriminant
to select ptrTypeDesc, TypeDesc.VT_CARRAY chooses ptrArrayDesc.
| Constructor and Description |
|---|
JIUnion(Class discriminantClass)
Creates an object with discriminant type specified.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMember(Object discriminant,
JIStruct member)
Adds a member to this Union.
|
void |
addMember(Object discriminant,
Object member)
Adds a member to this Union.
|
Map |
getMembers()
Returns the discriminant Vs there members Map.
|
void |
removeMember(Object discriminant)
Removes the entry , identified by it's
discriminant from the
parameter list of the union. |
public JIUnion(Class discriminantClass)
Integer,Short,Boolean or
Character. discriminantClass - IllegalArgumentException - if the discriminantClass is
not of the type as specified above.public void addMember(Object discriminant, Object member) throws JIException
member is distinguished
using the discriminant. discriminant - member - JIExceptionIllegalArgumentException - if any parameter is nullpublic void addMember(Object discriminant, JIStruct member) throws JIException
member is distinguished
using the discriminant. discriminant - member - JIExceptionIllegalArgumentException - if discriminant is
nullpublic void removeMember(Object discriminant)
discriminant from the
parameter list of the union. discriminant - public Map getMembers()
Copyright © 2022. All rights reserved.