KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > AliasDef_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::AliasDef 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 AliasDef_impl
42      extends Contained_impl
43   implements AliasDefOperations
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     /**
61      * TODO.
62      */

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

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

87     protected TypeCode
88     recursiveType(java.util.List JavaDoc idSeq)
89     {
90         try
91         {
92             Contained_impl cont = (Contained_impl)original_type_def_.getBaseImpl();
93             int idx = idSeq.indexOf(cont.id());
94             if (idx!=-1)
95             {
96                 // check if the contained can be a recursive type
97
int dk = cont.def_kind().value();
98                 if ((dk!=DefinitionKind._dk_Struct) &&
99                     (dk!=DefinitionKind._dk_Exception) &&
100                     (dk!=DefinitionKind._dk_Union) &&
101                     (dk!=DefinitionKind._dk_Value) &&
102                     (dk!=DefinitionKind._dk_Alias))
103                     throw exceptionIllegalRecursion(id(), cont.id());
104             }
105         }
106         catch (java.lang.ClassCastException JavaDoc ex)
107         {
108         }
109
110         TypeCode tc = original_type_def_.recursiveType(idSeq);
111
112         // delegate to the TypeCodeFactory.
113
return getIFR().getTCF().create_alias_tc(id(), name(), tc);
114     }
115
116     // ==================================================================
117
//
118
// Internal methods for managing dependencies.
119
//
120
// ==================================================================
121

122     /**
123      * Cuts dependencies to other objects.
124      */

125     protected void
126     cutDependencies()
127     {
128         // Cuts the dependency.
129
original_type_def_.cutDependency();
130
131         // Calls the Contained_impl cutDependencies operation.
132
super.cutDependencies();
133     }
134
135     // ==================================================================
136
//
137
// Public methods.
138
//
139
// ==================================================================
140

141     /**
142      * Obtain its CORBA::AliasDef object reference.
143      */

144     public AliasDef
145     asAliasDef()
146     {
147         return AliasDefHelper.narrow(asObject());
148     }
149
150     // ==================================================================
151
//
152
// For CORBA::IRObject interface.
153
//
154
// ==================================================================
155

156     /**
157      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
158      */

159     public DefinitionKind
160     def_kind()
161     {
162         return DefinitionKind.dk_Alias;
163     }
164
165     // ==================================================================
166
//
167
// For CORBA::IDLType interface.
168
//
169
// ==================================================================
170

171     /**
172      * IDL:omg.org/CORBA/IDLType/type:1.0
173      */

174     public TypeCode
175     type()
176     {
177         // check for recursion.
178
java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
179         return recursiveType(idSeq);
180     }
181
182     // ==================================================================
183
//
184
// For CORBA::AliasDef interface.
185
//
186
// ==================================================================
187

188     /**
189      * IDL:omg.org/CORBA/AliasDef/original_type_def:1.0
190      */

191     public IDLType
192     original_type_def()
193     {
194         // delegate to the IDLType reference.
195
return original_type_def_.asIDLType();
196     }
197
198     /**
199      * IDL:omg.org/CORBA/AliasDef/original_type_def:1.0
200      */

201     public void
202     original_type_def(IDLType val)
203     {
204         // try to cast val to a local object
205
// and delegate to the IDLType reference.
206
original_type_def_.setDependency( castToLocal(val) );
207     }
208 }
209
Popular Tags