KickJava   Java API By Example, From Geeks To Geeks.

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


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 reference an AST TypeRef. */
30 import org.objectweb.openccm.ast.api.TypeRef;
31
32 /** Used to access AST Declaration. */
33 import org.objectweb.openccm.ast.api.Declaration;
34
35 /**
36  * TypeRefWithContentImpl is a wrapper for sequence and array IDL types.
37  *
38  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
39  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
40  *
41  * @version 0.1
42  */

43
44 public class TypeRefWithContentImpl
45        extends TypeRefWithLengthImpl
46        implements org.objectweb.openccm.ast.api.TypeRefWithContent
47 {
48     // ==================================================================
49
//
50
// Internal state.
51
//
52
// ==================================================================
53

54     /** Associated content for sequence and array types. */
55     private TypeRef content_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /**
64      * The constructor.
65      *
66      * @param type The IDLType that should be referenced.
67      * @param kind The associated type kind.
68      * @param length The associated length.
69      * @param content The associated content type.
70      */

71     protected
72     TypeRefWithContentImpl(org.omg.CORBA.IDLType JavaDoc type,
73                            org.objectweb.openccm.ast.api.TypeKind kind,
74                            int length,
75                            TypeRef content)
76     {
77         // Call the TypeRefWithLengthImpl constructor.
78
super(type, kind, length);
79
80         // Init internal state.
81
content_ = content;
82     }
83
84     // ==================================================================
85
//
86
// Internal methods.
87
//
88
// ==================================================================
89

90     // ==================================================================
91
//
92
// Public methods.
93
//
94
// ==================================================================
95

96     // ==================================================================
97
//
98
// Methods for OMG IDL org.objectweb.openccm.ast.api.TypeRef
99
//
100
// ==================================================================
101

102     /**
103      * Obtain the external Declaration dependencies.
104      *
105      * @return The list of Declaration dependencies.
106      */

107     public Declaration[]
108     getDependencies()
109     {
110         if (dependencies_!=null)
111             return dependencies_;
112
113         if (content_.isDeclaration())
114         {
115             Declaration[] depend = content_.getDependencies();
116             Declaration[] depend2 = new Declaration[1+depend.length];
117             for (int i=0;i<depend.length;i++)
118                 depend2[i] = depend[i];
119
120             depend2[depend.length] = (Declaration)content_;
121             dependencies_ = depend2;
122         }
123         else
124             dependencies_ = content_.getDependencies();
125
126         return dependencies_;
127     }
128
129     // ==================================================================
130
//
131
// Methods for OMG IDL org.objectweb.openccm.ast.api.TypeRefWithContent
132
//
133
// ==================================================================
134

135     /**
136      * Set the contained type.
137      *
138      * @param type The contained type.
139      */

140     public void
141     setContentType(TypeRef content)
142     {
143         content_ = content;
144     }
145
146     /**
147      * Obtain the contained type.
148      *
149      * @return The contained type.
150      */

151     public TypeRef
152     getContentType()
153     {
154         return content_;
155     }
156 }
157
Popular Tags