KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > IDL3 > AliasDeclImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.IDL3;
28
29 /**
30  * This class implements the typedef declaration.
31  *
32  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.3
36  */

37
38 public class AliasDeclImpl
39        extends DeclarationImpl
40        implements TypeRef, AliasDecl
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /**
49      ** Reference to the CORBA 3.0 AliasDef.
50      **/

51     private org.omg.CORBA.AliasDef JavaDoc alias_def_;
52
53     /**
54      ** The original type of the alias.
55      **/

56     private TypeRef original_type_;
57
58     // ==================================================================
59
//
60
// Constructor.
61
//
62
// ==================================================================
63

64     /**
65      ** The constructor with the parent scope.
66      **
67      ** @param parent The parent scope of the declaration.
68      **/

69     protected
70     AliasDeclImpl(Repository rep, ScopeImpl parent)
71     {
72         // Call the DeclarationImpl constructor.
73
super(rep, parent);
74
75         // Init internal state.
76
alias_def_ = null;
77         original_type_ = null;
78         the_declaration_kind_ = DeclarationKind._dk_alias;
79     }
80
81     // ==================================================================
82
//
83
// Internal methods.
84
//
85
// ==================================================================
86

87     /**
88      ** Loads infos of the CORBA 3.0 AliasDef.
89      **
90      ** @param aliasDef The AliasDef to load.
91      **/

92     protected void
93     load(org.omg.CORBA.Contained JavaDoc contained)
94     {
95         alias_def_ = org.omg.CORBA.AliasDefHelper.narrow(contained);
96         setType(getRepository().getAsTypeRef(alias_def_.original_type_def()));
97         super.load(contained);
98     }
99
100     /**
101      ** Loads infos of the CORBA 3.0 AliasDef.
102      **
103      ** @param aliasDef The AliasDef to load.
104      **/

105     protected void
106     loadAsMapping(org.omg.CORBA.Contained JavaDoc contained)
107     {
108         alias_def_ = org.omg.CORBA.AliasDefHelper.narrow(contained);
109         setType(getRepository().getAsMappedTypeRef(alias_def_.original_type_def()));
110         super.load(contained);
111     }
112
113     // ==================================================================
114
//
115
// Methods for the Declaration interface.
116
//
117
// ==================================================================
118

119     /**
120      ** Create the constant declaration into the IFR.
121      **/

122     public void
123     create()
124     {
125         alias_def_ = the_parent_.getContainer().create_alias(getId(), getName(), getVersion(),
126                                                              original_type_.getIDLType());
127
128         super.create();
129     }
130
131     /**
132      ** Obtain the declaration external dependencies.
133      ** Note: for scopes, contained objects are not considered
134      ** as dependencies.
135      **
136      ** @return The list of dependencies as an array of Declaration.
137      **/

138     public Declaration[]
139     getDependencies()
140     {
141         if (dependencies_!=null)
142             return dependencies_;
143
144         org.objectweb.ccm.util.Vector alias_depend = new org.objectweb.ccm.util.Vector();
145
146         // content
147
if (getType().isDeclaration())
148             alias_depend.add(getType());
149
150         Declaration[] depend = getType().getDependencies();
151         for (int i=0;i<depend.length;i++)
152             alias_depend.add(depend[i]);
153
154
155         dependencies_ = (Declaration[])alias_depend.toArray(new Declaration[0]);
156         return dependencies_;
157     }
158
159     // ==================================================================
160
//
161
// Methods for the TypeRef interface.
162
//
163
// ==================================================================
164

165     /**
166      ** Obtain its IDLType reference.
167      **
168      ** @return The IDLType associated with the typedef declaration.
169      **/

170     public org.omg.CORBA.IDLType JavaDoc
171     getIDLType()
172     {
173         return alias_def_;
174     }
175
176     /**
177      **
178      **/

179     public int
180     getTypeKind()
181     {
182         return TypeKind._tk_alias;
183     }
184
185     // ==================================================================
186
//
187
// Methods for the AliasDecl interface.
188
//
189
// ==================================================================
190

191     /**
192      **
193      **/

194     public TypeRef
195     getType()
196     {
197         return original_type_;
198     }
199
200     /**
201      ** Set the original type.
202      **
203      ** @param type To original type of the typedef declaration.
204      **/

205     public void
206     setType(TypeRef type)
207     {
208         if(type != null)
209         {
210             original_type_ = type;
211             original_type_.addRef();
212         }
213     }
214
215     // ==================================================================
216
//
217
// Methods for the inherited DeclarationImpl class.
218
//
219
// ==================================================================
220

221     /**
222      **
223      **/

224     public void
225     destroy()
226     {
227         if (original_type_!=null)
228             original_type_.removeRef();
229
230         super.destroy();
231     }
232
233     /**
234      ** Obtain its CORBA 3.0 Contained reference.
235      **
236      ** @return The Contained object associated with the typedef declaration.
237      **/

238     protected org.omg.CORBA.Contained JavaDoc
239     getContained()
240     {
241        return alias_def_;
242     }
243 }
244
Popular Tags