KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > StructDef_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::StructDef 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.4
39  */

40
41 public class StructDef_impl
42        extends Container_impl
43        implements StructDefOperations
44 {
45     // ==================================================================
46
//
47
// Constructor.
48
//
49
// ==================================================================
50

51     /**
52      * TODO
53      */

54     public
55     StructDef_impl(IFR ifr,
56                    Container_impl container)
57     {
58         // call the Container_impl contructor.
59
super(ifr, container);
60
61         // set the tie servant object.
62
setServant(new StructDefPOATie(this));
63
64         // init internal state.
65
members_ = new StructMembers(this, this);
66     }
67
68     // ==================================================================
69
//
70
// Internal state.
71
//
72
// ==================================================================
73

74     /**
75      * The struct members.
76      */

77     protected StructMembers members_;
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         StructMember[] members = members_.getStructMemberSeq(idSeq);
98         idSeq.remove(id());
99
100         // delegate to the TypeCodeFactory.
101
return getIFR().getTCF().create_struct_tc(id(), name(), members);
102     }
103
104     // ==================================================================
105
//
106
// Public methods.
107
//
108
// ==================================================================
109

110     /**
111      * Obtain its CORBA::StructDef object reference.
112      */

113     public StructDef
114     asStructDef()
115     {
116         return StructDefHelper.narrow(asObject());
117     }
118
119     // ==================================================================
120
//
121
// For Container_impl class.
122
//
123
// ==================================================================
124

125     /**
126      * Check if this kind of objects is accepted by the container.
127      */

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

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

158     /**
159      * Cuts dependencies to other objects.
160      */

161     protected void
162     cutDependencies()
163     {
164         // Cuts dependencies to struct members types.
165
members_.cutDependencies();
166
167         // Calls the Container_impl::cutDependencies operation.
168
super.cutDependencies();
169     }
170
171     // ==================================================================
172
//
173
// For CORBA::IRObject interface.
174
//
175
// ==================================================================
176

177     /**
178      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
179      */

180     public DefinitionKind
181     def_kind()
182     {
183         return DefinitionKind.dk_Struct;
184     }
185
186     // ==================================================================
187
//
188
// For CORBA::IDLType interface.
189
//
190
// ==================================================================
191

192     /**
193      * IDL:omg.org/CORBA/IDLType/type:1.0
194      */

195     public TypeCode
196     type()
197     {
198         // check for recursion.
199
java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
200         return recursiveType(idSeq);
201     }
202
203     // ==================================================================
204
//
205
// For CORBA::Container interface.
206
//
207
// ==================================================================
208

209     // ==================================================================
210
//
211
// For CORBA::StructDef interface.
212
//
213
// ==================================================================
214

215     /**
216      * IDL:omg.org/CORBA/StructDef/members:1.0
217      */

218     public StructMember[]
219     members()
220     {
221         // delegate to the StructMembers.
222
return members_.getStructMemberSeq();
223     }
224
225     /**
226      * IDL:omg.org/CORBA/StructDef/members:1.0
227      */

228     public void
229     members(StructMember[] val)
230     {
231         // delegate to the StructMembers.
232
members_.setStructMemberSeq(val);
233     }
234 }
235
Popular Tags