KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > ValueBoxDef_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::ValueBoxDef 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 ValueBoxDef_impl
42      extends Contained_impl
43   implements ValueBoxDefOperations
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** The original type of the alias. */
52     protected IDLType_ref original_type_def_;
53
54     // ==================================================================
55
//
56
// Constructor.
57
//
58
// ==================================================================
59

60     /** TODO */
61     public
62     ValueBoxDef_impl(IFR ifr,
63                      Container_impl container)
64     {
65         // Calls the Contained_impl contructor.
66
super(ifr, container);
67
68         // Sets the tie servant object.
69
setServant(new ValueBoxDefPOATie(this));
70
71         // Creates the original_type_def reference.
72
original_type_def_ = new IDLType_ref(this);
73     }
74
75     // ==================================================================
76
//
77
// Internal methods for the inherited IRObject_impl class.
78
//
79
// ==================================================================
80

81     /**
82      * Warning : this operation must be implemented by subclasses.
83      * It allows us to avoid some casts while creating ::CORBA::TypeCode
84      */

85     protected TypeCode
86     recursiveType(java.util.List JavaDoc idSeq)
87     {
88         try
89         {
90             Contained_impl cont = (Contained_impl)original_type_def_.getBaseImpl();
91             int idx = idSeq.indexOf(cont.id());
92             if (idx!=-1)
93             {
94                 throw exceptionIllegalRecursion(id(), cont.id());
95             }
96         }
97         catch (java.lang.ClassCastException JavaDoc ex)
98         {
99         }
100
101         TypeCode tc = original_type_def_.recursiveType(idSeq);
102
103         // delegate to the TypeCodeFactory.
104
return getIFR().getTCF().create_value_box_tc(id(), name(), tc);
105     }
106
107     // ==================================================================
108
//
109
// Internal methods.
110
//
111
// ==================================================================
112

113     /**
114      * Obtain its CORBA::ValueBoxDef object reference.
115      */

116     public ValueBoxDef
117     asValueBoxDef()
118     {
119         return ValueBoxDefHelper.narrow(asObject());
120     }
121
122     // ==================================================================
123
//
124
// Internal methods for managing dependencies.
125
//
126
// ==================================================================
127

128     /**
129      * Cuts dependencies to other objects.
130      */

131     protected void
132     cutDependencies()
133     {
134         // Cuts the dependency.
135
original_type_def_.cutDependency();
136
137         // Calls the Container_impl::cutDependencies operation.
138
super.cutDependencies();
139     }
140
141     // ==================================================================
142
//
143
// For CORBA::IRObject interface.
144
//
145
// ==================================================================
146

147     /**
148      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
149      */

150     public DefinitionKind
151     def_kind()
152     {
153         return DefinitionKind.dk_ValueBox;
154     }
155
156     // ==================================================================
157
//
158
// For CORBA::IDLType interface.
159
//
160
// ==================================================================
161

162     /**
163      * IDL:omg.org/CORBA/IDLType/type:1.0
164      */

165     public TypeCode
166     type()
167     {
168         // check for recursion.
169
java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
170         return recursiveType(idSeq);
171     }
172
173     // ==================================================================
174
//
175
// For CORBA::ValueBoxDef interface.
176
//
177
// ==================================================================
178

179     /**
180      * IDL:omg.org/CORBA/ValueBoxDef/original_type_def:1.0
181      */

182     public IDLType
183     original_type_def()
184     {
185         // delegate to the IDLType reference.
186
return original_type_def_.asIDLType();
187     }
188
189     /**
190      * IDL:omg.org/CORBA/ValueBoxDef/original_type_def:1.0
191      */

192     public void
193     original_type_def(IDLType val)
194     {
195         // Try to cast val to a local object.
196
IRObject_impl type = castToLocal(val);
197
198         // Obtain the unaliased TypeCode of the type.
199
TypeCode tc = type.type();
200         while (tc.kind() == TCKind.tk_alias)
201         {
202             try
203             {
204                 tc = tc.content_type();
205             }
206             catch(org.omg.CORBA.TypeCodePackage.BadKind JavaDoc exc)
207             {
208             }
209         }
210
211         // Check the type code kind.
212
TCKind tk = tc.kind();
213         if( tk == TCKind.tk_null
214           || tk == TCKind.tk_void
215           || tk == TCKind.tk_Principal
216           || tk == TCKind.tk_except
217           || tk == TCKind.tk_native
218           || tk == TCKind.tk_abstract_interface
219           || tk == TCKind.tk_value
220           || tk == TCKind.tk_value_box)
221             throw exceptionInvalidValueBoxType();
222
223         // Delegate to the IDLType reference.
224
original_type_def_.setDependency( type );
225     }
226 }
227
Popular Tags