Web Site

org.codehaus.janino
Class Java.CompilationUnit

java.lang.Object
  extended byorg.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().


Constructor Summary
Java.CompilationUnit(String optionalFileName)
           
 
Method Summary
 void addImportDeclaration(Java.ImportDeclaration id)
           
 void addPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd)
           
 Java.Scope getEnclosingScope()
           
 String getFileName()
           
 Java.PackageMemberTypeDeclaration getPackageMemberTypeDeclaration(String name)
          Return the package member class or interface declared with the given name.
 Java.PackageMemberTypeDeclaration[] getPackageMemberTypeDeclarations()
          Get all classes and interfaces declared in this compilation unit.
 String[] getSingleTypeImport(String name)
          Check if the given name was imported through a "single type import", e.g.
 void setPackageDeclaration(Java.PackageDeclaration packageDeclaration)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Java.CompilationUnit

public Java.CompilationUnit(String optionalFileName)
Parameters:
optionalFileName - only for getFileName()
Method Detail

getFileName

public String getFileName()
Returns:
the optionalFileName given at construction.

getEnclosingScope

public Java.Scope getEnclosingScope()
Specified by:
getEnclosingScope in interface Java.Scope
Returns:
Enclusing scope or "null".

setPackageDeclaration

public void setPackageDeclaration(Java.PackageDeclaration packageDeclaration)

addImportDeclaration

public void addImportDeclaration(Java.ImportDeclaration id)
                          throws Parser.ParseException
Throws:
Parser.ParseException

addPackageMemberTypeDeclaration

public void addPackageMemberTypeDeclaration(Java.PackageMemberTypeDeclaration pmtd)

getPackageMemberTypeDeclarations

public Java.PackageMemberTypeDeclaration[] getPackageMemberTypeDeclarations()
Get 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

getSingleTypeImport

public String[] getSingleTypeImport(String name)
Check if the given name was imported through a "single type import", e.g.
     import java.util.Map

Returns:
the fully qualified name or null

Web Site