View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.java.symboltable;
5   
6   import net.sourceforge.pmd.lang.ast.Node;
7   import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
8   import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration;
9   import net.sourceforge.pmd.lang.symboltable.AbstractNameDeclaration;
10  
11  public class ClassNameDeclaration extends AbstractNameDeclaration implements TypedNameDeclaration {
12  
13      public ClassNameDeclaration(ASTClassOrInterfaceDeclaration node) {
14          super(node);
15      }
16  
17      public ClassNameDeclaration(ASTEnumDeclaration node) {
18          super(node);
19      }
20  
21      public String toString() {
22          if (node instanceof ASTClassOrInterfaceDeclaration) {
23              if (((ASTClassOrInterfaceDeclaration) node).isInterface()) {
24                  return "Interface " + node.getImage();
25              } else {
26                  return "Class " + node.getImage();
27              }
28          } else {
29              return "Enum " + node.getImage();
30          }
31      }
32  
33      public Node getAccessNodeParent() {
34          return node;
35      }
36  
37      public String getTypeImage() {
38          return ((ASTClassOrInterfaceDeclaration)node).getImage();
39      }
40  
41      public Class<?> getType() {
42          return ((ASTClassOrInterfaceDeclaration)node).getType();
43      }
44  }