01: /* Generated By:JJTree: Do not edit this line. ASTImportDeclaration.java */
02:
03: package net.sourceforge.pmd.ast;
04:
05: public class ASTImportDeclaration extends SimpleJavaTypeNode {
06:
07: private boolean isImportOnDemand;
08: private boolean isStatic;
09:
10: public ASTImportDeclaration(int id) {
11: super (id);
12: }
13:
14: public ASTImportDeclaration(JavaParser p, int id) {
15: super (p, id);
16: }
17:
18: public void setImportOnDemand() {
19: isImportOnDemand = true;
20: }
21:
22: public boolean isImportOnDemand() {
23: return isImportOnDemand;
24: }
25:
26: public void setStatic() {
27: isStatic = true;
28: }
29:
30: public boolean isStatic() {
31: return isStatic;
32: }
33:
34: // TODO - this should go away, but the DuplicateImports rule still uses it (in a clunky way)
35: public ASTName getImportedNameNode() {
36: return (ASTName) jjtGetChild(0);
37: }
38:
39: public String getImportedName() {
40: return ((ASTName) jjtGetChild(0)).getImage();
41: }
42:
43: public String getPackageName() {
44: String importName = getImportedName();
45: if (isImportOnDemand) {
46: return importName;
47: }
48: if (importName.indexOf('.') == -1) {
49: return "";
50: }
51: int lastDot = importName.lastIndexOf('.');
52: return importName.substring(0, lastDot);
53: }
54:
55: public void dump(String prefix) {
56: String out = "";
57: if (isStatic()) {
58: out += "(static)";
59: }
60: System.out.println(toString(prefix) + out);
61: dumpChildren(prefix);
62: }
63:
64: /**
65: * Accept the visitor. *
66: */
67: public Object jjtAccept(JavaParserVisitor visitor, Object data) {
68: return visitor.visit(this , data);
69: }
70:
71: private Package pkg;
72:
73: public void setPackage(Package packge) {
74: this .pkg = packge;
75: }
76:
77: public Package getPackage() {
78: return this.pkg;
79: }
80: }
|