org.teatrove.tea.compiler
Class CompilationUnit

java.lang.Object
  extended by org.teatrove.tea.compiler.CompilationUnit
All Implemented Interfaces:
EventListener, ErrorListener
Direct Known Subclasses:
AbstractCompiler.AbstractUnit, CompiledTemplate

public abstract class CompilationUnit
extends Object
implements ErrorListener

Author:
Brian S O'Neill

Constructor Summary
CompilationUnit(String name, Compiler compiler)
           
 
Method Summary
 void compileError(ErrorEvent e)
          Called when there is an error when compiling this CompilationUnit.
 Compiler getCompiler()
           
 int getErrorCount()
          Returns the number of errors generated while compiling this CompilationUnit.
 String[] getImportedPackages()
          Current implementation returns only the same packages as the compiler.
 String getName()
           
abstract  OutputStream getOutputStream()
           
 Template getParseTree()
           
abstract  Reader getReader()
           
 Class<?> getRuntimeContext()
          The retrieves the runtime context.
 String getShortName()
           
abstract  String getSourceFileName()
           
 String getTargetPackage()
          Return the package name that this CompilationUnit should be compiled into.
abstract  void resetOutputStream()
          Reset the output stream cleaning up or removing any files created as part of the output stream.
 void setParseTree(Template tree)
           
 boolean shouldCompile()
           
 boolean signatureEquals(String templateName, TypeDesc[] params, TypeDesc returnType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompilationUnit

public CompilationUnit(String name,
                       Compiler compiler)
Method Detail

getName

public String getName()

getShortName

public String getShortName()

getCompiler

public Compiler getCompiler()

getRuntimeContext

public Class<?> getRuntimeContext()
The retrieves the runtime context. The default behavior is to delegate this call to the compiler. This is overriden to implement compiled templates.


compileError

public void compileError(ErrorEvent e)
Called when there is an error when compiling this CompilationUnit.

Specified by:
compileError in interface ErrorListener

getErrorCount

public int getErrorCount()
Returns the number of errors generated while compiling this CompilationUnit.


getParseTree

public Template getParseTree()

setParseTree

public void setParseTree(Template tree)

getImportedPackages

public final String[] getImportedPackages()
Current implementation returns only the same packages as the compiler.

See Also:
Compiler.getImportedPackages()

getTargetPackage

public String getTargetPackage()
Return the package name that this CompilationUnit should be compiled into. Default implementation returns null, or no package.


getSourceFileName

public abstract String getSourceFileName()

getReader

public abstract Reader getReader()
                          throws IOException
Returns:
A new source file reader.
Throws:
IOException

shouldCompile

public boolean shouldCompile()
                      throws IOException
Returns:
true if the CompilationUnit should be compiled. Default is true.
Throws:
IOException

signatureEquals

public boolean signatureEquals(String templateName,
                               TypeDesc[] params,
                               TypeDesc returnType)
                        throws IOException
Throws:
IOException

getOutputStream

public abstract OutputStream getOutputStream()
                                      throws IOException
Returns:
An OutputStream to write compiled code to. Returning null is disables code generation for this CompilationUnit.
Throws:
IOException

resetOutputStream

public abstract void resetOutputStream()
Reset the output stream cleaning up or removing any files created as part of the output stream. This is generally used when an exception occurs during code generation to the output stream.



Copyright © 1997-2012 TeaTrove.org. All Rights Reserved.