KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
30  * ForwardScopeImpl is a wrapper class for Scopes
31  * which can be defined as forward.
32  *
33  * Inherits from:
34  * - ScopeImpl as forward scopes are also IDL scopes.
35  *
36  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
37  *
38  * @version 0.1
39  */

40
41 abstract public class ForwardScopeImpl
42               extends ScopeImpl
43            implements org.objectweb.openccm.ast.api.ForwardScope
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** Is it forward declared scope? */
52     private boolean forward_;
53
54     /** Is it completed? */
55     private boolean completed_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /**
64      * The constructor with the parent scope.
65      *
66      * @param rep The repository of the declaration.
67      * @param parent The parent scope of the forward declaration.
68      */

69     protected
70     ForwardScopeImpl(Repository rep,
71                      ScopeImpl parent)
72     {
73         // Call the ScopeImpl constructor.
74
super(rep, parent);
75
76         // Init internal state.
77
forward_ = false;
78         completed_ = false;
79     }
80
81     // ==================================================================
82
//
83
// Internal methods for DeclarationImpl.
84
//
85
// ==================================================================
86

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

92     protected void
93     load(org.omg.CORBA.Contained JavaDoc contained)
94     {
95         completed_ = true;
96         super.load(contained);
97     }
98
99     /**
100      * Loads infos of the CORBA 3.0 ValueDef.
101      *
102      * @param contained The ValueDef to load.
103      */

104     protected void
105     loadAsMapping(org.omg.CORBA.Contained JavaDoc contained)
106     {
107         completed_ = true;
108         super.loadAsMapping(contained);
109     }
110
111     // ==================================================================
112
//
113
// Internal methods.
114
//
115
// ==================================================================
116

117     /**
118      * Tests if this forward declaration is already created.
119      *
120      * @return True if it is already created else false.
121      */

122     abstract public boolean
123     isForwardCreated();
124  
125     /**
126      * Create this forward declaration.
127      */

128     abstract public void
129     createForward();
130
131     /**
132      * Complete this forward declaration.
133      */

134     abstract public void
135     completeForward();
136
137     // ==================================================================
138
//
139
// Public methods.
140
//
141
// ==================================================================
142

143     // ==================================================================
144
//
145
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
146
//
147
// ==================================================================
148

149     /**
150      * Create the declaration.
151      */

152     public void
153     create()
154     {
155         if (!isForwardCreated())
156         {
157             if (the_parent_!=null)
158                 the_parent_.addDecl(this);
159
160             completed_ = false;
161
162             createForward();
163
164             // Why this?
165
// completed_ = !forward_;
166
}
167         else
168         {
169             if(forward_)
170                 return;
171
172             if(completed_)
173             {
174                 throw new org.omg.CORBA.BAD_PARAM JavaDoc(
175                          org.objectweb.openccm.ir3.SystemExceptionMinorValues.NameAlreadyUsed,
176                          org.omg.CORBA.CompletionStatus.COMPLETED_NO);
177             }
178             else
179             {
180                 completeForward();
181                 completed_ = true;
182             }
183         }
184     }
185
186     // ==================================================================
187
//
188
// Methods for OMG IDL org.objectweb.openccm.ast.api.Scope
189
//
190
// ==================================================================
191

192     // ==================================================================
193
//
194
// Methods for OMG IDL org.objectweb.openccm.ast.api.ForwardScope
195
//
196
// ==================================================================
197

198     /**
199      * Is it a forward declaration?
200      *
201      * @return True if it's a forward declaration, false otherwise.
202      */

203     public boolean
204     isForward()
205     {
206         return forward_;
207     }
208
209     /**
210      * Set as forward.
211      *
212      * @param f True to set the declaration as a forward declaration,
213      * false otherwise.
214      */

215     public void
216     setForward(boolean f)
217     {
218         forward_ = f;
219     }
220
221     /**
222      * Is it a completed declaration?
223      *
224      * @return True if the declaration is complete, false otherwise.
225      */

226     public boolean
227     isCompleted()
228     {
229         return completed_;
230     }
231 }
232
Popular Tags