KickJava   Java API By Example, From Geeks To Geeks.

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


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 events port 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 abstract public class EventsDeclImpl
39                 extends DeclarationImpl
40                 implements EventsDecl
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /**
49      ** The port value type.
50      **/

51     protected EventDeclImpl event_;
52
53     // ==================================================================
54
//
55
// Constructor.
56
//
57
// ==================================================================
58

59     /**
60      ** The constructor with the parent scope.
61      **
62      ** @param parent The parent scope of the event declaration.
63      **/

64     protected
65     EventsDeclImpl(Repository rep, ScopeImpl parent)
66     {
67         // Call the DeclarationImpl constructor.
68
super(rep, parent);
69
70         // Init internal state.
71
event_ = null;
72     }
73
74     // ==================================================================
75
//
76
// Public methods for the import statement.
77
//
78
// ==================================================================
79

80     /**
81      ** Loads infos of the CORBA 3.0 EventDef.
82      **
83      ** @param eventDef The EventDef to load.
84      **/

85     protected void
86     load(org.omg.CORBA.Contained JavaDoc contained)
87     {
88         org.omg.CORBA.ComponentIR.EventPortDef event_port =
89             org.omg.CORBA.ComponentIR.EventPortDefHelper.narrow(contained);
90         setEvent((EventRef)getRepository().lookupId(event_port.event().id()));
91         super.load(contained);
92     }
93
94     // ==================================================================
95
//
96
// Methods for the Declaration interface.
97
//
98
// ==================================================================
99

100     /**
101      ** Obtain the declaration external dependencies.
102      ** Note: for scopes, contained objects are not considered
103      ** as dependencies.
104      **
105      ** @return The list of dependencies as an array of Declaration.
106      **/

107     public Declaration[]
108     getDependencies()
109     {
110         if (dependencies_!=null)
111             return dependencies_;
112
113         org.objectweb.ccm.util.Vector events_depend = new org.objectweb.ccm.util.Vector();
114
115         // content
116
if (getType().isDeclaration())
117             events_depend.add(getType());
118
119         Declaration[] depend = getType().getDependencies();
120         for (int i=0;i<depend.length;i++)
121             events_depend.add(depend[i]);
122
123
124         dependencies_ = (Declaration[])events_depend.toArray(new Declaration[0]);
125         return dependencies_;
126     }
127
128     // ==================================================================
129
//
130
// Methods for the EventsDecl interface.
131
//
132
// ==================================================================
133

134     /**
135      ** Set the event value type.
136      **
137      ** @param value The EventRef of the event.
138      **/

139     public void
140     setEvent(EventRef event)
141     {
142         if (event != null)
143         {
144             event_ = (EventDeclImpl)event;
145             event_.addRef();
146         }
147     }
148
149     /**
150      **
151      **/

152     public TypeRef
153     getType()
154     {
155         return event_;
156     }
157
158     // ==================================================================
159
//
160
// Methods for the inherited DeclarationImpl class.
161
//
162
// ==================================================================
163

164     /**
165      **
166      **/

167     public void
168     destroy()
169     {
170         if (event_!=null)
171             event_.removeRef();
172     }
173 }
174
Popular Tags