| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.velocity.runtime.resource.Resource
org.apache.velocity.Template
public 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.
 // set up and initialize Velocity before this code block
 Template template = Velocity.getTemplate("test.wm");
 Context context = new VelocityContext();
 context.put("foo", "bar");
 context.put("customer", new Customer());
 template.merge(context, writer);
 
| Field Summary | 
|---|
| Fields inherited from class org.apache.velocity.runtime.resource.Resource | 
|---|
data, encoding, lastModified, MILLIS_PER_SECOND, modificationCheckInterval, name, nextCheck, resourceLoader, rsvc, type | 
| Constructor Summary | |
|---|---|
Template()
Default constructor  | 
|
| Method Summary | |
|---|---|
 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.  | 
 void | 
merge(Context context,
      Writer writer,
      List macroLibraries)
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  | 
| Methods inherited from class org.apache.velocity.runtime.resource.Resource | 
|---|
getData, getEncoding, getLastModified, getName, getResourceLoader, getType, isSourceModified, requiresChecking, setData, setEncoding, setLastModified, setModificationCheckInterval, setName, setResourceLoader, setRuntimeServices, setType, touch | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public Template()
| Method Detail | 
|---|
public boolean process()
                throws ResourceNotFoundException,
                       ParseErrorException,
                       IOException
process in class ResourceResourceNotFoundException - if template not found
          from any available source.
ParseErrorException - if template cannot be parsed due
          to syntax (or other) error.
IOException - problem reading input stream
public void initDocument()
                  throws TemplateInitException
TemplateInitException - When a problem occurs during the document initialization.
public void merge(Context context,
                  Writer writer)
           throws ResourceNotFoundException,
                  ParseErrorException,
                  MethodInvocationException,
                  IOException
context - Conext with data elements accessed by templatewriter - output writer for rendered template
ResourceNotFoundException - if template not found
          from any available source.
ParseErrorException - if template cannot be parsed due
          to syntax (or other) error.
MethodInvocationException - When a method on a referenced object in the context could not invoked.
IOException - Might be thrown while rendering.
public void merge(Context context,
                  Writer writer,
                  List macroLibraries)
           throws ResourceNotFoundException,
                  ParseErrorException,
                  MethodInvocationException,
                  IOException
context - Conext with data elements accessed by templatewriter - output writer for rendered templatemacroLibraries - a list of template files containing macros to be used when merging
ResourceNotFoundException - if template not found
          from any available source.
ParseErrorException - if template cannot be parsed due
          to syntax (or other) error.
MethodInvocationException - When a method on a referenced object in the context could not invoked.
IOException - Might be thrown while rendering.
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||