KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.Vector JavaDoc;
21
22 public class JIfElseIfElseStatement extends JStatement {
23     private JIfStatement ifStatement;
24     private Vector JavaDoc elseifStatements;
25     private JElseStatement elseStatement;
26
27     public JIfElseIfElseStatement(JExpression if_expr) {
28         ifStatement = new JIfStatement(if_expr);
29         elseifStatements = new Vector JavaDoc();
30         elseStatement = new JElseStatement();
31     }
32
33     public void addIfStatement(JStatement s) {
34         ifStatement.addStatement(s);
35     }
36
37     public JIfStatement getIfStatement() {
38         return ifStatement;
39     }
40
41     public Vector JavaDoc getIfStatements() {
42         return ifStatement.getStatements();
43     }
44
45     public void addElseStatement(JStatement s) {
46         elseStatement.addStatement(s);
47     }
48
49     public JElseStatement getElseStatement() {
50         return elseStatement;
51     }
52
53     public Vector JavaDoc getElseStatements() {
54         return elseStatement.getStatements();
55     }
56
57     public JElseIfStatement getElseIf(JExpression e) {
58         JElseIfStatement rc = null;
59         int index = elseifStatements.indexOf(e);
60
61         if (index >= 0) {
62             rc = (JElseIfStatement) elseifStatements.get(index);
63         }
64
65         return rc;
66     }
67
68     public JElseIfStatement newElseIf(JExpression e) {
69         JElseIfStatement rc = getElseIf(e);
70
71         if (rc == null) {
72             rc = new JElseIfStatement(e);
73             elseifStatements.add(rc);
74         }
75
76         return rc;
77     }
78
79     public void addCatchStatement(JExpression e, JStatement s) {
80         JElseIfStatement eis = getElseIf(e);
81
82         if (eis == null) {
83             eis = newElseIf(e);
84         }
85
86         eis.addStatement(s);
87     }
88
89     public Vector JavaDoc getElseIfs() {
90         return elseifStatements;
91     }
92 }
93
Popular Tags