Java Doc for VelocityEngine.java in  » Template-Engine » Velocity » org » apache » velocity » app » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Template Engine » Velocity » org.apache.velocity.app 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.velocity.app.VelocityEngine

VelocityEngine
public class VelocityEngine implements RuntimeConstants(Code)

This class provides a separate new-able instance of the Velocity template engine. The alternative model for use is using the Velocity class which employs the singleton model.

Please ensure that you call one of the init() variants. This is critical for proper behavior.

Coming soon : Velocity will call the parameter-less init() at the first use of this class if the init() wasn't explicitly called. While this will ensure that Velocity functions, it almost certainly won't function in the way you intend, so please make sure to call init().


version:
   $Id: VelocityEngine.java 471381 2006-11-05 08:56:58Z wglass $



Constructor Summary
public  VelocityEngine()
    
public  VelocityEngine(String propsFilename)
    
public  VelocityEngine(Properties p)
    

Method Summary
public  voidaddProperty(String key, Object value)
     Add a Velocity Runtime property.
public  voidclearProperty(String key)
     Clear a Velocity Runtime property.
public  voiddebug(Object message)
    
public  voiderror(Object message)
    
public  booleanevaluate(Context context, Writer out, String logTag, String instring)
     renders the input string using the context into the output writer. To be used when a template is dynamically constructed, or want to use Velocity as a token replacer.
Parameters:
  context - context to use in rendering input string
Parameters:
  out - Writer in which to render the output
Parameters:
  logTag - string to be used as the template name for logmessages in case of error
Parameters:
  instring - input string containing the VTL to be rendered true if successful, false otherwise.
public  booleanevaluate(Context context, Writer writer, String logTag, InputStream instream)
     Renders the input stream using the context into the output writer. To be used when a template is dynamically constructed, or want to use Velocity as a token replacer.
Parameters:
  context - context to use in rendering input string
Parameters:
  writer - Writer in which to render the output
Parameters:
  logTag - string to be used as the template name for log messagesin case of error
Parameters:
  instream - input stream containing the VTL to be rendered true if successful, false otherwise.
public  booleanevaluate(Context context, Writer writer, String logTag, Reader reader)
     Renders the input reader using the context into the output writer. To be used when a template is dynamically constructed, or want to use Velocity as a token replacer.
Parameters:
  context - context to use in rendering input string
Parameters:
  writer - Writer in which to render the output
Parameters:
  logTag - string to be used as the template name for log messagesin case of error
Parameters:
  reader - Reader containing the VTL to be rendered true if successful, false otherwise.
public  ObjectgetApplicationAttribute(Object key)
    

Return an application attribute (which can be any Object) that was set by the application in order to be accessible from any component of the system that gets a RuntimeServices.

public  LoggetLog()
     Returns a convenient Log instance that wraps the current LogChute. Use this to log error messages.
public  ObjectgetProperty(String key)
     Get a Velocity Runtime property.
public  TemplategetTemplate(String name)
     Returns a Template from the Velocity resource management system.
Parameters:
  name - The file name of the desired template.
public  TemplategetTemplate(String name, String encoding)
     Returns a Template from the Velocity resource management system.
Parameters:
  name - The file name of the desired template.
Parameters:
  encoding - The character encoding to use for the template.
public  voidinfo(Object message)
    
public  voidinit()
    
public  voidinit(String propsFilename)
    
public  voidinit(Properties p)
    
public  booleaninvokeVelocimacro(String vmName, String logTag, String params, Context context, Writer writer)
     Invokes a currently registered Velocimacro with the parms provided and places the rendered stream into the writer. Note : currently only accepts args to the VM if they are in the context.
Parameters:
  vmName - name of Velocimacro to call
Parameters:
  logTag - string to be used for template name in case of error
Parameters:
  params - args used to invoke Velocimacro.
public  booleanmergeTemplate(String templateName, Context context, Writer writer)
     Merges a template and puts the rendered stream into the writer. The default encoding that Velocity uses to read template files is defined in the property input.encoding and defaults to ISO-8859-1.
Parameters:
  templateName - name of template to be used in merge
Parameters:
  context - filled context to be used in merge
Parameters:
  writer - writer to write template into true if successful, false otherwise.
public  booleanmergeTemplate(String templateName, String encoding, Context context, Writer writer)
     merges a template and puts the rendered stream into the writer
Parameters:
  templateName - name of template to be used in merge
Parameters:
  encoding - encoding used in template
Parameters:
  context - filled context to be used in merge
Parameters:
  writer - writer to write template into true if successful, false otherwise.
public  booleanresourceExists(String resourceName)
     Determines if a resource is accessable via the currently configured resource loaders.
