|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.go.tea.compiler.Compiler
The Tea compiler. This class is abstract, and a few concrete implementations can be found in the com.go.tea.util package.
A Compiler instance should be used for only one "build" because some information is cached internally like parse trees and error count.
FileCompiler,
ResourceCompiler| Constructor Summary | |
Compiler()
|
|
Compiler(java.util.Map parseTreeMap)
This constructor allows template signatures to be shared among compiler instances. |
|
| Method Summary | |
void |
addErrorListener(ErrorListener listener)
Add an ErrorListener in order receive events of compile-time errors. |
void |
addStatusListener(StatusListener listener)
Add a StatusListener in order to receive events of compilation progress. |
java.lang.String[] |
compile(java.lang.String name)
Compile a single compilation unit. |
java.lang.String[] |
compile(java.lang.String[] names)
Compile a list of compilation units. |
protected CodeGenerator |
createCodeGenerator(CompilationUnit unit)
Default implementation returns a new JavaClassGenerator. |
protected abstract CompilationUnit |
createCompilationUnit(java.lang.String name)
|
protected Parser |
createParser(Scanner scanner,
CompilationUnit unit)
|
protected Scanner |
createScanner(SourceReader reader,
CompilationUnit unit)
|
protected SourceReader |
createSourceReader(CompilationUnit unit)
Default implementation returns a SourceReader that uses "<%" and "%>" as code delimiters. |
protected TypeChecker |
createTypeChecker(CompilationUnit unit)
|
java.lang.ClassLoader |
getClassLoader()
Returns the ClassLoader used by the Compiler, or null if none set. |
CompilationUnit |
getCompilationUnit(java.lang.String name,
CompilationUnit from)
Returns a compilation unit associated with the given name, or null if not found. |
int |
getErrorCount()
|
static java.lang.String[] |
getImportedPackages()
Returns the list of imported packages that all templates have. |
java.lang.Class |
getRuntimeContext()
Return a class that defines a template's runtime context. |
java.lang.reflect.Method[] |
getRuntimeContextMethods()
Returns all the methods available in the runtime context. |
java.lang.String |
getRuntimeReceiver()
Return the name of a method in the runtime context to bind to for receiving objects emitted by templates. |
java.lang.String |
getRuntimeStringConverter()
Return the name of a method in the runtime context to bind to for converting objects and primitives to strings. |
java.lang.reflect.Method[] |
getStringConverterMethods()
Returns the set of methods that are used to perform conversion to strings. |
boolean |
isCodeGenerationEnabled()
Returns true if code generation is enabled. |
boolean |
isExceptionGuardianEnabled()
Returns true if the exception guardian is enabled. |
java.lang.Class |
loadClass(java.lang.String name)
Loads and returns a class by the fully qualified name given. |
void |
preserveParseTree(java.lang.String name)
After a template is compiled, all but the root node of its parse tree is clipped, in order to save memory. |
void |
removeErrorListener(ErrorListener listener)
|
void |
removeStatusListener(StatusListener listener)
|
void |
setClassLoader(java.lang.ClassLoader loader)
Sets the ClassLoader to use to load classes with. |
void |
setCodeGenerationEnabled(boolean flag)
By default, code generation is enabled. |
void |
setExceptionGuardianEnabled(boolean flag)
|
void |
setRuntimeContext(java.lang.Class contextClass)
Call to override the default runtime context class that a template is compiled to use. |
abstract boolean |
sourceExists(java.lang.String name)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Compiler()
public Compiler(java.util.Map parseTreeMap)
parseTreeMap - map should be thread-safe| Method Detail |
public void addErrorListener(ErrorListener listener)
ConsoleErrorReporterpublic void removeErrorListener(ErrorListener listener)
public void addStatusListener(StatusListener listener)
public void removeStatusListener(StatusListener listener)
public void setCodeGenerationEnabled(boolean flag)
public boolean isCodeGenerationEnabled()
public void setExceptionGuardianEnabled(boolean flag)
public boolean isExceptionGuardianEnabled()
public void setClassLoader(java.lang.ClassLoader loader)
public java.lang.ClassLoader getClassLoader()
public java.lang.Class loadClass(java.lang.String name)
throws java.lang.ClassNotFoundException
setClassLoader(ClassLoader)public void preserveParseTree(java.lang.String name)
name - fully qualified name of template whose parse tree is to be
preserved.
public java.lang.String[] compile(java.lang.String name)
throws java.io.IOException
name - the fully qualified template namejava.io.IOException -
public java.lang.String[] compile(java.lang.String[] names)
throws java.io.IOException
names - an array of fully qualified template namesjava.io.IOException - public int getErrorCount()
public CompilationUnit getCompilationUnit(java.lang.String name,
CompilationUnit from)
name - the requested namefrom - optional CompilationUnit is passed because requested name
should be found relative to it.public static final java.lang.String[] getImportedPackages()
public java.lang.Class getRuntimeContext()
Default implementation returns com.go.tea.runtime.UtilityContext.
UtilityContextpublic void setRuntimeContext(java.lang.Class contextClass)
Contextpublic final java.lang.reflect.Method[] getRuntimeContextMethods()
public java.lang.String getRuntimeReceiver()
Default implementation returns "print".
public java.lang.String getRuntimeStringConverter()
Default implementation returns "toString". Returning null indicates that a static String.valueOf method should be invoked.
public final java.lang.reflect.Method[] getStringConverterMethods()
public abstract boolean sourceExists(java.lang.String name)
protected abstract CompilationUnit createCompilationUnit(java.lang.String name)
protected SourceReader createSourceReader(CompilationUnit unit)
throws java.io.IOException
protected Scanner createScanner(SourceReader reader,
CompilationUnit unit)
throws java.io.IOException
protected Parser createParser(Scanner scanner,
CompilationUnit unit)
throws java.io.IOException
protected TypeChecker createTypeChecker(CompilationUnit unit)
protected CodeGenerator createCodeGenerator(CompilationUnit unit)
throws java.io.IOException
JavaClassGenerator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||