KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > ValueMemberDef_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::ValueMemberDef 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 ValueMemberDef_impl
42      extends FeatureContained
43   implements ValueMemberDefOperations
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** The type of the value member. */
52     protected IDLType_ref type_def_;
53
54     /** The access mode of the value member. */
55     protected short access_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /** TODO */
64     public
65     ValueMemberDef_impl(IFR ifr,
66                         Container_impl container)
67     {
68         // Calls the FeatureContained contructor.
69
super(ifr, container);
70
71     // Sets the tie servant object.
72
setServant(new ValueMemberDefPOATie(this));
73
74         // Creates the type_def reference.
75
type_def_ = new IDLType_ref(this);
76
77         // Inits access mode.
78
access_ = (short)1;
79     }
80
81     // ==================================================================
82
//
83
// Internal methods inherited from IROject_impl.
84
//
85
// ==================================================================
86

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

91     protected TypeCode
92     recursiveType(java.util.List JavaDoc idSeq)
93     {
94         try
95         {
96             Contained_impl cont = (Contained_impl)type_def_.getBaseImpl();
97             int idx = idSeq.indexOf(cont.id());
98             if (idx!=-1)
99                 return getIFR().getTCF().create_recursive_tc(cont.id());
100         }
101         catch(java.lang.ClassCastException JavaDoc ex)
102         {
103         }
104
105         return type_def_.recursiveType(idSeq);
106     }
107
108     // ==================================================================
109
//
110
// Public methods.
111
//
112
// ==================================================================
113

114     /**
115      * Obtain its CORBA::ValueMemberDef object reference.
116      */

117     public ValueMemberDef
118     asValueMemberDef()
119     {
120         return ValueMemberDefHelper.narrow(asObject());
121     }
122
123     /**
124      * Obtain its CORBA::ValueMember.
125      */

126     public ValueMember
127     getValueMember()
128     {
129         // create the CORBA::ValueMember.
130
ValueMember description = new ValueMember();
131
132         // set its fields.
133
description.name = name();
134         description.id = id();
135         description.defined_in = getContainerID();
136         description.version = version();
137         description.type = type();
138         description.type_def = type_def();
139         description.access = access();
140
141         return description;
142     }
143
144     /**
145      * Obtain its CORBA::ValueMember.
146      */

147     public ValueMember
148     getValueMember(java.util.List JavaDoc idSeq)
149     {
150         // create the CORBA::ValueMember.
151
ValueMember description = new ValueMember();
152
153         // set its fields.
154
description.name = name();
155         description.id = id();
156         description.defined_in = getContainerID();
157         description.version = version();
158         description.type = recursiveType(idSeq);
159         description.type_def = type_def();
160         description.access = access();
161
162         return description;
163     }
164
165     // ==================================================================
166
//
167
// For Contained_impl class.
168
//
169
// ==================================================================
170

171     /**
172      * To set the value field of the CORBA::Contained::Description struct.
173      */

174     public void
175     setDescriptionValue(Any any)
176     {
177         // insert its CORBA::ValueMember into the any.
178
ValueMemberHelper.insert(any, getValueMember());
179     }
180
181     // ==================================================================
182
//
183
// Internal methods for managing dependencies.
184
//
185
// ==================================================================
186

187     /**
188      * Cuts dependencies to other objects.
189      */

190     protected void
191     cutDependencies()
192     {
193         // Cuts the dependency.
194
type_def_.cutDependency();
195
196         // Calls the Container_impl::cutDependencies operation.
197
super.cutDependencies();
198     }
199
200     // ==================================================================
201
//
202
// For CORBA::IRObject interface.
203
//
204
// ==================================================================
205

206     /**
207      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
208      */

209     public DefinitionKind
210     def_kind()
211     {
212         return DefinitionKind.dk_ValueMember;
213     }
214
215     // ==================================================================
216
//
217
// For CORBA::ValueMemberDef interface.
218
//
219
// ==================================================================
220

221     /**
222      * IDL:omg.org/CORBA/ValueMemberDef/type:1.0
223      */

224     public TypeCode
225     type()
226     {
227         // check for recursion.
228
java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
229         return recursiveType(idSeq);
230     }
231
232     /**
233      * IDL:omg.org/CORBA/ValueMemberDef/type_def:1.0
234      */

235     public IDLType
236     type_def()
237     {
238         // delegate to the IDLType reference.
239
return type_def_.asIDLType();
240     }
241
242     /**
243      * IDL:omg.org/CORBA/ValueMemberDef/type_def:1.0
244      */

245     public void
246     type_def(IDLType val)
247     {
248         // try to cast val to a local object
249
// and delegate to the IDLType reference.
250
type_def_.setDependency( castToLocal(val) );
251     }
252
253     /**
254      * IDL:omg.org/CORBA/ValueMemberDef/access:1.0
255      */

256     public short
257     access()
258     {
259         return access_;
260     }
261
262     /**
263      * IDL:omg.org/CORBA/ValueMemberDef/access:1.0
264      */

265     public void
266     access(short val)
267     {
268         access_ = val;
269     }
270 }
271
Popular Tags