KickJava   Java API By Example, From Geeks To Geeks.

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


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

26
27 package org.objectweb.openccm.ast.lib;
28
29 // Package dependencies.
30
import org.objectweb.openccm.ast.api.DeclarationKind;
31 import org.objectweb.openccm.ast.api.Declaration;
32 import org.objectweb.openccm.ast.api.CategoryKind;
33 import org.objectweb.openccm.ast.api.HomeExecutorDecl;
34 import org.objectweb.openccm.ast.api.ProxyHomeDecl;
35
36 /**
37  * CompositionDeclImpl is a wrapper class for CIDL compsition declarations.
38  *
39  *
40  * Inherits from:
41  * - CidlScopeImpl as executors are also IDL scopes.
42  * - CompositionDecl as OMG IDL for CIDL composition declarations.
43  *
44  *
45  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
46  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
47  *
48  * @version 0.1
49  **/

50
51 public class CompositionDeclImpl
52      extends CidlScopeImpl
53   implements org.objectweb.openccm.ast.api.CompositionDecl
54 {
55     // ==================================================================
56
//
57
// Internal state.
58
//
59
// ==================================================================
60

61     /** The associated composition category. */
62     private CategoryKind category_;
63
64     // ==================================================================
65
//
66
// Constructor.
67
//
68
// ==================================================================
69

70     /**
71      * The constructor with the parent scope.
72      *
73      * @param rep The repository of the declaration.
74      * @param parent The parent scope of the exception declaration.
75      **/

76     public
77     CompositionDeclImpl(Repository rep,
78                         ScopeImpl parent)
79     {
80         // Call the ScopeImpl constructor.
81
super(rep, parent);
82
83         // Init internal state.
84
category_ = null;
85         content_loaded_ = true;
86     }
87
88     // ==================================================================
89
//
90
// Internal methods.
91
//
92
// ==================================================================
93

94     // ==================================================================
95
//
96
// Internal methods for DeclarationImpl.
97
//
98
// ==================================================================
99

100     /**
101      * Obtain its CORBA 3.0 Contained reference.
102      *
103      * @return The Contained object associated with the exception
104      * declaration.
105      **/

106     protected org.omg.CORBA.Contained JavaDoc
107     getContained()
108     {
109        return null;
110     }
111
112     // ==================================================================
113
//
114
// Internal methods for ScopeImpl.
115
//
116
// ==================================================================
117

118     /**
119      * Obtain its CORBA 3.0 Container reference.
120      *
121      * @return The Container object associated with the exception
122      * declaration.
123      **/

124     protected org.omg.CORBA.Container JavaDoc
125     getContainer()
126     {
127         return null;
128     }
129
130     // ==================================================================
131
//
132
// Public methods.
133
//
134
// ==================================================================
135

136     // ==================================================================
137
//
138
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
139
//
140
// ==================================================================
141

142     /**
143      * Obtain the declaration external dependencies.
144      *
145      * Note: for scopes, contained objects are not considered
146      * as dependencies.
147      *
148      * @return The list of dependencies as an array of Declaration.
149      **/

150     public Declaration[]
151     getDependencies()
152     {
153         if (dependencies_ != null)
154             return dependencies_;
155
156         java.util.List JavaDoc comp_depend = new java.util.ArrayList JavaDoc();
157         Declaration[] depend = null;
158
159         // contents
160
Declaration[] decls = getContents(true, DeclarationKind.dk_all);
161         for (int i=0; i<decls.length; i++)
162         {
163             depend = decls[i].getDependencies();
164             for (int j=0; j<depend.length; j++)
165             {
166                 if ( (!containsDecl(depend[j])) &&
167                      (depend[j] != this) &&
168                      (comp_depend.indexOf(depend[j]) == -1) )
169                 {
170                     comp_depend.add(depend[j]);
171                 }
172             }
173         }
174
175         dependencies_ = (Declaration[])comp_depend.toArray(new Declaration[0]);
176         return dependencies_;
177     }
178
179     // ==================================================================
180
//
181
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
182
//
183
// ==================================================================
184

185     /**
186      * Obtain its DeclarationKind.
187      *
188      * @return The DeclarationKind of the object.
189      **/

190     public long
191     getDeclKind()
192     {
193         return DeclarationKind.dk_composition;
194     }
195
196     // ==================================================================
197
//
198
// Methods for OMG IDL org.objectweb.openccm.ast.api.Scope
199
//
200
// ==================================================================
201

202     // ==================================================================
203
//
204
// Methods for OMG IDL org.objectweb.openccm.ast.api.CompositionDecl
205
//
206
// ==================================================================
207

208     /**
209      * Set the associated composition category.
210      *
211      * @param ash The associated composition category.
212      **/

213     public void
214     setCategoryKind(CategoryKind ck)
215     {
216         category_ = ck;
217     }
218
219     /**
220      * Obtain the associated composition category.
221      *
222      * @return The associated composition category.
223      **/

224     public CategoryKind
225     getCategoryKind()
226     {
227         return category_;
228     }
229
230
231     /**
232      * Start a new CIDL home executor declaration.
233      *
234      * @param name The name of the CIDL home executor declaration.
235      *
236      * @return The new created HomeExecutorDecl.
237      **/

238     public HomeExecutorDecl
239     startHomeExecutor(String JavaDoc name)
240     {
241         HomeExecutorDecl decl = new HomeExecutorDeclImpl(getRepository(), this);
242         decl.setName(name);
243         return decl;
244     }
245
246     /**
247      * Start a new CIDL proxy home declaration.
248      *
249      * @param name The name of the CIDL proxy home declaration.
250      *
251      * @return The new created ProxyHomeDecl.
252      **/

253     public ProxyHomeDecl
254     startProxyHome(String JavaDoc name)
255     {
256         ProxyHomeDecl decl = new ProxyHomeDeclImpl(getRepository(), this);
257         decl.setName(name);
258         return decl;
259     }
260 }
261
Popular Tags