public final class ImportDeclaration extends Node
This class represents a import declaration or an empty import declaration. Imports are optional for the
CompilationUnit
.
An enmpty import declaration is simply a semicolon among the import declarations.ImportDeclaration ::= "import" ( "static" )?
NameExpr
( "." "*" )? ";"
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE
Constructor and Description |
---|
ImportDeclaration(NameExpr name,
boolean isStatic,
boolean isAsterisk) |
ImportDeclaration(Range range,
NameExpr name,
boolean isStatic,
boolean isAsterisk) |
Modifier and Type | Method and Description |
---|---|
<R,A> R |
accept(GenericVisitor<R,A> v,
A arg)
Accept method for visitor support.
|
<A> void |
accept(VoidVisitor<A> v,
A arg)
Accept method for visitor support.
|
static ImportDeclaration |
createEmptyDeclaration()
Create an empty import declaration without specifying its position.
|
static ImportDeclaration |
createEmptyDeclaration(Range range)
Create an empty import declaration specifying its position.
|
NameExpr |
getName()
Retrieves the name of the import.
|
boolean |
isAsterisk()
Return if the import ends with "*".
|
boolean |
isEmptyImportDeclaration()
Is this an empty import declaration or a normal import declaration?
|
boolean |
isStatic()
Return if the import is static.
|
ImportDeclaration |
setAsterisk(boolean asterisk)
Sets if this import is asterisk.
|
ImportDeclaration |
setName(NameExpr name)
Sets the name this import.
|
ImportDeclaration |
setStatic(boolean static_)
Sets if this import is static.
|
addOrphanComment, clone, contains, equals, getAllContainedComments, getBegin, getChildrenNodes, getComment, getEnd, getNodesByType, getOrphanComments, getParentNode, getParentNodeOfType, getRange, getUserData, hasComment, hashCode, isPositionedAfter, isPositionedBefore, setAsParentNodeOf, setAsParentNodeOf, setBegin, setBlockComment, setComment, setEnd, setLineComment, setParentNode, setRange, setUserData, toString, toStringWithoutComments, tryAddImportToParentCompilationUnit
public ImportDeclaration(NameExpr name, boolean isStatic, boolean isAsterisk)
public static ImportDeclaration createEmptyDeclaration()
public static ImportDeclaration createEmptyDeclaration(Range range)
public boolean isEmptyImportDeclaration()
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Node
public <A> void accept(VoidVisitor<A> v, A arg)
Node
public NameExpr getName()
UnsupportedOperationException
- when invoked on an empty import declarationpublic boolean isAsterisk()
true
if the import ends with "*", false
otherwisepublic boolean isStatic()
true
if the import is static, false
otherwisepublic ImportDeclaration setAsterisk(boolean asterisk)
asterisk
- true
if this import is asteriskUnsupportedOperationException
- when setting true on an empty import declarationpublic ImportDeclaration setName(NameExpr name)
name
- the name to setUnsupportedOperationException
- when invoked on an empty import declarationpublic ImportDeclaration setStatic(boolean static_)
static_
- true
if this import is staticUnsupportedOperationException
- when setting true on an empty import declarationCopyright © 2007–2016. All rights reserved.