KickJava   Java API By Example, From Geeks To Geeks.

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


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.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** Used to access AST InterfaceDecl. */
30 import org.objectweb.openccm.ast.api.InterfaceDecl;
31
32 /** Used to access AST OperationDecl. */
33 import org.objectweb.openccm.ast.api.OperationDecl;
34
35 /**
36  * InterfacePortDeclImpl is a wrapper class for
37  * IDL interface port declarations.
38  *
39  * Inherits from:
40  * - DeclarationImpl as provides are declarations,
41  * - ClientOperationMapping
42  * to obtain the equivalent client operation mapping.
43  *
44  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
45  *
46  * @version 0.1
47  */

48
49 public abstract class InterfacePortDeclImpl
50                 extends DeclarationImpl
51                 implements org.objectweb.openccm.ast.api.InterfacePortDecl
52 {
53     // ==================================================================
54
//
55
// Internal state.
56
//
57
// ==================================================================
58

59     /** The port interface type. */
60     protected InterfaceDeclImpl interface_;
61
62     /** Client operation mapping. */
63     protected OperationDecl[] client_mapping_;
64
65     /** The local interface mapping. **/
66     private InterfaceDeclImpl local_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 provides declaration.
79      */

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

98     // ==================================================================
99
//
100
// Public methods.
101
//
102
// ==================================================================
103

104     // ==================================================================
105
//
106
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
107
//
108
// ==================================================================
109

110     // ==================================================================
111
//
112
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
113
//
114
// ==================================================================
115

116     // ==================================================================
117
//
118
// Methods for OMG IDL org.objectweb.openccm.ast.api.InterfacePortDecl
119
//
120
// ==================================================================
121

122     /**
123      * Set the associated InterfaceDecl.
124      *
125      * @param itf The associated InterfaceDecl.
126      */

127     public void
128     setInterface(InterfaceDecl itf)
129     {
130         if(itf != null)
131         {
132             interface_ = (InterfaceDeclImpl)itf;
133         }
134     }
135
136     /**
137      * Obtain the associated InterfaceDecl.
138      *
139      * @return The associated InterfaceDecl.
140      */

141     public InterfaceDecl
142     getInterface()
143     {
144         return interface_;
145     }
146
147     /**
148      * Obtain the local mapping. (CCM_<name> interface)
149      *
150      * @return The local consumer mapping.
151      */

152     public InterfaceDecl
153     getLocalMapping()
154     {
155         if (local_mapping_==null)
156         {
157             // load the local consumer mapping for this event.
158
String JavaDoc parent_base_id = getInterface().getParent().getId();
159             int idx = parent_base_id.lastIndexOf(':');
160             parent_base_id = parent_base_id.substring(0, idx);
161             String JavaDoc id = parent_base_id + "/CCM_" + getInterface().getName() + ":" + getVersion();
162             local_mapping_ = (InterfaceDeclImpl)getRepository().loadMapping(getInterface().getParent(), id);
163         }
164         return local_mapping_;
165     }
166 }
167
Popular Tags