janino.net

org.codehaus.janino
Class Java.CompilationUnit

java.lang.Object
  extended by 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 of Parser.parseCompilationUnit().


Nested Class Summary
static class Java.CompilationUnit.ImportDeclaration
          Base class for the various IMPORT declarations.
static class Java.CompilationUnit.SingleStaticImportDeclaration
          Represents a single static import declaration like import java.util.Collections.EMPTY_MAP;
static 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 like import java.util.Collections.
static class Java.CompilationUnit.TypeImportOnDemandDeclaration
          Represents a type-import-on-demand declaration like import java.util.*;.
 
Field Summary
 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
Java.CompilationUnit(String optionalFileName)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

Java.CompilationUnit

public Java.CompilationUnit(String optionalFileName)
Method Detail

getEnclosingScope

public Java.Scope getEnclosingScope()
Specified by:
getEnclosingScope in interface Java.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

janino.net