KickJava   Java API By Example, From Geeks To Geeks.

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


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 scopes with forward declaration.
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 abstract public class ForwardScopeImpl
39                 extends ScopeImpl
40                 implements ForwardScope
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /**
49      ** Is it forward?
50      **/

51     private boolean forward_;
52
53     /**
54      ** Is it completed?
55      **/

56     private boolean completed_;
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 forward declaration.
68      **/

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

86     /**
87      ** Create the container object.
88      **/

89     abstract protected void
90     createContainer();
91
92     /**
93      ** Complete the container object.
94      **/

95     abstract protected void
96     completeContainer();
97
98     // ==================================================================
99
//
100
// Methods for the Declaration interface.
101
//
102
// ==================================================================
103

104     /**
105      ** Create the interface declaration into the IFR.
106      **/

107     public void
108     create()
109     {
110         if (getContainer() == null)
111         {
112             createContainer();
113             if (the_parent_!=null)
114                 the_parent_.addDecl(this);
115
116             completed_ = !forward_;
117         }
118         else
119         {
120             if(forward_)
121                  return;
122
123             if(completed_)
124             {
125                 throw new org.omg.CORBA.BAD_PARAM JavaDoc(
126                          org.objectweb.openccm.ir3.SystemExceptionMinorValues.NameAlreadyUsed,
127                          org.omg.CORBA.CompletionStatus.COMPLETED_NO);
128             }
129             else
130             {
131                 completeContainer();
132                 completed_ = true;
133
134                 // move it in the same container to have the good order
135
getContained().move(the_parent_.getContainer(), getName(), getVersion());
136             }
137         }
138     }
139
140     // ==================================================================
141
//
142
// Methods for the ForwardScope interface.
143
//
144
// ==================================================================
145

146     /**
147      ** Is it a forward declaration?
148      **
149      ** @return True if it's a forward declaration, false otherwise.
150      **/

151     public boolean
152     isForward()
153     {
154         return forward_;
155     }
156
157     /**
158      ** Set as forward.
159      **
160      ** @param f True to set the declaration as a forward declaration,
161      ** false otherwise.
162      **/

163     public void
164     setForward(boolean f)
165     {
166         forward_ = f;
167     }
168
169     /**
170      ** Is it a completed declaration?
171      **
172      ** @return True if the declaration is complete, false otherwise.
173      **/

174     public boolean
175     isCompleted()
176     {
177         return completed_;
178     }
179 }
180
Popular Tags