KickJava   Java API By Example, From Geeks To Geeks.

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


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

17     public Object JavaDoc jjtAccept(JavaParserVisitor visitor, Object JavaDoc data) {
18         return visitor.visit(this, data);
19     }
20
21     public void dump(String JavaDoc prefix) {
22         System.out.println(collectDumpedModifiers(prefix));
23         dumpChildren(prefix);
24     }
25
26     /**
27      * Gets the name of the method.
28      *
29      * @return a String representing the name of the method
30      */

31     public String JavaDoc getMethodName() {
32         ASTMethodDeclarator md = (ASTMethodDeclarator) getFirstChildOfType(ASTMethodDeclarator.class);
33         if (md != null)
34             return md.getImage();
35         return null;
36     }
37
38     public boolean isSyntacticallyPublic() {
39         return super.isPublic();
40     }
41
42     public boolean isSyntacticallyAbstract() {
43         return super.isAbstract();
44     }
45
46     public boolean isPublic() {
47         if (isInterfaceMember()) {
48             return true;
49         }
50         return super.isPublic();
51     }
52
53     public boolean isAbstract() {
54         if (isInterfaceMember()) {
55             return true;
56         }
57         return super.isAbstract();
58     }
59
60     public boolean isInterfaceMember() {
61         ASTClassOrInterfaceDeclaration clz = (ASTClassOrInterfaceDeclaration) getFirstParentOfType(ASTClassOrInterfaceDeclaration.class);
62         return clz != null && clz.isInterface();
63     }
64
65     public boolean isVoid() {
66         return ((ASTResultType) getFirstChildOfType(ASTResultType.class)).isVoid();
67     }
68
69     public ASTResultType getResultType() {
70         return (ASTResultType) getFirstChildOfType(ASTResultType.class);
71     }
72
73     public ASTBlock getBlock() {
74         // FIXME doesn't work for all methods that use generics and declare exceptions
75
if (this.jjtGetChild(2) instanceof ASTBlock) {
76             return (ASTBlock) this.jjtGetChild(2);
77         }
78         if (jjtGetNumChildren() > 3) {
79             if (this.jjtGetChild(3) instanceof ASTBlock) {
80                 return (ASTBlock) this.jjtGetChild(3);
81             }
82         }
83         return null;
84     }
85 }
86
Popular Tags