org.apache.velocity
Class Template
This class is used for controlling all template
operations. This class uses a parser created
by JavaCC to create an AST that is subsequently
traversed by a Visitor.
Template template = Velocity.getTemplate("test.wm");
Context context = new VelocityContext();
context.put("foo", "bar");
context.put("customer", new Customer());
template.merge(context, writer);
$Id: Template.java,v 1.36.4.1 2004/03/03 22:28:24 geirm Exp $
void | initDocument() - initializes the document.
|
void | merge(Context context, Writer writer) - The AST node structure is merged with the
context to produce the final output.
|
boolean | process() - gets the named resource as a stream, parses and inits
|
getData , getEncoding , getLastModified , getName , getResourceLoader , isSourceModified , process , requiresChecking , setData , setEncoding , setLastModified , setModificationCheckInterval , setName , setResourceLoader , setRuntimeServices , touch |
errorCondition
private Exception errorCondition
initialized
private boolean initialized
To keep track of whether this template has been
initialized. We use the document.init(context)
to perform this.
Template
public Template()
Default constructor
initDocument
public void initDocument()
throws Exception
initializes the document. init() is not longer
dependant upon context, but we need to let the
init() carry the template name down throught for VM
namespace features
merge
public void merge(Context context,
Writer writer)
throws ResourceNotFoundException,
ParseErrorException,
MethodInvocationException,
Exception
The AST node structure is merged with the
context to produce the final output.
Throws IOException if failure is due to a file related
issue, and Exception otherwise
context
- Conext with data elements accessed by templatewriter
- output writer for rendered template
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.