KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > SequenceDef_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::SequenceDef 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 SequenceDef_impl
42      extends AnonymousIDLType
43   implements SequenceDefOperations
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** The sequence bound. */
52     protected int bound_;
53
54     /** The sequence element type. */
55     protected IDLType_ref element_type_def_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /** TODO */
64     public
65     SequenceDef_impl(IFR ifr)
66     {
67         // Calls the AnonymousIDLType contructor.
68
super(ifr);
69
70         // Sets the TIE servant object.
71
setServant(new SequenceDefPOATie(this));
72
73         // Sets the bound to zero.
74
bound_ = 0;
75
76         // Creates the element_type_def reference.
77
element_type_def_ = new IDLType_ref(this);
78     }
79
80     // ==================================================================
81
//
82
// Internal methods inherited from IROject_impl.
83
//
84
// ==================================================================
85

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

90     protected TypeCode
91     recursiveType(java.util.List JavaDoc idSeq)
92     {
93         TypeCode tc = null;
94         try
95         {
96             Contained_impl cont = (Contained_impl)element_type_def_.getBaseImpl();
97             int idx = idSeq.indexOf(cont.id());
98             if (idx!=-1)
99             {
100                 // check if the contained can be a recursive type
101
int dk = cont.def_kind().value();
102                 if ((dk!=DefinitionKind._dk_Struct) &&
103                     (dk!=DefinitionKind._dk_Exception) &&
104                     (dk!=DefinitionKind._dk_Union) &&
105                     (dk!=DefinitionKind._dk_Value) &&
106                     (dk!=DefinitionKind._dk_Alias))
107                     throw exceptionIllegalRecursion("anonymous sequence", cont.id());
108
109                 tc = getIFR().getTCF().create_recursive_tc(cont.id());
110             }
111         }
112         catch (java.lang.ClassCastException JavaDoc ex)
113         {
114         }
115
116         if (tc==null)
117             tc = element_type_def_.recursiveType(idSeq);
118
119         return getIFR().getTCF().create_sequence_tc(bound(), tc);
120     }
121
122     // ==================================================================
123
//
124
// Public methods.
125
//
126
// ==================================================================
127

128     /**
129      * Obtain its CORBA::SequenceDef object reference.
130      */

131     public SequenceDef
132     asSequenceDef()
133     {
134         return SequenceDefHelper.narrow(asObject());
135     }
136
137     // ==================================================================
138
//
139
// Internal methods for managing dependencies.
140
//
141
// ==================================================================
142

143     /**
144      * Cuts dependencies to other objects.
145      */

146     protected void
147     cutDependencies()
148     {
149         // Cuts the dependency.
150
element_type_def_.cutDependency();
151
152         // Calls the IRObject_impl::cutDependencies method.
153
super.cutDependencies();
154     }
155
156     // ==================================================================
157
//
158
// For CORBA::IRObject interface.
159
//
160
// ==================================================================
161

162     /**
163      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
164      */

165     public DefinitionKind
166     def_kind()
167     {
168         return DefinitionKind.dk_Sequence;
169     }
170
171     // ==================================================================
172
//
173
// For CORBA::IDLType interface.
174
//
175
// ==================================================================
176

177     /**
178      * IDL:omg.org/CORBA/IDLType/type:1.0
179      */

180     public TypeCode
181     type()
182     {
183         // check for recursion.
184
java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
185         return recursiveType(idSeq);
186     }
187
188     // ==================================================================
189
//
190
// For CORBA::SequenceDef interface.
191
//
192
// ==================================================================
193

194     /**
195      * IDL:omg.org/CORBA/SequenceDef/bound:1.0
196      */

197     public int
198     bound()
199     {
200         return bound_;
201     }
202
203     public void
204     bound(int b)
205     {
206         bound_ = b;
207     }
208
209     /**
210      * IDL:omg.org/CORBA/SequenceDef/element_type:1.0
211      */

212     public TypeCode
213     element_type()
214     {
215         // delegate to the IDLType reference.
216
return element_type_def_.recursiveType();
217     }
218
219     /**
220      * IDL:omg.org/CORBA/SequenceDef/element_type_def:1.0
221      */

222     public IDLType
223     element_type_def()
224     {
225         // delegate to the IDLType reference.
226
return element_type_def_.asIDLType();
227     }
228
229     /**
230      * IDL:omg.org/CORBA/SequenceDef/element_type_def:1.0
231      */

232     public void
233     element_type_def(IDLType val)
234     {
235         // try to cast val to a local object
236
// and delegate to the IDLType reference.
237
element_type_def_.setDependency( castToLocal(val) );
238     }
239 }
240
Popular Tags