Package org.codehaus.janino
Class Java.CompilationUnit
- java.lang.Object
-
- org.codehaus.janino.Java.CompilationUnit
-
- All Implemented Interfaces:
Java.Scope
- Enclosing class:
- Java
public static final class Java.CompilationUnit extends Object implements Java.Scope
Holds the result ofParser.parseCompilationUnit()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Java.CompilationUnit.ImportDeclaration
Base class for the various IMPORT declarations.static class
Java.CompilationUnit.SingleStaticImportDeclaration
Represents a single static import declaration likestatic class
Java.CompilationUnit.SingleTypeImportDeclaration
Represents a 'single-type import declaration' like 'import java.util.Map;
'.static class
Java.CompilationUnit.StaticImportOnDemandDeclaration
Represents a static-import-on-demand declaration likestatic class
Java.CompilationUnit.TypeImportOnDemandDeclaration
Represents a type-import-on-demand declaration likeimport java.util.*;
.
-
Field Summary
Fields Modifier and Type Field Description List<Java.CompilationUnit.ImportDeclaration>
importDeclarations
The IMPORT declarations in this CU.String
optionalFileName
A string that explains the 'file' (or similar resource) where this CU was loaded from.Java.PackageDeclaration
optionalPackageDeclaration
The package declaration at the very top of this CU (if any).List<Java.PackageMemberTypeDeclaration>
packageMemberTypeDeclarations
The top-level declarations in this CU.
-
Constructor Summary
Constructors Constructor Description CompilationUnit(String optionalFileName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addImportDeclaration(Java.CompilationUnit.ImportDeclaration id)
Adds one IMPORT declaration to this CU.void
addPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd)
Adds one top-level type declaration to this CU.Java.Scope
getEnclosingScope()
Java.PackageMemberTypeDeclaration
getPackageMemberTypeDeclaration(String name)
Return 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 CU.
-
-
-
Field Detail
-
optionalFileName
public final String optionalFileName
A string that explains the 'file' (or similar resource) where this CU was loaded from.
-
optionalPackageDeclaration
public Java.PackageDeclaration optionalPackageDeclaration
The package declaration at the very top of this CU (if any).
-
importDeclarations
public final List<Java.CompilationUnit.ImportDeclaration> importDeclarations
The IMPORT declarations in this CU.
-
packageMemberTypeDeclarations
public final List<Java.PackageMemberTypeDeclaration> packageMemberTypeDeclarations
The top-level declarations in this CU.
-
-
Constructor Detail
-
CompilationUnit
public CompilationUnit(String optionalFileName)
-
-
Method Detail
-
getEnclosingScope
public Java.Scope getEnclosingScope()
- Specified by:
getEnclosingScope
in interfaceJava.Scope
- Returns:
- The scope that encloses this scope, or
null
-
setPackageDeclaration
public void setPackageDeclaration(Java.PackageDeclaration packageDeclaration)
Sets the package declaration of this CU.
-
addImportDeclaration
public void addImportDeclaration(Java.CompilationUnit.ImportDeclaration id)
Adds one IMPORT declaration to this CU.
-
addPackageMemberTypeDeclaration
public void addPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd)
Adds one top-level type declaration to this CU.
-
getPackageMemberTypeDeclarations
public Java.PackageMemberTypeDeclaration[] getPackageMemberTypeDeclarations()
Gets all classes and interfaces declared in this compilation unit.
-
getPackageMemberTypeDeclaration
public Java.PackageMemberTypeDeclaration getPackageMemberTypeDeclaration(String name)
Return 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
-
-