KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* Generated By:JJTree: Do not edit this line. ASTFormalParameter.java */
2
3 package net.sourceforge.pmd.ast;
4
5 import net.sourceforge.pmd.Rule;
6
7 public class ASTFormalParameter extends AccessNode implements Dimensionable, CanSuppressWarnings {
8
9     private boolean isVarargs;
10
11
12     public void setVarargs() {
13         isVarargs = true;
14     }
15
16     public boolean isVarargs() {
17         return isVarargs;
18     }
19     
20     public ASTFormalParameter(int id) {
21         super(id);
22     }
23
24     public ASTFormalParameter(JavaParser p, int id) {
25         super(p, id);
26     }
27
28     public Object JavaDoc jjtAccept(JavaParserVisitor visitor, Object JavaDoc data) {
29         return visitor.visit(this, data);
30     }
31
32     public boolean hasSuppressWarningsAnnotationFor(Rule rule) {
33         for (int i = 0; i < jjtGetNumChildren(); i++) {
34             if (jjtGetChild(i) instanceof ASTAnnotation) {
35                 ASTAnnotation a = (ASTAnnotation) jjtGetChild(i);
36                 if (a.suppresses(rule)) {
37                     return true;
38                 }
39             }
40         }
41         return false;
42     }
43
44     public boolean isArray() {
45         return checkType() + checkDecl() > 0;
46     }
47
48     public int getArrayDepth() {
49         if (!isArray()) {
50             return 0;
51         }
52         return checkType() + checkDecl();
53     }
54
55     public ASTType getTypeNode() {
56         for (int i = 0; i < jjtGetNumChildren(); i++) {
57             if (jjtGetChild(i) instanceof ASTType) {
58                 return (ASTType) jjtGetChild(i);
59             }
60         }
61         throw new IllegalStateException JavaDoc("ASTType not found");
62     }
63
64     private int checkType() {
65         return getTypeNode().getArrayDepth();
66     }
67
68     private ASTVariableDeclaratorId getDecl() {
69         return (ASTVariableDeclaratorId) jjtGetChild(jjtGetNumChildren()-1);
70     }
71
72     private int checkDecl() {
73         return getDecl().getArrayDepth();
74     }
75
76     public void dump(String JavaDoc prefix) {
77         System.out.println(collectDumpedModifiers(prefix));
78         dumpChildren(prefix);
79     }
80
81 }
82
Popular Tags