japa.parser.ast
Class CompilationUnit

java.lang.Object
  extended by japa.parser.ast.Node
      extended by japa.parser.ast.ExtendedNode
          extended by japa.parser.ast.CompilationUnit

public final class CompilationUnit
extends ExtendedNode

This class represents the entire compilation unit. Each java file denotes a compilation unit.

The CompilationUnit is constructed following the syntax:
CompilationUnit ::= ( PackageDeclaration )?
( ImportDeclaration )*
( TypeDeclaration )*

Author:
Julio Vilmar Gesser

Constructor Summary
CompilationUnit()
           
CompilationUnit(int beginLine, int beginColumn, int endLine, int endColumn, japa.parser.ast.PackageDeclaration pakage, java.util.List<japa.parser.ast.ImportDeclaration> imports, java.util.List<japa.parser.ast.body.TypeDeclaration> types, java.util.List<japa.parser.ast.Comment> comments)
           
CompilationUnit(japa.parser.ast.PackageDeclaration pakage, java.util.List<japa.parser.ast.ImportDeclaration> imports, java.util.List<japa.parser.ast.body.TypeDeclaration> types, java.util.List<japa.parser.ast.Comment> comments)
           
 
Method Summary
<R,A> R
accept(japa.parser.ast.visitor.GenericVisitor<R,A> v, A arg)
           
<A> void
accept(japa.parser.ast.visitor.VoidVisitor<A> v, A arg)
           
 java.util.List<japa.parser.ast.Comment> getComments()
          Return a list containing all comments declared in this compilation unit.
 java.util.List<japa.parser.ast.ImportDeclaration> getImports()
          Retrieves the list of imports declared in this compilation unit or null if there is no import.
 japa.parser.ast.PackageDeclaration getPackage()
          Retrieves the package declaration of this compilation unit.
If this compilation unit has no package declaration (default package), null is returned.
 java.util.List<japa.parser.ast.body.TypeDeclaration> getTypes()
          Return the list of types declared in this compilation unit.
If there is no types declared, null is returned.
 void setComments(java.util.List<japa.parser.ast.Comment> comments)
          Sets the list of comments of this compilation unit.
 void setImports(java.util.List<japa.parser.ast.ImportDeclaration> imports)
          Sets the list of imports of this compilation unit.
 void setPackage(japa.parser.ast.PackageDeclaration pakage)
          Sets or clear the package declarations of this compilation unit.
 void setTypes(java.util.List<japa.parser.ast.body.TypeDeclaration> types)
          Sets the list of types declared in this compilation unit.
 
Methods inherited from class japa.parser.ast.ExtendedNode
toString
 
Methods inherited from class japa.parser.ast.Node
equals, getBeginColumn, getBeginLine, getData, getEndColumn, getEndLine, hashCode, setBeginColumn, setBeginLine, setData, setEndColumn, setEndLine, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompilationUnit

public CompilationUnit()

CompilationUnit

public CompilationUnit(japa.parser.ast.PackageDeclaration pakage,
                       java.util.List<japa.parser.ast.ImportDeclaration> imports,
                       java.util.List<japa.parser.ast.body.TypeDeclaration> types,
                       java.util.List<japa.parser.ast.Comment> comments)

CompilationUnit

public CompilationUnit(int beginLine,
                       int beginColumn,
                       int endLine,
                       int endColumn,
                       japa.parser.ast.PackageDeclaration pakage,
                       java.util.List<japa.parser.ast.ImportDeclaration> imports,
                       java.util.List<japa.parser.ast.body.TypeDeclaration> types,
                       java.util.List<japa.parser.ast.Comment> comments)
Method Detail

accept

public <R,A> R accept(japa.parser.ast.visitor.GenericVisitor<R,A> v,
                      A arg)
Specified by:
accept in class japa.parser.ast.Node

accept

public <A> void accept(japa.parser.ast.visitor.VoidVisitor<A> v,
                       A arg)
Specified by:
accept in class japa.parser.ast.Node

getComments

public java.util.List<japa.parser.ast.Comment> getComments()
Return a list containing all comments declared in this compilation unit. Including javadocs, line comments and block comments of all types, inner-classes and other members.
If there is no comment, null is returned.

Returns:
list with all comments of this compilation unit or null
See Also:
JavadocComment, LineComment, BlockComment

getImports

public java.util.List<japa.parser.ast.ImportDeclaration> getImports()
Retrieves the list of imports declared in this compilation unit or null if there is no import.

Returns:
the list of imports or null if there is no import

getPackage

public japa.parser.ast.PackageDeclaration getPackage()
Retrieves the package declaration of this compilation unit.
If this compilation unit has no package declaration (default package), null is returned.

Returns:
the package declaration or null

getTypes

public java.util.List<japa.parser.ast.body.TypeDeclaration> getTypes()
Return the list of types declared in this compilation unit.
If there is no types declared, null is returned.

Returns:
the list of types or null null if there is no type
See Also:
AnnotationDeclaration, ClassOrInterfaceDeclaration, EmptyTypeDeclaration, EnumDeclaration

setComments

public void setComments(java.util.List<japa.parser.ast.Comment> comments)
Sets the list of comments of this compilation unit.

Parameters:
comments - the list of comments

setImports

public void setImports(java.util.List<japa.parser.ast.ImportDeclaration> imports)
Sets the list of imports of this compilation unit. The list is initially null.

Parameters:
imports - the list of imports

setPackage

public void setPackage(japa.parser.ast.PackageDeclaration pakage)
Sets or clear the package declarations of this compilation unit.

Parameters:
pakage - the pakage declaration to set or null to default package

setTypes

public void setTypes(java.util.List<japa.parser.ast.body.TypeDeclaration> types)
Sets the list of types declared in this compilation unit.

Parameters:
types - the lis of types


Copyright © 2013 eXo Platform SAS. All Rights Reserved.