KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > ExceptionDef_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::ExceptionDef 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 ExceptionDef_impl
42        extends Container_impl
43        implements ExceptionDefOperations
44 {
45     // ==================================================================
46
//
47
// Constructor.
48
//
49
// ==================================================================
50

51     /**
52      * TODO
53      */

54     public
55     ExceptionDef_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 ExceptionDefPOATie(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 exception members.
76      */

77     protected StructMembers members_;
78
79     // ==================================================================
80
//
81
// Internal methods for the inherited IRObject_impl class.
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         idSeq.add(id());
93         StructMember[] members = members_.getStructMemberSeq(idSeq);
94         idSeq.remove(id());
95
96         // delegate to the TypeCodeFactory.
97
return getIFR().getTCF().create_exception_tc(id(), name(), members);
98     }
99
100     // ==================================================================
101
//
102
// Static public methods.
103
//
104
// ==================================================================
105

106     /**
107      * Compute the CORBA::ExcDescriptionSeq for an CORBA::ExceptionDefSeq.
108      */

109     static public ExceptionDescription[]
110     compute_ExcDescriptionSeq(ExceptionDef_ref[] seq)
111     {
112         ExceptionDescription[] result =
113                         new ExceptionDescription[seq.length];
114
115         for(int i=0; i<seq.length; i++)
116             result[i] = seq[i].getImpl().getExceptionDescription();
117
118         return result;
119     }
120
121     // ==================================================================
122
//
123
// Public methods.
124
//
125
// ==================================================================
126

127     /**
128      * Obtain its CORBA::ExceptionDef object reference.
129      */

130     public ExceptionDef
131     asExceptionDef()
132     {
133         return ExceptionDefHelper.narrow(asObject());
134     }
135
136     /**
137      * Obtain its CORBA::ExceptionDescription.
138      */

139     public ExceptionDescription
140     getExceptionDescription()
141     {
142         // create the CORBA::ExceptionDescription.
143
ExceptionDescription description =
144                                    new ExceptionDescription();
145
146         // set its fields.
147
description.name = name();
148         description.id = id();
149         description.defined_in = getContainerID();
150         description.version = version();
151         description.type = type();
152
153         return description;
154     }
155
156     // ==================================================================
157
//
158
// For Contained_impl class.
159
//
160
// ==================================================================
161

162     /**
163      * To set the value field of the CORBA::Contained::Description struct.
164      */

165     public void
166     setDescriptionValue(Any any)
167     {
168         // insert its CORBA::ExceptionDescription into the any.
169
ExceptionDescriptionHelper.insert(any, getExceptionDescription());
170     }
171
172     // ==================================================================
173
//
174
// For Container_impl class.
175
//
176
// ==================================================================
177

178     /**
179      * Check if this kind of objects is accepted by the container.
180      */

181     public boolean
182     checkDefinitionKind(DefinitionKind dk)
183     {
184         // Only Structs, Unions and Enums are accepted!
185
return (dk == DefinitionKind.dk_Struct)
186             || (dk == DefinitionKind.dk_Union)
187             || (dk == DefinitionKind.dk_Enum);
188     }
189
190     /**
191      * Check a new name according to already contained names.
192      */

193     public void
194     checkName(String JavaDoc name,
195               boolean exclude_inherited,
196               boolean in_inherited)
197     {
198         // call the Container_impl::checkName operation.
199
super.checkName(name, exclude_inherited, in_inherited);
200
201         // check if the name is a member name.
202
members_.checkName(name);
203     }
204
205     // ==================================================================
206
//
207
// Internal methods for managing dependencies.
208
//
209
// ==================================================================
210

211     /**
212      * Cuts dependencies to other objects.
213      */

214     protected void
215     cutDependencies()
216     {
217         // Cuts dependencies to exception members types.
218
members_.cutDependencies();
219
220         // Calls the Container_impl::cutDependencies operation.
221
super.cutDependencies();
222     }
223
224     // ==================================================================
225
//
226
// For CORBA::IRObject interface.
227
//
228
// ==================================================================
229

230     /**
231      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
232      */

233     public DefinitionKind
234     def_kind()
235     {
236         return DefinitionKind.dk_Exception;
237     }
238
239     // ==================================================================
240
//
241
// For CORBA::Container interface.
242
//
243
// ================================================================
244

245     // ==================================================================
246
//
247
// For CORBA::ExceptionDef interface.
248
//
249
// ==================================================================
250

251     /**
252      * IDL:omg.org/CORBA/ExceptionDef/type:1.0
253      */

254     public TypeCode
255     type()
256     {
257         // check for recursion.
258
java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
259         return recursiveType(idSeq);
260     }
261
262     /**
263      * IDL:omg.org/CORBA/ExceptionDef/members:1.0
264      */

265     public StructMember[]
266     members()
267     {
268         // delegate to the StructMembers.
269
return members_.getStructMemberSeq();
270     }
271
272     /**
273      * IDL:omg.org/CORBA/ExceptionDef/members:1.0
274      */

275     public void
276     members(StructMember[] val)
277     {
278         // delegate to the StructMembers.
279
members_.setStructMemberSeq(val);
280     }
281 }
282
Popular Tags