001: /*
002: * Author: Mike Atkinson
003: *
004: * This software has been developed under the copyleft
005: * rules of the GNU General Public License. Please
006: * consult the GNU General Public License for more
007: * details about use and distribution of this software.
008: */
009: package net.sourceforge.jrefactory.ast;
010:
011: import net.sourceforge.jrefactory.parser.JavaParser;
012: import net.sourceforge.jrefactory.parser.JavaParserVisitor;
013:
014: /**
015: * Stores an import declaration that appears at the beginning of a java file.
016: *
017: * @author Mike Atkinson
018: * @since jRefactory 2.9.0, created October 16, 2003
019: */
020: public class ASTImportDeclaration extends SimpleNode {
021: private boolean importPackage;
022: private boolean staticImport;// JDK 1.5
023:
024: /**
025: * Constructor for the ASTImportDeclaration node.
026: *
027: * @param identifier The id of this node (JJTIMPORTDECLARATION).
028: */
029: public ASTImportDeclaration(int identifier) {
030: super (identifier);
031: }
032:
033: /**
034: * Constructor for the ASTImportDeclaration node.
035: *
036: * @param parser The JavaParser that created this ASTImportDeclaration node.
037: * @param identifier The id of this node (JJTIMPORTDECLARATION).
038: */
039: public ASTImportDeclaration(JavaParser parser, int identifier) {
040: super (parser, identifier);
041: }
042:
043: /**
044: * Set when including everything in a package
045: *
046: * @param way <code>true</code> if we are importing the package.
047: */
048: public void setImportPackage(boolean way) {
049: importPackage = way;
050: }
051:
052: /**
053: * Set when including everything in a package. JDK 1.5 indicate that this is a static import.
054: *
055: * @param isStatic <code>true</code> if we are importing statics from the package
056: * @since JRefactory 2.7.00
057: */
058: public void setStaticImport(boolean isStatic) {
059: staticImport = isStatic;
060: }
061:
062: /**
063: * Return whether we are importing a package
064: *
065: * @return <code>true</code> if the whole package is being imported (with ".*;").
066: */
067: public boolean isImportingPackage() {
068: return importPackage;
069: }
070:
071: /**
072: * Return whether we are importing a the static from this package. JDK 1.5
073: *
074: * @return <code>true</code> if we are importing statics from the package
075: * @since JRefactory 2.7.00
076: */
077: public boolean isStaticImport() {
078: return staticImport;
079: }
080:
081: /**
082: * Gets the importOnDemand attribute of the ASTImportDeclaration node.
083: *
084: * @return <code>true</code> if the whole package was imported (with ".*;").
085: */
086: public boolean isImportOnDemand() {
087: return importPackage;
088: }
089:
090: /**
091: * Gets the importedNameNode attribute of the ASTImportDeclaration node.
092: *
093: * @return The name of the class or package being imported.
094: */
095: public ASTName getImportedNameNode() {
096: return (ASTName) jjtGetFirstChild();
097: }
098:
099: /**
100: * Accept the visitor.
101: *
102: * @param visitor An implementation of JavaParserVisitor that processes the ASTImportDeclaration node.
103: * @param data Some data being passed between the visitor methods.
104: * @return Usually the data parameter (possibly modified).
105: */
106: public Object jjtAccept(JavaParserVisitor visitor, Object data) {
107: return visitor.visit(this, data);
108: }
109:
110: }
|