01: /* Generated By:JJTree: Do not edit this line. ASTLocalVariableDeclaration.java */
02: package net.sourceforge.pmd.ast;
03:
04: public class ASTLocalVariableDeclaration extends AccessNode implements
05: Dimensionable {
06:
07: public ASTLocalVariableDeclaration(int id) {
08: super (id);
09: }
10:
11: public ASTLocalVariableDeclaration(JavaParser p, int id) {
12: super (p, id);
13: }
14:
15: /**
16: * Accept the visitor. *
17: */
18: public Object jjtAccept(JavaParserVisitor visitor, Object data) {
19: return visitor.visit(this , data);
20: }
21:
22: public boolean isArray() {
23: return checkType() + checkDecl() > 0;
24: }
25:
26: public int getArrayDepth() {
27: if (!isArray()) {
28: return 0;
29: }
30: return checkType() + checkDecl();
31: }
32:
33: private int checkType() {
34: if (jjtGetNumChildren() == 0
35: || !(jjtGetChild(0) instanceof ASTType)) {
36: return 0;
37: }
38: return ((ASTType) jjtGetChild(0)).getArrayDepth();
39: }
40:
41: private int checkDecl() {
42: if (jjtGetNumChildren() < 2
43: || !(jjtGetChild(1) instanceof ASTVariableDeclarator)) {
44: return 0;
45: }
46: return ((ASTVariableDeclaratorId) (jjtGetChild(1)
47: .jjtGetChild(0))).getArrayDepth();
48: }
49:
50: public void dump(String prefix) {
51: String out = "";
52: if (isArray()) {
53: out += "(array";
54: for (int i = 0; i < getArrayDepth(); i++) {
55: out += "[";
56: }
57: out += ")";
58: }
59: if (isFinal()) {
60: out += "(final)";
61: }
62: System.out.println(toString(prefix) + out);
63: dumpChildren(prefix);
64: }
65: }
|