KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > lib > ValueBoxDeclImpl


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, Mathieu Vadet.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** Used to access AST TypeKind. */
30 import org.objectweb.openccm.ast.api.TypeKind;
31
32 /** Used to access AST DeclarationKind. */
33 import org.objectweb.openccm.ast.api.DeclarationKind;
34
35 /** Used to access AST Declaration. */
36 import org.objectweb.openccm.ast.api.Declaration;
37
38 /** To use CORBA::ValueBoxDef. */
39 import org.omg.CORBA.ValueBoxDef JavaDoc;
40 import org.omg.CORBA.ValueBoxDefHelper;
41
42 /**
43  * ValueBoxDeclImpl is a wrapper class for IDL value box declarations.
44  *
45  * Inherits from:
46  * - DeclarationWithTypeRefImpl as value boxes are IDL declarations
47  * and have an associated type.
48  *
49  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
50  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
51  *
52  * @version 0.3
53  */

54
55 public class ValueBoxDeclImpl
56        extends DeclarationWithTypeRefImpl
57        implements org.objectweb.openccm.ast.api.ValueBoxDecl,
58                   IDLTypeWrapper
59 {
60     // ==================================================================
61
//
62
// Internal state.
63
//
64
// ==================================================================
65

66     /** Reference to the CORBA 3.0 ValueBoxDef. */
67     private ValueBoxDef JavaDoc value_box_def_;
68
69     // ==================================================================
70
//
71
// Constructor.
72
//
73
// ==================================================================
74

75     /**
76      * The constructor with the parent scope.
77      *
78      * @param rep The repository of the declaration.
79      * @param parent The parent scope of the value box declaration.
80      */

81     protected
82     ValueBoxDeclImpl(Repository rep,
83                      ScopeImpl parent)
84     {
85         // Call the DeclarationWithTypeRefImpl constructor.
86
super(rep, parent);
87
88         // Init internal state.
89
value_box_def_ = null;
90     }
91
92     // ==================================================================
93
//
94
// Internal methods.
95
//
96
// ==================================================================
97

98     // ==================================================================
99
//
100
// Internal methods for DeclarationImpl.
101
//
102
// ==================================================================
103

104     /**
105      * Loads infos of the CORBA 3.0 ValueBoxDef.
106      *
107      * @param contained The ValueBoxDef to load.
108      */

109     protected void
110     load(org.omg.CORBA.Contained JavaDoc contained)
111     {
112         value_box_def_ = ValueBoxDefHelper.narrow(contained);
113         setType(getRepository().
114                 getAsTypeRef(value_box_def_.original_type_def()));
115         super.load(contained);
116     }
117
118     /**
119      * Loads infos of the CORBA 3.0 ValueBoxDef.
120      *
121      * @param contained The ValueBoxDef to load.
122      */

123     protected void
124     loadAsMapping(org.omg.CORBA.Contained JavaDoc contained)
125     {
126         value_box_def_ = ValueBoxDefHelper.narrow(contained);
127         setType(getRepository().
128                 getAsMappedTypeRef(value_box_def_.original_type_def()));
129         super.loadAsMapping(contained);
130     }
131
132     /**
133      * Obtain its CORBA 3.0 Contained reference.
134      *
135      * @return The Contained object associated with the
136      * value box declaration.
137      */

138     protected org.omg.CORBA.Contained JavaDoc
139     getContained()
140     {
141        return value_box_def_;
142     }
143
144     // ==================================================================
145
//
146
// Public methods.
147
//
148
// ==================================================================
149

150     // ==================================================================
151
//
152
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
153
//
154
// ==================================================================
155

156     /**
157      * Obtain the declaration external dependencies.
158      *
159      * Note: for scopes, contained objects are not considered
160      * as dependencies.
161      *
162      * @return The list of dependencies as an array of Declaration.
163      */

164     public Declaration[]
165     getDependencies()
166     {
167         if (dependencies_!=null)
168             return dependencies_;
169
170         java.util.List JavaDoc vbox_depend = new java.util.ArrayList JavaDoc();
171
172         // content
173
if (getType().isDeclaration())
174             vbox_depend.add(getType());
175
176         Declaration[] depend = getType().getDependencies();
177         for (int i=0;i<depend.length;i++)
178             vbox_depend.add(depend[i]);
179
180         dependencies_ = (Declaration[])vbox_depend.toArray(new Declaration[0]);
181         return dependencies_;
182     }
183
184     // ==================================================================
185
//
186
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
187
//
188
// ==================================================================
189

190     /**
191      * Obtain its DeclarationKind.
192      *
193      * @return The DeclarationKind of the object.
194      */

195     public long
196     getDeclKind()
197     {
198         return DeclarationKind.dk_value_box;
199     }
200
201     /**
202      * Create the value box declaration into the IFR.
203      */

204     public void
205     create()
206     {
207         value_box_def_ = the_parent_.getContainer().
208                          create_value_box(getId(),
209                                           getName(),
210                                           getVersion(),
211                                           super.getIDLType());
212         super.create();
213     }
214
215     // ==================================================================
216
//
217
// Methods for OMG IDL org.objectweb.openccm.ast.api.TypeRef
218
//
219
// ==================================================================
220

221     /**
222      * Obtain its associated TypeKind.
223      *
224      * @return The associated TypeKind.
225      */

226     public TypeKind
227     getTypeKind()
228     {
229         return TypeKind.tk_value_box;
230     }
231
232     // ==================================================================
233
//
234
// Methods for OMG IDL org.objectweb.openccm.ast.api.ValueBoxDecl
235
//
236
// ==================================================================
237

238     // ==================================================================
239
//
240
// Methods for interface IDLTypeWrapper
241
//
242
// ==================================================================
243

244     /**
245      * Obtain its IDLType reference.
246      *
247      * @return The IDLType associated with the type reference.
248      */

249     public org.omg.CORBA.IDLType JavaDoc
250     getIDLType()
251     {
252         return value_box_def_;
253     }
254 }
255
Popular Tags