KickJava   Java API By Example, From Geeks To Geeks.

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


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 manipulate CORBA IDLType. */
30 import org.omg.CORBA.IDLType JavaDoc;
31
32 /** Used to access AST TypeKind. */
33 import org.objectweb.openccm.ast.api.TypeKind;
34
35 /** Used to access AST Declaration. */
36 import org.objectweb.openccm.ast.api.Declaration;
37
38 /**
39  * TypeRefImpl is a wrapper to CORBA::IDLType object
40  * provided by the Interface Repository.
41  *
42  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
43  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
44  *
45  * @version 0.3
46  */

47
48 public class TypeRefImpl
49        extends ObjectBase
50        implements IDLTypeWrapper,
51                   org.objectweb.openccm.ast.api.TypeRef
52 {
53     // ==================================================================
54
//
55
// Internal state.
56
//
57
// ==================================================================
58

59     /** Reference to the CORBA::IDLType from the Interface Repository. */
60     private IDLType JavaDoc type_;
61
62     /** Associated AST TypeKind. */
63     private TypeKind kind_;
64
65     /** List of dependencies. */
66     protected Declaration[] dependencies_;
67
68     // ==================================================================
69
//
70
// Constructor.
71
//
72
// ==================================================================
73

74     /**
75      * The constructor.
76      *
77      * @param type The IDLType that should be referenced.
78      * @param kind The associated type kind.
79      */

80     protected
81     TypeRefImpl(IDLType JavaDoc type,
82                 TypeKind kind)
83     {
84         // Init internal state.
85
type_ = type;
86         kind_ = kind;
87         dependencies_ = null;
88     }
89
90     // ==================================================================
91
//
92
// Internal methods.
93
//
94
// ==================================================================
95

96     /**
97      * TODO: Why is it needed?
98      */

99     protected String JavaDoc
100     getId()
101     {
102         if (kind_==TypeKind.tk_objref)
103             return "IDL:omg.org/CORBA/Object:1.0";
104         throw new org.objectweb.openccm.ast.api.ASTError("Bad TypeKind!");
105     }
106
107     // ==================================================================
108
//
109
// Public methods.
110
//
111
// ==================================================================
112

113     // ==================================================================
114
//
115
// Methods for interface IDLTypeWrapper
116
//
117
// ==================================================================
118

119     /**
120      * Obtain its IDLType reference.
121      *
122      * @return The IDLType associated with the type reference.
123      */

124     public IDLType JavaDoc
125     getIDLType()
126     {
127         return type_;
128     }
129
130     // ==================================================================
131
//
132
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
133
//
134
// ==================================================================
135

136     /**
137      * Obtain the external Declaration dependencies.
138      *
139      * @return The list of Declaration dependencies.
140      */

141     public Declaration[]
142     getDependencies()
143     {
144         if (dependencies_!=null)
145             return dependencies_;
146         dependencies_ = new Declaration[0];
147         return dependencies_;
148     }
149
150     // ==================================================================
151
//
152
// Methods for OMG IDL org.objectweb.openccm.ast.api.TypeRef
153
//
154
// ==================================================================
155

156     /**
157      * Obtain its associated TypeKind.
158      *
159      * @return The associated TypeKind.
160      */

161     public TypeKind
162     getTypeKind()
163     {
164         return kind_;
165     }
166
167     /**
168      * Test if this TypeRef is also a Declaration object.
169      *
170      * @return True if it is a Declaration, false otherwise.
171      */

172     public boolean
173     isDeclaration()
174     {
175         return false;
176     }
177
178 }
179
Popular Tags