KickJava   Java API By Example, From Geeks To Geeks.

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


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.Declaration;
31 import org.objectweb.openccm.ast.api.DeclarationKind;
32 import org.objectweb.openccm.ast.api.AbstractStorageHomeDecl;
33 import org.objectweb.openccm.ast.api.StringList;
34
35 /**
36  * SegmentDeclImpl is a wrapper class for
37  * CIDL segment declarations.
38  *
39  *
40  * Inherits from:
41  *
42  * - DeclarationImpl as they are IDL declarations,
43  *
44  * - SegmentDecl: OMG IDL for SegmentDecl.
45  *
46  *
47  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
48  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
49  *
50  * @version 0.3
51  */

52
53 public class SegmentDeclImpl
54      extends DeclarationImpl
55   implements org.objectweb.openccm.ast.api.SegmentDecl
56 {
57     // ==================================================================
58
//
59
// Internal state.
60
//
61
// ==================================================================
62

63     /** The associated abstract storagehome. */
64     private AbstractStorageHomeDeclImpl ash_;
65
66     /** The list of facets. */
67     private StringListImpl facets_;
68
69     /** The list of sinks. */
70     private StringListImpl sinks_;
71
72     // ==================================================================
73
//
74
// Constructor.
75
//
76
// ==================================================================
77

78     /**
79      * The constructor with the parent scope.
80      *
81      * @param rep The repository of the declaration.
82      * @param parent The parent scope of the declaration.
83      */

84     protected
85     SegmentDeclImpl(Repository rep,
86                     ScopeImpl parent)
87     {
88         // Call the DeclarationImpl constructor.
89
super(rep, parent);
90
91         // Init internal state.
92
ash_ = null;
93         facets_ = new StringListImpl();
94         sinks_ = new StringListImpl();
95     }
96
97     // ==================================================================
98
//
99
// Internal methods.
100
//
101
// ==================================================================
102

103     // ==================================================================
104
//
105
// Methods for the inherited DeclarationImpl class.
106
//
107
// ==================================================================
108

109     /**
110      * Obtain its CORBA 3.0 Contained reference.
111      *
112      * @return The Contained object associated with the any declaration.
113      */

114     protected org.omg.CORBA.Contained JavaDoc
115     getContained()
116     {
117        return null;
118     }
119
120     // ==================================================================
121
//
122
// Public methods.
123
//
124
// ==================================================================
125

126     // ==================================================================
127
//
128
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
129
//
130
// ==================================================================
131

132     /**
133      * Obtain the declaration external dependencies.
134      *
135      * Note: for scopes, contained objects are not considered
136      * as dependencies.
137      *
138      * @return The list of dependencies as an array of Declaration.
139      */

140     public Declaration[]
141     getDependencies()
142     {
143         if (dependencies_!=null)
144             return dependencies_;
145
146         java.util.List JavaDoc seg_depend = new java.util.ArrayList JavaDoc();
147         Declaration[] depend = null;
148
149         // Segment persistence declaration
150
if (getAbstractStorageHome() != null)
151         {
152             seg_depend.add( getAbstractStorageHome() );
153             depend = getAbstractStorageHome().getDependencies();
154             for (int j=0; j<depend.length; j++)
155             {
156                 if ( (depend[j] != this) &&
157                      (seg_depend.indexOf(depend[j]) == -1) )
158                     seg_depend.add(depend[j]);
159             }
160         }
161
162         // Facets / Sinks list
163
/* No dependencies because facets and sinks are dependencies
164            of the component executor (via the component). */

165
166         dependencies_ = (Declaration[])seg_depend.toArray(new Declaration[0]);
167         return dependencies_;
168     }
169
170     // ==================================================================
171
//
172
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
173
//
174
// ==================================================================
175

176     /**
177      * Obtain its DeclarationKind.
178      *
179      * This method is implemented into DeclarationImpl subclasses.
180      *
181      * @return The DeclarationKind of the object.
182      */

183     public long
184     getDeclKind()
185     {
186       return DeclarationKind.dk_segment;
187     }
188
189     /**
190       * Obtain its category (IDL, PSDL, CIDL).
191       *
192       * @return The category of the declaration.
193       */

194     public org.objectweb.openccm.ast.api.DeclarationCategory
195     getCategory()
196     {
197         return org.objectweb.openccm.ast.api.DeclarationCategory.dc_cidl;
198     }
199
200     // ==================================================================
201
//
202
// Methods for OMG IDL org.objectweb.openccm.ast.api.SegmentDecl
203
//
204
// ==================================================================
205

206     /**
207      * Set the associated abstract storagehome.
208      *
209      * @param ash - The associated abstract storagehome.
210      */

211     public void
212     setAbstractStorageHome(AbstractStorageHomeDecl ash)
213     {
214         ash_ = (AbstractStorageHomeDeclImpl)ash;
215     }
216
217     /**
218      * Obtain the associated abstract storagehome.
219      *
220      * @return The associated abstract storagehome.
221      */

222     public AbstractStorageHomeDecl
223     getAbstractStorageHome()
224     {
225         return ash_;
226     }
227
228     /**
229      * Obtain the list of implemented facets.
230      *
231      * @return The list of facets.
232      */

233     public StringList
234     getFacetList()
235     {
236         return facets_;
237     }
238
239     /**
240      * Obtain the list of implemented sinks.
241      *
242      * @return The list of sinks.
243      */

244     public StringList
245     getSinkList()
246     {
247         return sinks_;
248     }
249 }
250
Popular Tags