KickJava   Java API By Example, From Geeks To Geeks.

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


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 /** Used to access AST Declaration. */
30 import org.objectweb.openccm.ast.api.Declaration;
31
32 /** Used to access AST OperationDecl. */
33 import org.objectweb.openccm.ast.api.OperationDecl;
34
35 /** Used to access AST EventDecl. */
36 import org.objectweb.openccm.ast.api.EventDecl;
37
38 /**
39  * EventPortDeclImpl is a wrapper class for IDL event port declarations.
40  *
41  * Inherits from:
42  * - DeclarationImpl as these are declarations,
43  * - ClientOperationMapping
44  * to obtain the equivalent client operation mapping.
45  *
46  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
47  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
48  *
49  * @version 0.3
50  */

51
52 abstract public class EventPortDeclImpl
53                 extends DeclarationImpl
54                 implements org.objectweb.openccm.ast.api.EventPortDecl
55 {
56     // ==================================================================
57
//
58
// Internal state.
59
//
60
// ==================================================================
61

62     /** The port event type. */
63     protected EventDeclImpl event_;
64
65     /** Client operation mapping. */
66     protected OperationDecl[] client_mapping_;
67
68     // ==================================================================
69
//
70
// Constructor.
71
//
72
// ==================================================================
73

74     /**
75      * The constructor with the parent scope.
76      *
77      * @param rep The repository of the declaration.
78      * @param parent The parent scope of the event declaration.
79      */

80     protected
81     EventPortDeclImpl(Repository rep,
82                       ScopeImpl parent)
83     {
84         // Call the DeclarationImpl constructor.
85
super(rep, parent);
86
87         // Init internal state.
88
event_ = null;
89         client_mapping_ = null;
90     }
91
92     // ==================================================================
93
//
94
// Internal methods.
95
//
96
// ==================================================================
97

98     // ==================================================================
99
//
100
// Internal methods for DeclarationImpl.
101
//
102
// ==================================================================
103

104     /**
105      * Loads infos of the CORBA 3.0 EventDef.
106      *
107      * @param contained The EventDef to load.
108      */

109     protected void
110     load(org.omg.CORBA.Contained JavaDoc contained)
111     {
112         org.omg.CORBA.ComponentIR.EventPortDef event_port =
113             org.omg.CORBA.ComponentIR.EventPortDefHelper.narrow(contained);
114         setEvent((EventDecl)getRepository().lookupId(event_port.event().id()));
115         super.load(contained);
116     }
117
118     // ==================================================================
119
//
120
// Public methods.
121
//
122
// ==================================================================
123

124     // ==================================================================
125
//
126
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
127
//
128
// ==================================================================
129

130     /**
131      * Obtain the declaration external dependencies.
132      *
133      * Note: for scopes, contained objects are not considered
134      * as dependencies.
135      *
136      * @return The list of dependencies as an array of Declaration.
137      */

138     public Declaration[]
139     getDependencies()
140     {
141         if (dependencies_!=null)
142             return dependencies_;
143
144         java.util.List JavaDoc events_depend = new java.util.ArrayList JavaDoc();
145
146         // content
147
// TODO: The next test is not needed
148
// as EventDecl is a Declaration, isn't it?
149
if (getEvent().isDeclaration())
150             events_depend.add(getEvent());
151
152         Declaration[] depend = getEvent().getDependencies();
153         for (int i=0;i<depend.length;i++)
154             events_depend.add(depend[i]);
155
156         dependencies_ = (Declaration[])events_depend.toArray(
157                                           new Declaration[0]);
158         return dependencies_;
159     }
160
161     // ==================================================================
162
//
163
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
164
//
165
// ==================================================================
166

167     // ==================================================================
168
//
169
// Methods for OMG IDL org.objectweb.openccm.ast.api.EventPortDecl
170
//
171
// ==================================================================
172

173     /**
174      * Set the event value type.
175      *
176      * @param event The EventDecl of the event.
177      */

178     public void
179     setEvent(EventDecl event)
180     {
181         if (event != null)
182         {
183             event_ = (EventDeclImpl)event;
184         }
185     }
186
187     /**
188      * Obtain the event value type.
189      *
190      * @return The EventDecl of the event.
191      */

192     public EventDecl
193     getEvent()
194     {
195         return event_;
196     }
197 }
198
Popular Tags