public  voidsetApplicationAttribute(Object key, Object value)
    

Sets an application attribute (which can be any Object) that will be accessible from any component of the system that gets a RuntimeServices.

public  voidsetExtendedProperties(ExtendedProperties configuration)
     Set an entire configuration at once.
public  voidsetProperty(String key, Object value)
     Set a Velocity Runtime property.
public  booleantemplateExists(String resourceName)
    
public  voidwarn(Object message)
    


Constructor Detail
VelocityEngine
public VelocityEngine()(Code)
Init-less CTOR



VelocityEngine
public VelocityEngine(String propsFilename) throws Exception(Code)
CTOR that invokes an init(String), initializing the engine using the properties file specified
Parameters:
  propsFilename - name of properties file to init with
throws:
  Exception -



VelocityEngine
public VelocityEngine(Properties p) throws Exception(Code)
CTOR that invokes an init(String), initializing the engine using the Properties specified
Parameters:
  p - name of properties to init with
throws:
  Exception -




Method Detail
addProperty
public void addProperty(String key, Object value)(Code)
Add a Velocity Runtime property.
Parameters:
  key -
Parameters:
  value -



clearProperty
public void clearProperty(String key)(Code)
Clear a Velocity Runtime property.
Parameters:
  key - of property to clear



debug
public void debug(Object message)(Code)

Parameters:
  message -



error
public void error(Object message)(Code)

Parameters:
  message -



evaluate
public boolean evaluate(Context context, Writer out, String logTag, String instring) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException(Code)
renders the input string using the context into the output writer. To be used when a template is dynamically constructed, or want to use Velocity as a token replacer.
Parameters:
  context - context to use in rendering input string
Parameters:
  out - Writer in which to render the output
Parameters:
  logTag - string to be used as the template name for logmessages in case of error
Parameters:
  instring - input string containing the VTL to be rendered true if successful, false otherwise. If false, seeVelocity runtime log
throws:
  ParseErrorException -
throws:
  MethodInvocationException -
throws:
  ResourceNotFoundException -
throws:
  IOException -



evaluate
public boolean evaluate(Context context, Writer writer, String logTag, InputStream instream) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException(Code)
Renders the input stream using the context into the output writer. To be used when a template is dynamically constructed, or want to use Velocity as a token replacer.
Parameters:
  context - context to use in rendering input string
Parameters:
  writer - Writer in which to render the output
Parameters:
  logTag - string to be used as the template name for log messagesin case of error
Parameters:
  instream - input stream containing the VTL to be rendered true if successful, false otherwise. If false, seeVelocity runtime log
throws:
  ParseErrorException -
throws:
  MethodInvocationException -
throws:
  ResourceNotFoundException -
throws:
  IOException - VelocityEngine.evaluate(Context context,Writer writer,String logTag,Reader reader)



evaluate
public boolean evaluate(Context context, Writer writer, String logTag, Reader reader) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException(Code)
Renders the input reader using the context into the output writer. To be used when a template is dynamically constructed, or want to use Velocity as a token replacer.
Parameters:
  context - context to use in rendering input string
Parameters:
  writer - Writer in which to render the output
Parameters:
  logTag - string to be used as the template name for log messagesin case of error
Parameters:
  reader - Reader containing the VTL to be rendered true if successful, false otherwise. If false, seeVelocity runtime log
throws:
  ParseErrorException -
throws:
  MethodInvocationException -
throws:
  ResourceNotFoundException -
throws:
  IOException -
since:
   Velocity v1.1



getApplicationAttribute
public Object getApplicationAttribute(Object key)(Code)

Return an application attribute (which can be any Object) that was set by the application in order to be accessible from any component of the system that gets a RuntimeServices. This allows communication between the application environment and custom pluggable components of the Velocity engine, such as ResourceLoaders and LogChutes.


Parameters:
  key - object 'name' under which the object is stored value object to store under this key



getLog
public Log getLog()(Code)
Returns a convenient Log instance that wraps the current LogChute. Use this to log error messages. It has the usual methods you'd expect. A log object.



getProperty
public Object getProperty(String key)(Code)
Get a Velocity Runtime property.
Parameters:
  key - property to retrieve property value or null if the propertynot currently set



getTemplate
public Template getTemplate(String name) throws ResourceNotFoundException, ParseErrorException, Exception(Code)
Returns a Template from the Velocity resource management system.
Parameters:
  name - The file name of the desired template. The template.
throws:
  ResourceNotFoundException - if template not foundfrom any available source.
throws:
  ParseErrorException - if template cannot be parsed dueto syntax (or other) error.
throws:
  Exception - if an error occurs in template initialization



