net.janino
Class Java.CompilationUnit

java.lang.Object
  |
  +--net.janino.Java.CompilationUnit
All Implemented Interfaces:
Java.Scope
Enclosing class:
Java

public static class Java.CompilationUnit
extends java.lang.Object
implements Java.Scope

Holds the result of Parser.parseCompilationUnit().

A call to compile(IClassLoader, int) generates an array of ClassFile objects which represent the classes and interfaces defined in the compilation unit.


Constructor Summary
Java.CompilationUnit(java.lang.String optionalFileName)
           
 
Method Summary
 void addClassOrInterfaceDeclaration(Java.ClassOrInterfaceDeclaration cid)
           
 void addImportedClass(Scanner.Location location, java.lang.String className, java.lang.String fullClassName)
           
 void addImportedPackage(java.lang.String packageName)
           
 ClassFile[] compile(IClassLoader iClassLoader, int debuggingInformation)
          Compiles this compilation unit and returns a set of ClassFile objects.
 Java.ClassOrInterfaceDeclaration getClassOrInterfaceDeclaration(java.lang.String className)
          Find one class or interface by name.
 Java.ClassOrInterfaceDeclaration[] getClassOrInterfaceDeclarations()
          Get all classes and interfaces declared in this compilation unit.
 Java.Scope getEnclosingScope()
           
 java.lang.String getFileName()
           
 void setPackage(java.lang.String packagE)
           
 
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(java.lang.String optionalFileName)
Parameters:
optionalFileName - only for getFileName()
Method Detail

getFileName

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

getEnclosingScope

public Java.Scope getEnclosingScope()
Specified by:
getEnclosingScope in interface Java.Scope
Following copied from interface: net.janino.Java.Scope
Returns:
Enclusing scope or "null".

setPackage

public void setPackage(java.lang.String packagE)

addImportedClass

public void addImportedClass(Scanner.Location location,
                             java.lang.String className,
                             java.lang.String fullClassName)
                      throws Parser.ParseException

addImportedPackage

public void addImportedPackage(java.lang.String packageName)

addClassOrInterfaceDeclaration

public void addClassOrInterfaceDeclaration(Java.ClassOrInterfaceDeclaration cid)

getClassOrInterfaceDeclarations

public Java.ClassOrInterfaceDeclaration[] getClassOrInterfaceDeclarations()
Get all classes and interfaces declared in this compilation unit.

getClassOrInterfaceDeclaration

public Java.ClassOrInterfaceDeclaration getClassOrInterfaceDeclaration(java.lang.String className)
Find one class or interface by name.
Parameters:
className - Fully qualified class name, e.g. "pkg1.pkg2.Outer$Inner".

compile

public ClassFile[] compile(IClassLoader iClassLoader,
                           int debuggingInformation)
                    throws Java.CompileException
Compiles this compilation unit and returns a set of ClassFile objects.
Parameters:
iClassLoader - used to look for classes defined outside this compilation unit
Returns:
a set of generated ClassFile objects