KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > PrimitiveDef_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::PrimitiveDef 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 PrimitiveDef_impl
42      extends IRObject_impl
43   implements PrimitiveDefOperations
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** The TypeCode. */
52     protected TypeCode tc_;
53
54     /** The primitive kind. */
55     protected PrimitiveKind primitive_kind_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /** TODO */
64     public
65     PrimitiveDef_impl(IFR ifr,
66                       PrimitiveKind pk)
67     {
68         // Calls the IRObject_impl contructor.
69
super(ifr);
70
71         // Creates the tie servant object.
72
setServant(new PrimitiveDefPOATie(this));
73
74         // Obtains the TypeCodeFactory.
75
ORB tcf = ifr.getTCF();
76
77         //
78
// Creates the appropriate TypeCode.
79
//
80
switch(pk.value())
81         {
82         case PrimitiveKind._pk_null:
83             tc_ = tcf.get_primitive_tc(TCKind.tk_null);
84             break;
85
86         case PrimitiveKind._pk_void:
87             tc_ = tcf.get_primitive_tc(TCKind.tk_void);
88             break;
89
90         case PrimitiveKind._pk_short:
91             tc_ = tcf.get_primitive_tc(TCKind.tk_short);
92             break;
93
94         case PrimitiveKind._pk_long:
95             tc_ = tcf.get_primitive_tc(TCKind.tk_long);
96             break;
97
98         case PrimitiveKind._pk_ushort:
99             tc_ = tcf.get_primitive_tc(TCKind.tk_ushort);
100             break;
101
102         case PrimitiveKind._pk_ulong:
103             tc_ = tcf.get_primitive_tc(TCKind.tk_ulong);
104             break;
105
106         case PrimitiveKind._pk_float:
107             tc_ = tcf.get_primitive_tc(TCKind.tk_float);
108             break;
109
110         case PrimitiveKind._pk_double:
111             tc_ = tcf.get_primitive_tc(TCKind.tk_double);
112             break;
113
114         case PrimitiveKind._pk_boolean:
115             tc_ = tcf.get_primitive_tc(TCKind.tk_boolean);
116             break;
117
118         case PrimitiveKind._pk_char:
119             tc_ = tcf.get_primitive_tc(TCKind.tk_char);
120             break;
121
122         case PrimitiveKind._pk_octet:
123             tc_ = tcf.get_primitive_tc(TCKind.tk_octet);
124             break;
125
126         case PrimitiveKind._pk_any:
127             tc_ = tcf.get_primitive_tc(TCKind.tk_any);
128             break;
129
130         case PrimitiveKind._pk_TypeCode:
131             tc_ = tcf.get_primitive_tc(TCKind.tk_TypeCode);
132             break;
133
134         case PrimitiveKind._pk_Principal:
135             tc_ = tcf.get_primitive_tc(TCKind.tk_Principal);
136             break;
137
138         case PrimitiveKind._pk_string:
139             tc_ = tcf.create_string_tc(0);
140             break;
141
142         case PrimitiveKind._pk_objref:
143             tc_ = tcf.create_interface_tc("IDL:omg.org/CORBA/Object:1.0",
144                                           "Object");
145             break;
146
147         case PrimitiveKind._pk_longlong:
148             tc_ = tcf.get_primitive_tc(TCKind.tk_longlong);
149             break;
150
151         case PrimitiveKind._pk_ulonglong:
152             tc_ = tcf.get_primitive_tc(TCKind.tk_ulonglong);
153             break;
154
155         case PrimitiveKind._pk_longdouble:
156             tc_ = tcf.get_primitive_tc(TCKind.tk_longdouble);
157             break;
158
159         case PrimitiveKind._pk_wchar:
160             tc_ = tcf.get_primitive_tc(TCKind.tk_wchar);
161             break;
162
163         case PrimitiveKind._pk_wstring:
164             tc_ = tcf.create_wstring_tc(0);
165             break;
166
167         case PrimitiveKind._pk_value_base:
168         tc_ = org.objectweb.openccm.corba.TheORB.create_valuebase_tc();
169         break;
170         }
171
172         // Sets the PrimitiveKind.
173
primitive_kind_ = pk;
174     }
175
176     // ==================================================================
177
//
178
// Internal methods inherited from IROject_impl.
179
//
180
// ==================================================================
181

182     /**
183      * Warning : this operation must be implemented by subclasses.
184      * It allows us to avoid some casts while creating ::CORBA::TypeCode
185      */

186     protected TypeCode
187     recursiveType(java.util.List JavaDoc idSeq)
188     {
189         return type();
190     }
191
192     // ==================================================================
193
//
194
// Public methods.
195
//
196
// ==================================================================
197

198     /**
199      * Obtain its CORBA::PrimitiveDef object reference.
200      */

201     public PrimitiveDef
202     asPrimitiveDef()
203     {
204         return PrimitiveDefHelper.narrow(asObject());
205     }
206
207     // ==================================================================
208
//
209
// For CORBA::IRObject interface.
210
//
211
// ==================================================================
212

213     /**
214      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
215      */

216     public DefinitionKind
217     def_kind()
218     {
219         return DefinitionKind.dk_Primitive;
220     }
221
222     /**
223      * IDL:omg.org/CORBA/IRObject/destroy:1.0
224      */

225     public void
226     destroy()
227     {
228         // this is an indestructible IFR object!
229
throw exceptionCanNotBeDestroyed();
230     }
231
232     // ==================================================================
233
//
234
// For CORBA::IDLType interface.
235
//
236
// ==================================================================
237

238     /**
239      * IDL:omg.org/CORBA/IDLType/type:1.0
240      */

241     public TypeCode
242     type()
243     {
244         return tc_;
245     }
246
247     // ==================================================================
248
//
249
// For CORBA::PrimitiveDef interface.
250
//
251
// ==================================================================
252

253     /**
254      * IDL:omg.org/CORBA/PrimitiveDef/kind:1.0
255      */

256     public PrimitiveKind
257     kind()
258     {
259         return primitive_kind_;
260     }
261 }
262
Popular Tags