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.
author: Brian S O'Neill version: 58 , 7/26/01 See Also:com.go.tea.util.FileCompiler See Also:com.go.tea.util.ResourceCompiler
This constructor allows template signatures to be shared among compiler
instances. This is useful in interactive environments, where compilation
is occurring on a regular basis, but most called templates are not
being modified. The Compiler will map qualified template names to
ParseTree objects that have their code removed. Removing a template
entry from the map will force the compiler to re-parse the template if
it is called. Any template passed into the compile method will always be
re-parsed, even if its parse tree is already present in the map.
Parameters: parseTreeMap - map should be thread-safe
Compile a single compilation unit. This method can be called multiple
times, but it will not compile compilation units that have already been
compiled.
Parameters: name - the fully qualified template name The names of all the sources compiled by this compiler exception: IOException -
Compile a list of compilation units. This method can be called multiple
times, but it will not compile compilation units that have already been
compiled.
Parameters: names - an array of fully qualified template names The names of all the sources compiled by this compiler exception: IOException -
Returns a compilation unit associated with the given name, or null if
not found.
Parameters: name - the requested name Parameters: from - optional CompilationUnit is passed because requested nameshould be found relative to it.
final public static String[] getImportedPackages()(Code)
Returns the list of imported packages that all templates have. This
always returns "java.lang" and "java.util". Template parameters can
abbreviate the names of all classes in java.lang and java.util.
Return a class that defines a template's runtime context. The runtime
context contains methods that are callable by templates. A template
is compiled such that the first parameter of its execute method must
be an instance of the runtime context.
Return the name of a method in the runtime context to bind to for
receiving objects emitted by templates. The compiler will bind to the
closest matching public method based on the type of its single
parameter.
Return the name of a method in the runtime context to bind to for
converting objects and primitives to strings. The compiler will bind to
the closest matching public method based on the type of its single
parameter.
Default implementation returns "toString". Returning null indicates
that a static String.valueOf method should be invoked.
getStringConverterMethods
final publicMethod[] getStringConverterMethods()(Code)
Returns the set of methods that are used to perform conversion to
strings. The compiler will bind to the closest matching method based
on its parameter type.
Loads and returns a class by the fully qualified name given. If a
ClassLoader is specified, it is used to load the class. Otherwise,
the class is loaded via Class.forName.
See Also:Compiler.setClassLoader(ClassLoader)
After a template is compiled, all but the root node of its parse tree
is clipped, in order to save memory. Applications that wish to traverse
CompilationUnit parse trees should call this method to preserve them.
This method must be called prior to compilation and prior to requesting
a parse tree from a CompilationUnit.
Parameters: name - fully qualified name of template whose parse tree is to bepreserved.