|
1 |
| package edu.rice.cs.javalanglevels.tree; |
|
2 |
| |
|
3 |
| import edu.rice.cs.javalanglevels.SourceInfo; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| public class CatchBlock extends JExpression { |
|
11 |
| private final FormalParameter _exception; |
|
12 |
| private final Block _block; |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
22
| public CatchBlock(SourceInfo in_sourceInfo, FormalParameter in_exception, Block in_block) {
|
|
19 |
22
| super(in_sourceInfo);
|
|
20 |
| |
|
21 |
22
| if (in_exception == null) {
|
|
22 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'exception' to the CatchBlock constructor was null. This class may not have null field values.");
|
|
23 |
| } |
|
24 |
22
| _exception = in_exception;
|
|
25 |
| |
|
26 |
22
| if (in_block == null) {
|
|
27 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'block' to the CatchBlock constructor was null. This class may not have null field values.");
|
|
28 |
| } |
|
29 |
22
| _block = in_block;
|
|
30 |
| } |
|
31 |
| |
|
32 |
122
| final public FormalParameter getException() { return _exception; }
|
|
33 |
48
| final public Block getBlock() { return _block; }
|
|
34 |
| |
|
35 |
36
| public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forCatchBlock(this); }
|
|
36 |
0
| public void visit(JExpressionIFVisitor_void visitor) { visitor.forCatchBlock(this); }
|
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
0
| public java.lang.String toString() {
|
|
43 |
0
| java.io.StringWriter w = new java.io.StringWriter();
|
|
44 |
0
| output(w);
|
|
45 |
0
| return w.toString();
|
|
46 |
| } |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
0
| public void output(java.io.Writer writer) {
|
|
52 |
0
| outputHelp(new TabPrintWriter(writer, 2));
|
|
53 |
| } |
|
54 |
| |
|
55 |
2
| public void outputHelp(TabPrintWriter writer) {
|
|
56 |
2
| writer.print("CatchBlock" + ":");
|
|
57 |
2
| writer.indent();
|
|
58 |
| |
|
59 |
2
| writer.startLine("");
|
|
60 |
2
| writer.print("sourceInfo = ");
|
|
61 |
2
| SourceInfo temp_sourceInfo = getSourceInfo();
|
|
62 |
2
| if (temp_sourceInfo == null) {
|
|
63 |
0
| writer.print("null");
|
|
64 |
| } else { |
|
65 |
2
| writer.print(temp_sourceInfo);
|
|
66 |
| } |
|
67 |
| |
|
68 |
2
| writer.startLine("");
|
|
69 |
2
| writer.print("exception = ");
|
|
70 |
2
| FormalParameter temp_exception = getException();
|
|
71 |
2
| if (temp_exception == null) {
|
|
72 |
0
| writer.print("null");
|
|
73 |
| } else { |
|
74 |
2
| temp_exception.outputHelp(writer);
|
|
75 |
| } |
|
76 |
| |
|
77 |
2
| writer.startLine("");
|
|
78 |
2
| writer.print("block = ");
|
|
79 |
2
| Block temp_block = getBlock();
|
|
80 |
2
| if (temp_block == null) {
|
|
81 |
0
| writer.print("null");
|
|
82 |
| } else { |
|
83 |
2
| temp_block.outputHelp(writer);
|
|
84 |
| } |
|
85 |
2
| writer.unindent();
|
|
86 |
| } |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
4
| public boolean equals(java.lang.Object obj) {
|
|
94 |
0
| if (obj == null) return false;
|
|
95 |
4
| if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
|
|
96 |
0
| return false;
|
|
97 |
| } else { |
|
98 |
4
| CatchBlock casted = (CatchBlock) obj;
|
|
99 |
0
| if (! (getException().equals(casted.getException()))) return false;
|
|
100 |
0
| if (! (getBlock().equals(casted.getBlock()))) return false;
|
|
101 |
4
| return true;
|
|
102 |
| } |
|
103 |
| } |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
2
| protected int generateHashCode() {
|
|
112 |
2
| int code = getClass().hashCode();
|
|
113 |
2
| code ^= 0;
|
|
114 |
2
| code ^= getException().hashCode();
|
|
115 |
2
| code ^= getBlock().hashCode();
|
|
116 |
2
| return code;
|
|
117 |
| } |
|
118 |
| } |