KickJava   Java API By Example, From Geeks To Geeks.

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


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 /** To access AST DeclarationKind. */
30 import org.objectweb.openccm.ast.api.DeclarationKind;
31
32 /** To access AST Declaration. */
33 import org.objectweb.openccm.ast.api.Declaration;
34
35 /** To use CORBA::ValueMemberDef. */
36 import org.omg.CORBA.ValueMemberDef JavaDoc;
37 import org.omg.CORBA.ValueMemberDefHelper;
38
39 /**
40  * ValueMemberDeclImpl is a wrapper class
41  * for IDL value member declarations.
42  *
43  *
44  * Inherits from:
45  *
46  * - DeclarationWithTypeRefImpl as value members are IDL declarations
47  * and have an associated type.
48  *
49  * - ValueMemberDecl: OMG IDL for value member declarations.
50  *
51  *
52  * Provides:
53  *
54  * - The boolean 'Public' property,
55  * i.e. the setPublic and isPublic operations.
56  *
57  * - The boolean 'Private' property,
58  * i.e. the setPrivate and isPrivate operations.
59  *
60  *
61  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
62  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
63  *
64  * @version 0.3
65  */

66
67 public class ValueMemberDeclImpl
68        extends DeclarationWithTypeRefImpl
69        implements org.objectweb.openccm.ast.api.ValueMemberDecl
70 {
71     // ==================================================================
72
//
73
// Internal state.
74
//
75
// ==================================================================
76

77     /** Reference to the CORBA 3.0 ValueMemberDef. */
78     private ValueMemberDef JavaDoc value_member_def_;
79
80     /** The visibility of the value member. */
81     private short access_;
82
83     // ==================================================================
84
//
85
// Constructor.
86
//
87
// ==================================================================
88

89     /**
90      * The constructor with the parent scope.
91      *
92      * @param rep The repository of the declaration.
93      * @param parent The parent scope of the value member declaration.
94      **/

95     protected
96     ValueMemberDeclImpl(Repository rep,
97                         ScopeImpl parent)
98     {
99         // Call the DeclarationWithTypeRefImpl constructor.
100
super(rep, parent);
101
102         // Init internal state.
103
value_member_def_ = null;
104         type_ = null;
105         access_ = (short)0;
106     }
107
108     // ==================================================================
109
//
110
// Internal methods.
111
//
112
// ==================================================================
113

114     // ==================================================================
115
//
116
// Internal methods for DeclarationImpl.
117
//
118
// ==================================================================
119

120     /**
121      * Loads infos of the CORBA 3.0 ValueMemberDef.
122      *
123      * @param contained The ValueMemberDef to load.
124      */

125     protected void
126     load(org.omg.CORBA.Contained JavaDoc contained)
127     {
128         value_member_def_ = ValueMemberDefHelper.narrow(contained);
129         setType(getRepository().getAsTypeRef(value_member_def_.type_def()));
130         access_ = value_member_def_.access();
131         super.load(contained);
132     }
133
134     /**
135      * Obtain its CORBA 3.0 Contained reference.
136      *
137      * @return The Contained object associated with the value
138      * member declaration.
139      */

140     protected org.omg.CORBA.Contained JavaDoc
141     getContained()
142     {
143        return value_member_def_;
144     }
145
146     // ==================================================================
147
//
148
// Internal methods for DeclarationWithTypeRefImpl.
149
//
150
// ==================================================================
151

152     // ==================================================================
153
//
154
// Public methods.
155
//
156
// ==================================================================
157

158     // ==================================================================
159
//
160
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
161
//
162
// ==================================================================
163

164     /**
165      * Obtain the declaration external dependencies.
166      *
167      * Note: for scopes, contained objects are not considered
168      * as dependencies.
169      *
170      * @return The list of dependencies as an array of Declaration.
171      */

172     public Declaration[]
173     getDependencies()
174     {
175         if (dependencies_!=null)
176             return dependencies_;
177
178         java.util.List JavaDoc vmember_depend = new java.util.ArrayList JavaDoc();
179
180         // content
181
if (getType().isDeclaration())
182             vmember_depend.add(getType());
183
184         Declaration[] depend = getType().getDependencies();
185         for (int i=0; i<depend.length; i++)
186             vmember_depend.add(depend[i]);
187
188
189         dependencies_ = (Declaration[])vmember_depend.toArray(new Declaration[0]);
190         return dependencies_;
191     }
192
193     // ==================================================================
194
//
195
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
196
//
197
// ==================================================================
198

199     /**
200      * Obtain its DeclarationKind.
201      *
202      * @return The DeclarationKind of the object.
203      */

204     public long
205     getDeclKind()
206     {
207         return DeclarationKind.dk_value_member;
208     }
209
210     /**
211      * Create the value member declaration into the IFR.
212      */

213     public void
214     create()
215     {
216         // Create a ValueMemberDef into the IFR.
217
value_member_def_ = the_parent_.getExtValueDef().
218                             create_value_member(getId(),
219                                                 getName(),
220                                                 getVersion(),
221                                                 getIDLType(),
222                                                 access_);
223         super.create();
224     }
225
226     // ==================================================================
227
//
228
// Methods for org.objectweb.openccm.ast.api.DeclarationWithTypeRef
229
//
230
// ==================================================================
231

232     // ==================================================================
233
//
234
// Methods for OMG IDL org.objectweb.openccm.ast.api.ValueMemberDecl
235
//
236
// ==================================================================
237

238     /**
239      * Set as a public value member.
240      */

241     public void
242     setPublic()
243     {
244         access_ = (short)1;
245     }
246
247     /**
248      * Is it a public value member?
249      *
250      * @return True if it is public, else false.
251      */

252     public boolean
253     isPublic()
254     {
255         return access_ == (short)1;
256     }
257
258     /**
259      * Set as a private value member.
260      */

261     public void
262     setPrivate()
263     {
264         access_ = (short)0;
265     }
266
267     /**
268      * Is it a private value member?
269      *
270      * @return True if it is private, else false.
271      */

272     public boolean
273     isPrivate()
274     {
275         return access_ == (short)0;
276     }
277 }
278
Popular Tags