KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > UnionDef_impl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle.
23 Contributor(s): Mathieu Vadet, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ir3;
28
29 // Package dependencies
30
import org.omg.CORBA.*;
31
32 /**
33  * Implementation of the CORBA::UnionDef interface.
34  *
35  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
36  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
37  *
38  * @version 0.5
39  */

40
41 public class UnionDef_impl
42      extends Container_impl
43   implements UnionDefOperations
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** The reference to the discriminator type object. */
52     protected IDLType_ref discriminator_type_def_;
53
54     /** The union members. */
55     protected UnionMembers members_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /** TODO */
64     public
65     UnionDef_impl(IFR ifr,
66                   Container_impl container)
67     {
68         // Calls the Container_impl contructor.
69
super(ifr, container);
70
71         // Sets the tie servant object.
72
setServant(new UnionDefPOATie(this));
73
74         // Inits internal state.
75
discriminator_type_def_ = new IDLType_ref(this);
76         members_ = new UnionMembers(this);
77     }
78
79     // ==================================================================
80
//
81
// Internal methods inherited from IROject_impl.
82
//
83
// ==================================================================
84

85     /**
86      * Warning : this operation must be implemented by subclasses.
87      * It allows us to avoid some casts while creating ::CORBA::TypeCode
88      */

89     protected TypeCode
90     recursiveType(java.util.List JavaDoc idSeq)
91     {
92         int idx = idSeq.indexOf(id());
93         if (idx!=-1)
94             return getIFR().getTCF().create_recursive_tc(id());
95
96         idSeq.add(id());
97         UnionMember[] members = members_.getUnionMemberSeq(idSeq);
98         idSeq.remove(id());
99
100         // delegate to the TypeCodeFactory.
101
return getIFR().getTCF().create_union_tc(id(), name(),
102                                                  discriminator_type(),
103                                                  members);
104     }
105
106     // ==================================================================
107
//
108
// Internal methods.
109
//
110
// ==================================================================
111

112     /**
113      * Obtain its CORBA::UnionDef object reference.
114      */

115     public UnionDef
116     asUnionDef()
117     {
118         return UnionDefHelper.narrow(asObject());
119     }
120
121     // ==================================================================
122
//
123
// For Container_impl class.
124
//
125
// ==================================================================
126

127     /**
128      * Check if this kind of objects is accepted by the container.
129      */

130     public boolean
131     checkDefinitionKind(DefinitionKind dk)
132     {
133         // Only Structs, Unions and Enums are accepted!
134
return (dk == DefinitionKind.dk_Struct)
135             || (dk == DefinitionKind.dk_Union)
136             || (dk == DefinitionKind.dk_Enum);
137     }
138
139     /**
140      * Check a new name according to already contained names.
141      */

142     public void
143     checkName(String JavaDoc name,
144               boolean exclude_inherited,
145               boolean in_inherited)
146     {
147         // call the Container_impl::checkName operation.
148
super.checkName(name, exclude_inherited, in_inherited);
149
150         // check if the name is a member name.
151
members_.checkName(name);
152     }
153
154     // ==================================================================
155
//
156
// Internal methods for managing dependencies.
157
//
158
// ==================================================================
159

160     /**
161      * Cuts dependencies to other objects.
162      */

163     protected void
164     cutDependencies()
165     {
166         // Cuts the dependency.
167
discriminator_type_def_.cutDependency();
168
169         // Cuts dependencies to union members types.
170
members_.cutDependencies();
171
172         // Calls the Container_impl::cutDependencies operation.
173
super.cutDependencies();
174     }
175
176     // ==================================================================
177
//
178
// For CORBA::IRObject interface.
179
//
180
// ==================================================================
181

182     /**
183      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
184      */

185     public DefinitionKind
186     def_kind()
187     {
188         return DefinitionKind.dk_Union;
189     }
190
191     // ==================================================================
192
//
193
// For CORBA::IDLType interface.
194
//
195
// ==================================================================
196

197     /**
198      * IDL:omg.org/CORBA/IDLType/type:1.0
199      */

200     public TypeCode
201     type()
202     {
203         // check for recursion.
204
java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
205         return recursiveType(idSeq);
206     }
207
208     // ==================================================================
209
//
210
// For CORBA::Container interface.
211
//
212
// ==================================================================
213

214     // ==================================================================
215
//
216
// For CORBA::UnionDef interface.
217
//
218
// ==================================================================
219

220     /**
221      * IDL:omg.org/CORBA/UnionDef/discriminator_type:1.0
222      */

223     public TypeCode
224     discriminator_type()
225     {
226         // delegate to the IDLType reference.
227
return discriminator_type_def_.recursiveType();
228     }
229
230     /**
231      * IDL:omg.org/CORBA/UnionDef/discriminator_type_def:1.0
232      */

233     public IDLType
234     discriminator_type_def()
235     {
236         // delegate to the IDLType reference.
237
return discriminator_type_def_.asIDLType();
238     }
239
240     /**
241      * IDL:omg.org/CORBA/UnionDef/discriminator_type_def:1.0
242      */

243     public void
244     discriminator_type_def(IDLType val)
245     {
246         // for forward declarations
247
if (val == null)
248             discriminator_type_def_.setDependency(null);
249         else
250             // try to cast val to a local object
251
// and delegate to the IDLType reference.
252
discriminator_type_def_.setDependency( castToLocal(val) );
253     }
254
255     /**
256      * IDL:omg.org/CORBA/UnionDef/members:1.0
257      */

258     public UnionMember[]
259     members()
260     {
261         // delegate to the UnionMembers.
262
return members_.getUnionMemberSeq();
263     }
264
265     /**
266      * IDL:omg.org/CORBA/UnionDef/members:1.0
267      */

268     public void
269     members(UnionMember[] val)
270     {
271         // delegate to the UnionMembers.
272
members_.setUnionMemberSeq(val);
273     }
274 }
275
Popular Tags