getTemplate
public Template getTemplate(String name, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception(Code)
Returns a Template from the Velocity resource management system.
Parameters:
  name - The file name of the desired template.
Parameters:
  encoding - The character encoding to use for the template. The template.
throws:
  ResourceNotFoundException - if template not foundfrom any available source.
throws:
  ParseErrorException - if template cannot be parsed dueto syntax (or other) error.
throws:
  Exception - if an error occurs in template initialization
since:
   Velocity v1.1



info
public void info(Object message)(Code)

Parameters:
  message -



init
public void init() throws Exception(Code)
initialize the Velocity runtime engine, using the default properties of the Velocity distribution
throws:
  Exception -



init
public void init(String propsFilename) throws Exception(Code)
initialize the Velocity runtime engine, using default properties plus the properties in the properties file passed in as the arg
Parameters:
  propsFilename - file containing properties to use to initializethe Velocity runtime
throws:
  Exception -



init
public void init(Properties p) throws Exception(Code)
initialize the Velocity runtime engine, using default properties plus the properties in the passed in java.util.Properties object
Parameters:
  p - Proprties object containing initialization properties
throws:
  Exception -



invokeVelocimacro
public boolean invokeVelocimacro(String vmName, String logTag, String params, Context context, Writer writer) throws Exception(Code)
Invokes a currently registered Velocimacro with the parms provided and places the rendered stream into the writer. Note : currently only accepts args to the VM if they are in the context.
Parameters:
  vmName - name of Velocimacro to call
Parameters:
  logTag - string to be used for template name in case of error
Parameters:
  params - args used to invoke Velocimacro. In context key format :eg "foo","bar" (rather than "$foo","$bar")
Parameters:
  context - Context object containing data/objects used for rendering.
Parameters:
  writer - Writer for output stream true if Velocimacro exists and successfully invoked, false otherwise.
throws:
  Exception -



mergeTemplate
public boolean mergeTemplate(String templateName, Context context, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception(Code)
Merges a template and puts the rendered stream into the writer. The default encoding that Velocity uses to read template files is defined in the property input.encoding and defaults to ISO-8859-1.
Parameters:
  templateName - name of template to be used in merge
Parameters:
  context - filled context to be used in merge
Parameters:
  writer - writer to write template into true if successful, false otherwise. Errorslogged to velocity log.
throws:
  ResourceNotFoundException -
throws:
  ParseErrorException -
throws:
  MethodInvocationException -
throws:
  Exception - VelocityEngine.mergeTemplate(String templateName,String encoding,Context context,Writer writer)



mergeTemplate
public boolean mergeTemplate(String templateName, String encoding, Context context, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception(Code)
merges a template and puts the rendered stream into the writer
Parameters:
  templateName - name of template to be used in merge
Parameters:
  encoding - encoding used in template
Parameters:
  context - filled context to be used in merge
Parameters:
  writer - writer to write template into true if successful, false otherwise. Errorslogged to velocity log
throws:
  ResourceNotFoundException -
throws:
  ParseErrorException -
throws:
  MethodInvocationException -
throws:
  Exception -
since:
   Velocity v1.1



resourceExists
public boolean resourceExists(String resourceName)(Code)
Determines if a resource is accessable via the currently configured resource loaders.

Note that the current implementation will not change the state of the system in any real way - so this cannot be used to pre-load the resource cache, as the previous implementation did as a side-effect.

The previous implementation exhibited extreme lazyness and sloth, and the author has been flogged.
Parameters:
  resourceName - name of the resource to search for true if found, false otherwise



setApplicationAttribute
public void setApplicationAttribute(Object key, Object value)(Code)

Sets an application attribute (which can be any Object) that will be accessible from any component of the system that gets a RuntimeServices. This allows communication between the application environment and custom pluggable components of the Velocity engine, such as ResourceLoaders and LogChutes.

Note that there is no enforcement or rules for the key used - it is up to the application developer. However, to help make the intermixing of components possible, using the target Class name (e.g. com.foo.bar ) as the key might help avoid collision.


Parameters:
  key - object 'name' under which the object is stored
Parameters:
  value - object to store under this key



setExtendedProperties
public void setExtendedProperties(ExtendedProperties configuration)(Code)
Set an entire configuration at once. This is useful in cases where the parent application uses the ExtendedProperties class and the velocity configuration is a subset of the parent application's configuration.
Parameters:
  configuration -



setProperty
public void setProperty(String key, Object value)(Code)
Set a Velocity Runtime property.
Parameters:
  key -
Parameters:
  value -



templateExists
public boolean templateExists(String resourceName)(Code)

Parameters:
  resourceName - True if the template exists.
See Also:   VelocityEngine.resourceExists(String)



warn
public void warn(Object message)(Code)

Parameters:
  message -



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.