KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > ImportReference


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15 import org.eclipse.jdt.internal.compiler.lookup.*;
16
17 public class ImportReference extends ASTNode {
18
19     public char[][] tokens;
20     public long[] sourcePositions; //each entry is using the code : (start<<32) + end
21
public int declarationEnd; // doesn't include an potential trailing comment
22
public int declarationSourceStart;
23     public int declarationSourceEnd;
24     public int modifiers; // 1.5 addition for static imports
25
public Annotation[] annotations;
26
27     public ImportReference(
28             char[][] tokens,
29             long[] sourcePositions,
30             boolean onDemand,
31             int modifiers) {
32
33         this.tokens = tokens;
34         this.sourcePositions = sourcePositions;
35         if (onDemand) {
36             this.bits |= ASTNode.OnDemand;
37         }
38         this.sourceEnd = (int) (sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFF);
39         this.sourceStart = (int) (sourcePositions[0] >>> 32);
40         this.modifiers = modifiers;
41     }
42     
43     public boolean isStatic() {
44         return (this.modifiers & ClassFileConstants.AccStatic) != 0;
45     }
46
47     /**
48      * @return char[][]
49      */

50     public char[][] getImportName() {
51
52         return tokens;
53     }
54
55     public StringBuffer JavaDoc print(int indent, StringBuffer JavaDoc output) {
56
57         return print(indent, output, true);
58     }
59
60     public StringBuffer JavaDoc print(int tab, StringBuffer JavaDoc output, boolean withOnDemand) {
61
62         /* when withOnDemand is false, only the name is printed */
63         for (int i = 0; i < tokens.length; i++) {
64             if (i > 0) output.append('.');
65             output.append(tokens[i]);
66         }
67         if (withOnDemand && ((this.bits & ASTNode.OnDemand) != 0)) {
68             output.append(".*"); //$NON-NLS-1$
69
}
70         return output;
71     }
72
73     public void traverse(ASTVisitor visitor, CompilationUnitScope scope) {
74         // annotations are traversed during the compilation unit traversal using a class scope
75
visitor.visit(this, scope);
76         visitor.endVisit(this, scope);
77     }
78 }
79
Popular Tags