KickJava   Java API By Example, From Geeks To Geeks.

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


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 manages IDL value member declarations.
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 ValueMemberDeclImpl
39        extends DeclarationImpl
40        implements ValueMemberDecl
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

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

51     private org.omg.CORBA.ValueMemberDef JavaDoc value_member_def_;
52
53     /**
54      ** The type of the value member.
55      **/

56     private TypeRef type_;
57
58     /**
59      ** The visibility of the value member.
60      **/

61     private short access_;
62
63     // ==================================================================
64
//
65
// Constructor.
66
//
67
// ==================================================================
68

69     /**
70      ** The constructor with the parent scope.
71      **
72      ** @param parent The parent scope of the value member declaration.
73      **/

74     protected
75     ValueMemberDeclImpl(Repository rep, ScopeImpl parent)
76     {
77         // Call the DeclarationImpl constructor.
78
super(rep, parent);
79
80         // Init internal state.
81
value_member_def_ = null;
82         type_ = null;
83         access_ = (short)0;
84         the_declaration_kind_ = DeclarationKind._dk_value_member;
85     }
86
87     // ==================================================================
88
//
89
// Internal methods.
90
//
91
// ==================================================================
92

93     /**
94      ** Loads infos of the CORBA 3.0 ValueMemberDef.
95      **
96      ** @param value_member_def The ValueMemberDef to load.
97      **/

98     protected void
99     load(org.omg.CORBA.Contained JavaDoc contained)
100     {
101         value_member_def_ = org.omg.CORBA.ValueMemberDefHelper.narrow(contained);
102         setType(getRepository().getAsTypeRef(value_member_def_.type_def()));
103         access_ = value_member_def_.access();
104         super.load(contained);
105     }
106
107     // ==================================================================
108
//
109
// Methods for the Declaration interface.
110
//
111
// ==================================================================
112

113     /**
114      ** Create the value member declaration into the IFR.
115      **/

116     public void
117     create()
118     {
119         // Create a ValueMemberDef into the IFR.
120
value_member_def_ = the_parent_.getExtValueDef().create_value_member(getId(),
121                                                                              getName(),
122                                                                              getVersion(),
123                                                                              type_.getIDLType(),
124                                                                              access_);
125
126         super.create();
127     }
128
129     /**
130      ** Obtain the declaration external dependencies.
131      ** Note: for scopes, contained objects are not considered
132      ** as dependencies.
133      **
134      ** @return The list of dependencies as an array of Declaration.
135      **/

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

163     /**
164      ** Set the type.
165      **
166      ** @param type The type reference of the value member.
167      **/

168     public void
169     setType(TypeRef type)
170     {
171         if(type != null)
172         {
173             type_ = type;
174             type_.addRef();
175         }
176     }
177
178     /**
179      ** Set as private.
180      **/

181     public void
182     setPrivate()
183     {
184         access_ = (short)0;
185     }
186
187     /**
188      ** Set as public.
189      **/

190     public void
191     setPublic()
192     {
193         access_ = (short)1;
194     }
195
196     /**
197      **
198      **/

199     public TypeRef
200     getType()
201     {
202         return type_;
203     }
204
205     /**
206      **
207      **/

208     public boolean
209     isPrivate()
210     {
211         return access_==(short)0;
212     }
213
214     // ==================================================================
215
//
216
// Methods for the inherited DeclarationImpl class.
217
//
218
// ==================================================================
219

220     /**
221      **
222      **/

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

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