|
1 |
| |
|
2 |
| |
|
3 |
| package net.sourceforge.pmd.ast; |
|
4 |
| |
|
5 |
| public class ASTImportDeclaration extends SimpleJavaNode { |
|
6 |
| |
|
7 |
| private boolean isImportOnDemand; |
|
8 |
| private boolean isStatic; |
|
9 |
| |
|
10 |
0
| public ASTImportDeclaration(int id) {
|
|
11 |
0
| super(id);
|
|
12 |
| } |
|
13 |
| |
|
14 |
93
| public ASTImportDeclaration(JavaParser p, int id) {
|
|
15 |
93
| super(p, id);
|
|
16 |
| } |
|
17 |
| |
|
18 |
49
| public void setImportOnDemand() {
|
|
19 |
49
| isImportOnDemand = true;
|
|
20 |
| } |
|
21 |
| |
|
22 |
39
| public boolean isImportOnDemand() {
|
|
23 |
39
| return isImportOnDemand;
|
|
24 |
| } |
|
25 |
| |
|
26 |
2
| public void setStatic() {
|
|
27 |
2
| isStatic = true;
|
|
28 |
| } |
|
29 |
| |
|
30 |
9
| public boolean isStatic() {
|
|
31 |
9
| return isStatic;
|
|
32 |
| } |
|
33 |
| |
|
34 |
| |
|
35 |
15
| public ASTName getImportedNameNode() {
|
|
36 |
15
| return (ASTName) jjtGetChild(0);
|
|
37 |
| } |
|
38 |
| |
|
39 |
52
| public String getImportedName() {
|
|
40 |
52
| return ((ASTName) jjtGetChild(0)).getImage();
|
|
41 |
| } |
|
42 |
| |
|
43 |
17
| public String getPackageName() {
|
|
44 |
17
| String importName = getImportedName();
|
|
45 |
17
| if (isImportOnDemand) {
|
|
46 |
3
| return importName;
|
|
47 |
| } |
|
48 |
14
| if (importName.indexOf('.') == -1) {
|
|
49 |
2
| return "";
|
|
50 |
| } |
|
51 |
12
| int lastDot = importName.lastIndexOf('.');
|
|
52 |
12
| return importName.substring(0, lastDot);
|
|
53 |
| } |
|
54 |
| |
|
55 |
| |
|
56 |
0
| public void dump(String prefix) {
|
|
57 |
0
| String out = "";
|
|
58 |
0
| if (isStatic()) {
|
|
59 |
0
| out += "(static)";
|
|
60 |
| } |
|
61 |
0
| System.out.println(toString(prefix) + out);
|
|
62 |
0
| dumpChildren(prefix);
|
|
63 |
| } |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
279
| public Object jjtAccept(JavaParserVisitor visitor, Object data) {
|
|
69 |
279
| return visitor.visit(this, data);
|
|
70 |
| } |
|
71 |
| } |