KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > interop > generator > JMethod


1 /**
2  *
3  * Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.geronimo.interop.generator;
19
20 import java.lang.reflect.Modifier JavaDoc;
21 import java.util.Vector JavaDoc;
22
23 public class JMethod extends JEntity {
24     private JReturnType rt;
25     private JParameter parms[];
26     private Class JavaDoc thrown[];
27     private Vector JavaDoc statements;
28     private JBlockStatement bodyBlockStatement;
29     private String JavaDoc body; // Yuck
30

31     protected JMethod(String JavaDoc name) {
32         super(name, Modifier.PUBLIC);
33
34         statements = new Vector JavaDoc();
35         bodyBlockStatement = new JBlockStatement();
36     }
37
38     protected JMethod(JReturnType rt, String JavaDoc name, JParameter parms[], Class JavaDoc thrown[]) {
39         this(name);
40
41         setRT(rt);
42         setParms(parms);
43         setThrown(thrown);
44     }
45
46     public void setRT(JReturnType jt) {
47         rt = jt;
48     }
49
50     public JReturnType getRT() {
51         return rt;
52     }
53
54     public void setParms(JParameter parms[]) {
55         this.parms = parms;
56     }
57
58     public JParameter[] getParms() {
59         return parms;
60     }
61
62     public void setThrown(Class JavaDoc thrown[]) {
63         this.thrown = thrown;
64     }
65
66     public Class JavaDoc[] getThrown() {
67         return thrown;
68     }
69
70     public void setBody(String JavaDoc body) {
71         this.body = body;
72     }
73
74     public String JavaDoc getBody() {
75         return body;
76     }
77
78     public JLocalVariable newLocalVariable(Class JavaDoc type, String JavaDoc name) {
79         return bodyBlockStatement.newLocalVariable(type, name);
80     }
81
82     public JLocalVariable newLocalVariable(Class JavaDoc type, String JavaDoc name, JExpression initExpr) {
83         return bodyBlockStatement.newLocalVariable(type, name, initExpr);
84     }
85
86     public void deleteLocalVariable(JLocalVariable f) {
87         bodyBlockStatement.deleteLocalVariable(f);
88     }
89
90     public Vector JavaDoc getLocalVariables() {
91         return bodyBlockStatement.getLocalVariables();
92     }
93
94     public void addStatement(JStatement s) {
95         statements.add(s);
96     }
97
98     public Vector JavaDoc getStatements() {
99         return statements;
100     }
101 }
102
Popular Tags