KickJava   Java API By Example, From Geeks To Geeks.

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


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 JTryCatchFinallyStatement extends JStatement {
23     private JTryStatement tryStatement;
24     private Vector JavaDoc catchStatements;
25     private JFinallyStatement finallyStatement;
26
27     public JTryCatchFinallyStatement() {
28         tryStatement = new JTryStatement();
29         catchStatements = new Vector JavaDoc();
30         finallyStatement = new JFinallyStatement();
31     }
32
33     public void addTryStatement(JStatement s) {
34         tryStatement.addStatement(s);
35     }
36
37     public JTryStatement getTryStatement() {
38         return tryStatement;
39     }
40
41     public JCatchStatement getCatch(JVariable v) {
42         JCatchStatement rc = null;
43         int index = catchStatements.indexOf(v);
44
45         if (index >= 0) {
46             rc = (JCatchStatement) catchStatements.get(index);
47         }
48
49         return rc;
50     }
51
52     public JCatchStatement newCatch(JVariable v) {
53         JCatchStatement rc = getCatch(v);
54
55         if (rc == null) {
56             rc = new JCatchStatement(v);
57             catchStatements.add(rc);
58         }
59
60         return rc;
61     }
62
63     public void addCatchStatement(JVariable v, JStatement s) {
64         JCatchStatement cs = getCatch(v);
65
66         if (cs == null) {
67             cs = newCatch(v);
68         }
69
70         cs.addStatement(s);
71     }
72
73     public Vector JavaDoc getCatches() {
74         return catchStatements;
75     }
76
77     public void addFinallyStatement(JStatement s) {
78         finallyStatement.addStatement(s);
79     }
80
81     public JFinallyStatement getFinallyStatement() {
82         return finallyStatement;
83     }
84 }
85
Popular Tags