View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   /* Generated By:JJTree: Do not edit this line. ASTImportDeclaration.java */
5   
6   package net.sourceforge.pmd.lang.java.ast;
7   
8   public class ASTImportDeclaration extends AbstractJavaTypeNode {
9   
10      private boolean isImportOnDemand;
11      private boolean isStatic;
12  
13      public ASTImportDeclaration(int id) {
14          super(id);
15      }
16  
17      public ASTImportDeclaration(JavaParser p, int id) {
18          super(p, id);
19      }
20  
21      public void setImportOnDemand() {
22          isImportOnDemand = true;
23      }
24  
25      public boolean isImportOnDemand() {
26          return isImportOnDemand;
27      }
28  
29      public void setStatic() {
30          isStatic = true;
31      }
32  
33      public boolean isStatic() {
34          return isStatic;
35      }
36  
37      // TODO - this should go away, but the DuplicateImports rule still uses it (in a clunky way)
38      public ASTName getImportedNameNode() {
39          return (ASTName) jjtGetChild(0);
40      }
41  
42      public String getImportedName() {
43          return ((ASTName) jjtGetChild(0)).getImage();
44      }
45  
46      public String getPackageName() {
47          String importName = getImportedName();
48          if (isImportOnDemand) {
49              return importName;
50          }
51          if (importName.indexOf('.') == -1) {
52              return "";
53          }
54          int lastDot = importName.lastIndexOf('.');
55          return importName.substring(0, lastDot);
56      }
57  
58      /**
59       * Accept the visitor. *
60       */
61      public Object jjtAccept(JavaParserVisitor visitor, Object data) {
62          return visitor.visit(this, data);
63      }
64      
65      private Package pkg;
66      public void setPackage(Package packge){
67          this.pkg = packge;
68      }
69      
70      public Package getPackage(){
71          return this.pkg;
72      }
73  }