Package org.codehaus.janino
Class Java.CompilationUnit
- java.lang.Object
-
- org.codehaus.janino.Java.AbstractCompilationUnit
-
- org.codehaus.janino.Java.CompilationUnit
-
- All Implemented Interfaces:
Java.Scope
- Enclosing class:
- Java
public static final class Java.CompilationUnit extends Java.AbstractCompilationUnit
Representation of an "ordinary compilation unit" as explained in JLS9 7.3 (before Java 9 known as "compilation unit" and described in JLS8 7.3).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.janino.Java.AbstractCompilationUnit
Java.AbstractCompilationUnit.ImportDeclaration, Java.AbstractCompilationUnit.SingleStaticImportDeclaration, Java.AbstractCompilationUnit.SingleTypeImportDeclaration, Java.AbstractCompilationUnit.StaticImportOnDemandDeclaration, Java.AbstractCompilationUnit.TypeImportOnDemandDeclaration
-
-
Field Summary
Fields Modifier and Type Field Description Java.PackageDeclaration
packageDeclaration
The package declaration at the very top of this compilation unit (if any).java.util.List<Java.PackageMemberTypeDeclaration>
packageMemberTypeDeclarations
The top-level declarations in this compilation unit.-
Fields inherited from class org.codehaus.janino.Java.AbstractCompilationUnit
fileName, importDeclarations
-
-
Constructor Summary
Constructors Constructor Description CompilationUnit(java.lang.String fileName)
CompilationUnit(java.lang.String fileName, Java.AbstractCompilationUnit.ImportDeclaration[] importDeclarations)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,EX extends java.lang.Throwable>
Raccept(Visitor.AbstractCompilationUnitVisitor<R,EX> visitor)
Invokes the "visit...()
" method ofVisitor.AbstractCompilationUnitVisitor
for the concreteJava.AbstractCompilationUnit
type.void
addPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd)
Adds one top-level type declaration to this compilation unit.Java.PackageMemberTypeDeclaration
getPackageMemberTypeDeclaration(java.lang.String name)
Returns the package member class or interface declared with the given name.Java.PackageMemberTypeDeclaration[]
getPackageMemberTypeDeclarations()
Gets all classes and interfaces declared in this compilation unit.void
setPackageDeclaration(Java.PackageDeclaration packageDeclaration)
Sets the package declaration of this compilation unit.-
Methods inherited from class org.codehaus.janino.Java.AbstractCompilationUnit
getEnclosingScope
-
-
-
-
Field Detail
-
packageDeclaration
@Nullable public Java.PackageDeclaration packageDeclaration
The package declaration at the very top of this compilation unit (if any).
-
packageMemberTypeDeclarations
public final java.util.List<Java.PackageMemberTypeDeclaration> packageMemberTypeDeclarations
The top-level declarations in this compilation unit.
-
-
Constructor Detail
-
CompilationUnit
public CompilationUnit(@Nullable java.lang.String fileName)
-
CompilationUnit
public CompilationUnit(@Nullable java.lang.String fileName, Java.AbstractCompilationUnit.ImportDeclaration[] importDeclarations)
-
-
Method Detail
-
setPackageDeclaration
public void setPackageDeclaration(@Nullable Java.PackageDeclaration packageDeclaration)
Sets the package declaration of this compilation unit.
-
addPackageMemberTypeDeclaration
public void addPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd)
Adds one top-level type declaration to this compilation unit.
-
getPackageMemberTypeDeclarations
public Java.PackageMemberTypeDeclaration[] getPackageMemberTypeDeclarations()
Gets all classes and interfaces declared in this compilation unit.
-
getPackageMemberTypeDeclaration
@Nullable public Java.PackageMemberTypeDeclaration getPackageMemberTypeDeclaration(java.lang.String name)
Returns the package member class or interface declared with the given name.- Parameters:
name
- Declared (i.e. not the fully qualified) name- Returns:
null
if a package member type with that name is not declared in this compilation unit
-
accept
@Nullable public <R,EX extends java.lang.Throwable> R accept(Visitor.AbstractCompilationUnitVisitor<R,EX> visitor) throws EX extends java.lang.Throwable
Description copied from class:Java.AbstractCompilationUnit
Invokes the "visit...()
" method ofVisitor.AbstractCompilationUnitVisitor
for the concreteJava.AbstractCompilationUnit
type.- Specified by:
accept
in classJava.AbstractCompilationUnit
- Throws:
EX extends java.lang.Throwable
-
-