KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > ast > ASTLocalVariableDeclaration


1 /* Generated By:JJTree: Do not edit this line. ASTLocalVariableDeclaration.java */
2
3 package net.sourceforge.pmd.ast;
4
5 import net.sourceforge.pmd.Rule;
6
7 public class ASTLocalVariableDeclaration extends AccessNode implements Dimensionable, CanSuppressWarnings {
8
9     public ASTLocalVariableDeclaration(int id) {
10         super(id);
11     }
12
13     public ASTLocalVariableDeclaration(JavaParser p, int id) {
14         super(p, id);
15     }
16
17     /**
18      * Accept the visitor. *
19      */

20     public Object JavaDoc jjtAccept(JavaParserVisitor visitor, Object JavaDoc data) {
21         return visitor.visit(this, data);
22     }
23
24     public boolean hasSuppressWarningsAnnotationFor(Rule rule) {
25         for (int i = 0; i < jjtGetNumChildren(); i++) {
26             if (jjtGetChild(i) instanceof ASTAnnotation) {
27                 ASTAnnotation a = (ASTAnnotation) jjtGetChild(i);
28                 if (a.suppresses(rule)) {
29                     return true;
30                 }
31             }
32         }
33         return false;
34     }
35
36     public boolean isArray() {
37         return checkType() + checkDecl() > 0;
38     }
39
40     public int getArrayDepth() {
41         return checkType() + checkDecl();
42     }
43
44     public ASTType getTypeNode() {
45         for (int i = 0; i < jjtGetNumChildren(); i++) {
46             if (jjtGetChild(i) instanceof ASTType) {
47                 return (ASTType) jjtGetChild(i);
48             }
49         }
50         throw new IllegalStateException JavaDoc("ASTType not found");
51     }
52
53     private int checkType() {
54         return getTypeNode().getArrayDepth();
55     }
56
57     private ASTVariableDeclaratorId getDecl() {
58         return (ASTVariableDeclaratorId) jjtGetChild(jjtGetNumChildren()-1).jjtGetChild(0);
59     }
60
61     private int checkDecl() {
62         return getDecl().getArrayDepth();
63     }
64
65     public void dump(String JavaDoc prefix) {
66         String JavaDoc out = "";
67         if (isArray()) {
68             out += "(array";
69             for (int i = 0; i < getArrayDepth(); i++) {
70                 out += "[";
71             }
72             out += ")";
73         }
74         if (isFinal()) {
75             out += "(final)";
76         }
77         System.out.println(toString(prefix) + out);
78         dumpChildren(prefix);
79     }
80 }
81
Popular Tags