1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44:
45: import ;
46: import ;
47:
48:
53: public abstract class UnionMemberHelper
54: {
55:
58: private static TypeCode typeCode;
59:
60:
63: private static boolean active;
64:
65:
68: public static void insert(Any a, UnionMember that)
69: {
70: OutputStream out = a.create_output_stream();
71: a.type(type());
72: write(out, that);
73: a.read_value(out.create_input_stream(), type());
74: }
75:
76:
79: public static UnionMember extract(Any a)
80: {
81: return read(a.create_input_stream());
82: }
83:
84:
87: public static synchronized TypeCode type()
88: {
89: if (typeCode == null)
90: {
91: synchronized (TypeCode.class)
92: {
93: if (typeCode == null)
94: {
95: if (active)
96: {
97: return OrbRestricted.Singleton.create_recursive_tc(id());
98: }
99: active = true;
100:
101: ORB orb = OrbRestricted.Singleton;
102:
103: StructMember[] members = new StructMember[ 4 ];
104: TypeCode member;
105: member = orb.create_string_tc(0);
106: member =
107: orb.create_alias_tc(IdentifierHelper.id(), "Identifier",
108: member
109: );
110: members [ 0 ] = new StructMember("name", member, null);
111: member = orb.get_primitive_tc(TCKind.tk_any);
112: members [ 1 ] = new StructMember("label", member, null);
113: member = orb.create_string_tc(0);
114: member = orb.get_primitive_tc(TCKind.tk_TypeCode);
115: members [ 2 ] = new StructMember("type", member, null);
116: member = IDLTypeHelper.type();
117: members [ 3 ] = new StructMember("type_def", member, null);
118: typeCode =
119: orb.create_struct_tc(UnionMemberHelper.id(), "UnionMember",
120: members
121: );
122: active = false;
123: }
124: }
125: }
126: return typeCode;
127: }
128:
129:
134: public static String id()
135: {
136: return "IDL:omg.org/CORBA/UnionMember:1.0";
137: }
138:
139:
142: public static UnionMember read(InputStream istream)
143: {
144: try
145: {
146: UnionMember value = new UnionMember();
147: value.name = istream.read_string();
148: value.label = istream.read_any();
149: value.type = TypeCodeHelper.read(istream);
150: value.type_def = IDLTypeHelper.read(istream);
151: return value;
152: }
153: catch (UserException ex)
154: {
155: MARSHAL m = new MARSHAL();
156: m.minor = Minor.UserException;
157: m.initCause(ex);
158: throw m;
159: }
160: }
161:
162:
165: public static void write(OutputStream ostream, UnionMember value)
166: {
167: try
168: {
169: ostream.write_string(value.name);
170: ostream.write_any(value.label);
171: TypeCodeHelper.write(ostream, value.type);
172: IDLTypeHelper.write(ostream, value.type_def);
173: }
174: catch (UserException ex)
175: {
176: MARSHAL m = new MARSHAL();
177: m.minor = Minor.UserException;
178: m.initCause(ex);
179: throw m;
180: }
181: }
182: }