KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > generator > java > ast > lib > MethodObjectImpl


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

26
27 package org.objectweb.openccm.generator.java.ast.lib;
28
29 import org.objectweb.openccm.generator.java.ast.api.MethodObject;
30 import org.objectweb.openccm.generator.java.ast.api.AbstractObject;
31 import org.objectweb.openccm.generator.java.ast.api.StaticObject;
32 import org.objectweb.openccm.generator.java.ast.api.AttributeObject;
33 import org.objectweb.openccm.generator.java.ast.api.MethodContent;
34 import java.util.ArrayList JavaDoc;
35
36 /**
37  * This is the representation for java Methodes.
38  *
39  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</A>
40  */

41
42 public class MethodObjectImpl
43      extends ObjectBaseImpl
44   implements MethodObject
45 {
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51

52     /** The delegation for an abstract */
53     private AbstractObject abstract_delegate_;
54
55     /** The delegation for a static */
56     private StaticObject static_delegate_;
57
58     /** The return type */
59     private AttributeObject return_type_;
60
61     /** Method parameters */
62     private ArrayList JavaDoc parameters_;
63
64     /** Method exceptions */
65     private ArrayList JavaDoc exceptions_;
66
67     /** Method implementation */
68     private MethodContent impl_;
69
70     // ==================================================================
71
//
72
// Constructor.
73
//
74
// ==================================================================
75

76     /** The default constructor. */
77     public
78     MethodObjectImpl()
79     {
80         // Init internal states
81
super();
82         abstract_delegate_ = new AbstractObjectImpl();
83         static_delegate_ = new StaticObjectImpl();
84         return_type_ = null;
85         parameters_ = new ArrayList JavaDoc();
86         exceptions_ = new ArrayList JavaDoc();
87         impl_ = new MethodContentImpl();
88     }
89
90     // ==================================================================
91
//
92
// Internal methods.
93
//
94
// ==================================================================
95

96     // ==================================================================
97
//
98
// Public methods.
99
//
100
// ==================================================================
101

102     // ==================================================================
103
//
104
// Methods for org.objectweb.openccm.generator.java.ast.api.AbstractObject
105
//
106
// ==================================================================
107

108     /**
109      * Set abstract this object.
110      *
111      * @param b - The value to set.
112      */

113     public void
114     setAbstract(boolean b)
115     {
116         abstract_delegate_.setAbstract(b);
117     }
118
119     /**
120      * Is this object abstract ?
121      *
122      * @return True if it is abstract, else false.
123      */

124     public boolean
125     isAbstract()
126     {
127         return abstract_delegate_.isAbstract();
128     }
129
130     // ==================================================================
131
//
132
// Methods for org.objectweb.openccm.generator.java.ast.api.StaticObject
133
//
134
// ==================================================================
135

136     /**
137      * Set static this object.
138      *
139      * @param b - The value to set.
140      */

141     public void
142     setStatic(boolean b)
143     {
144         static_delegate_.setStatic(b);
145     }
146
147     /**
148      * Is this object static ?
149      *
150      * @return True if it is static, else false.
151      */

152     public boolean
153     isStatic()
154     {
155         return static_delegate_.isStatic();
156     }
157
158     // ==================================================================
159
//
160
// Methods for org.objectweb.openccm.generator.java.ast.api.MethodObject
161
//
162
// ==================================================================
163

164     /**
165      * Set its return type.
166      *
167      * @param type - The type to set.
168      */

169     public void
170     setReturnType(String JavaDoc type)
171     {
172         return_type_ = new AttributeObjectImpl();
173         return_type_.setType(type);
174     }
175
176     /**
177      * Obtain its name.
178      *
179      * @return Its name.
180      */

181     public AttributeObject
182     getReturnType()
183     {
184         return return_type_;
185     }
186
187     /**
188      * Add a parameter.
189      *
190      * @param param - The parameter to add.
191      */

192     public void
193     addParameter(AttributeObject param)
194     {
195         parameters_.add(param);
196     }
197
198     /**
199      * Obtain all parameters.
200      *
201      * @return A list of parameters.
202      */

203     public ArrayList JavaDoc
204     getParameters()
205     {
206         return parameters_;
207     }
208
209     /**
210      * Obtain its implementation.
211      *
212      * @return Its implementation.
213      */

214     public MethodContent
215     getImpl()
216     {
217         return impl_;
218     }
219
220     /**
221      * Add an exception.
222      *
223      * @param ex - The exception to add.
224      */

225     public void
226     addException(String JavaDoc ex)
227     {
228         exceptions_.add(ex);
229     }
230
231     /**
232      * Obtain all exceptions.
233      *
234      * @return A list of exceptions.
235      */

236     public ArrayList JavaDoc
237     getExceptions()
238     {
239         return exceptions_;
240     }
241 }
242
Popular Tags