KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gcc > generator > JCatchStatement


1 /*
2  * Copyright 2004 The Apache Software Foundation or its licensors, as
3  * applicable.
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
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19 package gcc.generator;
20
21 public class JCatchStatement extends JBlockStatement
22 {
23     protected JVariable _var;
24
25     public JCatchStatement( JVariable v )
26     {
27         super();
28         _var = v;
29     }
30
31     public JVariable getVariable()
32     {
33         return _var;
34     }
35
36     public int hashCode()
37     {
38         return _var.hashCode();
39     }
40
41     public boolean equals( Object other )
42     {
43         boolean rc = false;
44
45         if (this == other)
46         {
47             rc = true;
48         }
49         else if (other instanceof JCatchStatement)
50         {
51             JCatchStatement cs = (JCatchStatement)other;
52
53             if (cs._var.getType().equals(_var.getType()))
54             {
55                 rc = true;
56             }
57         }
58         else if (other instanceof JVariable)
59         {
60             JVariable v = (JVariable)other;
61
62             if (v.getType().equals( _var.getType() ))
63             {
64                 rc = true;
65             }
66         }
67
68
69         return rc;
70     }
71 }
72
73 /*
74 public class JCatchStatement extends JStatement
75 {
76     protected JVariable _var;
77     protected JBlockStatement _statements;
78
79     public JCatchStatement( JVariable v )
80     {
81         _var = v;
82         _statements = new JBlockStatement();
83     }
84
85     public void addStatement( JStatement s )
86     {
87         _statements.addStatement( s );
88     }
89
90     public JBlockStatement getStatement()
91     {
92         return _statements;
93     }
94
95     public JVariable getVariable()
96     {
97         return _var;
98     }
99
100     public int hashCode()
101     {
102         return _var.hashCode();
103     }
104
105     public boolean equals( Object other )
106     {
107         boolean rc = false;
108
109         if (this == other)
110         {
111             rc = true;
112         }
113         else if (other instanceof JCatchStatement)
114         {
115             JCatchStatement cs = (JCatchStatement)other;
116
117             if (cs._var.getType().equals(_var.getType()))
118             {
119                 rc = true;
120             }
121         }
122         else if (other instanceof JVariable)
123         {
124             JVariable v = (JVariable)other;
125
126             if (v.getType().equals( _var.getType() ))
127             {
128                 rc = true;
129             }
130         }
131
132
133         return rc;
134     }
135 }
136
137 */
Popular Tags