KickJava   Java API By Example, From Geeks To Geeks.

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


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::AliasDef. */
39 import org.omg.CORBA.AliasDef JavaDoc;
40 import org.omg.CORBA.AliasDefHelper;
41
42 /**
43  * AliasDeclImpl is a wrapper class for IDL typedef declarations.
44  *
45  * Inherits from:
46  * - DeclarationWithTypeRefImpl as typedefs are IDL declarations
47  * which refer to an original 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 AliasDeclImpl
56        extends DeclarationWithTypeRefImpl
57        implements org.objectweb.openccm.ast.api.AliasDecl,
58                   IDLTypeWrapper
59 {
60     // ==================================================================
61
//
62
// Internal state.
63
//
64
// ==================================================================
65

66     /** Reference to the CORBA 3.0 AliasDef. */
67     private AliasDef JavaDoc alias_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 declaration.
80      */

81     protected
82     AliasDeclImpl(Repository rep,
83                   ScopeImpl parent)
84     {
85         // Call the DeclarationWithTypeRefImpl constructor.
86
super(rep, parent);
87
88         // Init internal state.
89
alias_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 AliasDef.
106      *
107      * @param contained The AliasDef to load.
108      */

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

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

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

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

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

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

188     /**
189      * Obtain its DeclarationKind.
190      *
191      * @return The DeclarationKind of the object.
192      */

193     public long
194     getDeclKind()
195     {
196         return DeclarationKind.dk_alias;
197     }
198
199     /**
200      * Create the constant declaration into the IFR.
201      */

202     public void
203     create()
204     {
205         alias_def_ = the_parent_.getContainer().
206                      create_alias(getId(), getName(), getVersion(), super.getIDLType());
207         super.create();
208     }
209
210     // ==================================================================
211
//
212
// Methods for OMG IDL org.objectweb.openccm.ast.api.TypeRef
213
//
214
// ==================================================================
215

216     /**
217      * Obtain its associated TypeKind.
218      *
219      * @return The associated TypeKind.
220      */

221     public TypeKind
222     getTypeKind()
223     {
224         return TypeKind.tk_alias;
225     }
226
227     // ==================================================================
228
//
229
// Methods for OMG IDL org.objectweb.openccm.ast.api.AliasDecl
230
//
231
// ==================================================================
232

233     // ==================================================================
234
//
235
// Methods for interface IDLTypeWrapper
236
//
237
// ==================================================================
238

239     /**
240      * Obtain its IDLType reference.
241      *
242      * @return The IDLType associated with the type reference.
243      */

244     public org.omg.CORBA.IDLType JavaDoc
245     getIDLType()
246     {
247         return alias_def_;
248     }
249 }
250
Popular Tags