1 /* Generated By:JJTree: Do not edit this line. ASTTryStatement.java */
2
3 package net.sourceforge.pmd.ast;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 public class ASTTryStatement extends SimpleNode {
9
10 private boolean hasCatch;
11 private boolean hasFinally;
12
13
14 public ASTTryStatement(int id) {
15 super(id);
16 }
17
18 public ASTTryStatement(JavaParser p, int id) {
19 super(p, id);
20 }
21
22 public void setHasCatch() {
23 hasCatch = true;
24 }
25
26 public void setHasFinally() {
27 hasFinally = true;
28 }
29
30 public boolean hasCatch() {
31 return hasCatch;
32 }
33
34 public boolean hasFinally() {
35 return hasFinally;
36 }
37
38 /***
39 * Call hasFinally() before you call this method
40 */
41 public ASTBlock getFinallyBlock() {
42 return (ASTBlock) jjtGetChild(jjtGetNumChildren() - 1);
43 }
44
45 /***
46 * Call hasCatch() before you call this method
47 */
48 public List getCatchBlocks() {
49 int numChildren = jjtGetNumChildren();
50 if (hasFinally)
51 numChildren--;
52 List blocks = new ArrayList();
53 for (int i = 1; i < numChildren; i += 2) {
54 blocks.add(new ASTCatch((ASTFormalParameter) jjtGetChild(i + 0), (ASTBlock) jjtGetChild(i + 1)));
55 }
56 return blocks;
57 }
58
59 /*** Accept the visitor. **/
60 public Object jjtAccept(JavaParserVisitor visitor, Object data) {
61 return visitor.visit(this, data);
62 }
63 }
This page was automatically generated by Maven