KickJava   Java API By Example, From Geeks To Geeks.

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


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 box 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 ValueBoxDeclImpl
39        extends DeclarationImpl
40        implements TypeRef, ValueBoxDecl
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

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

51     private org.omg.CORBA.ValueBoxDef JavaDoc value_box_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 value box declaration.
68      **/

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

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

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

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

119     /**
120      ** Create the value box declaration into the IFR.
121      **/

122     public void
123     create()
124     {
125         value_box_def_ = the_parent_.getContainer().create_value_box(getId(),
126                                                                      getName(),
127                                                                      getVersion(),
128                                                                      original_type_.getIDLType());
129
130         super.create();
131     }
132
133     /**
134      ** Obtain the declaration external dependencies.
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         org.objectweb.ccm.util.Vector vbox_depend = new org.objectweb.ccm.util.Vector();
147
148         // content
149
if (getType().isDeclaration())
150             vbox_depend.add(getType());
151
152         Declaration[] depend = getType().getDependencies();
153         for (int i=0;i<depend.length;i++)
154             vbox_depend.add(depend[i]);
155
156
157         dependencies_ = (Declaration[])vbox_depend.toArray(new Declaration[0]);
158         return dependencies_;
159     }
160
161     // ==================================================================
162
//
163
// Methods for the TypeRef interface.
164
//
165
// ==================================================================
166

167     /**
168      ** Obtain its IDLType reference.
169      **
170      ** @return The IDLType associated with the value box declaration.
171      **/

172     public org.omg.CORBA.IDLType JavaDoc
173     getIDLType()
174     {
175         return value_box_def_;
176     }
177
178     /**
179      **
180      **/

181     public int
182     getTypeKind()
183     {
184         return TypeKind._tk_value_box;
185     }
186
187     // ==================================================================
188
//
189
// Methods for the ValueBoxDecl interface.
190
//
191
// ==================================================================
192

193     /**
194      ** Set the original type.
195      **
196      ** @param type The original type of the value box declaration.
197      **/

198     public void
199     setType(TypeRef type)
200     {
201         if (type != null)
202         {
203             original_type_ = type;
204             original_type_.addRef();
205         }
206     }
207
208     /**
209      **
210      **/

211     public TypeRef
212     getType()
213     {
214         return original_type_;
215     }
216
217     // ==================================================================
218
//
219
// Methods for the inherited DeclarationImpl class.
220
//
221
// ==================================================================
222

223     /**
224      **
225      **/

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

241     protected org.omg.CORBA.Contained JavaDoc
242     getContained()
243     {
244        return value_box_def_;
245     }
246 }
247
Popular Tags