public class ReportVelocityEngine
extends org.apache.velocity.app.VelocityEngine
COUNTER_INITIAL_VALUE, COUNTER_NAME, DEBUG_PREFIX, DEFAULT_RUNTIME_DIRECTIVES, DEFAULT_RUNTIME_PROPERTIES, DEFINE_DIRECTIVE_MAXDEPTH, DIRECTIVE_IF_TOSTRING_NULLCHECK, ENCODING_DEFAULT, ERROR_PREFIX, ERRORMSG_END, ERRORMSG_START, EVALUATE_CONTEXT_CLASS, EVENTHANDLER_INCLUDE, EVENTHANDLER_INVALIDREFERENCES, EVENTHANDLER_METHODEXCEPTION, EVENTHANDLER_NULLSET, EVENTHANDLER_REFERENCEINSERTION, FILE_RESOURCE_LOADER_CACHE, FILE_RESOURCE_LOADER_PATH, HAS_NEXT_NAME, INFO_PREFIX, INPUT_ENCODING, INTERPOLATE_STRINGLITERALS, INTROSPECTOR_RESTRICT_CLASSES, INTROSPECTOR_RESTRICT_PACKAGES, MAX_NUMBER_LOOPS, NUMBER_OF_PARSERS, OUTPUT_ENCODING, PARSE_DIRECTIVE_MAXDEPTH, PARSER_POOL_CLASS, PARSER_POOL_SIZE, PROVIDE_SCOPE_CONTROL, RESOURCE_LOADER, RESOURCE_MANAGER_CACHE_CLASS, RESOURCE_MANAGER_CLASS, RESOURCE_MANAGER_DEFAULTCACHE_SIZE, RESOURCE_MANAGER_LOGWHENFOUND, RUNTIME_LOG, RUNTIME_LOG_ERROR_STACKTRACE, RUNTIME_LOG_INFO_STACKTRACE, RUNTIME_LOG_LOGSYSTEM, RUNTIME_LOG_LOGSYSTEM_CLASS, RUNTIME_LOG_REFERENCE_LOG_INVALID, RUNTIME_LOG_WARN_STACKTRACE, RUNTIME_REFERENCES_STRICT, RUNTIME_REFERENCES_STRICT_ESCAPE, SET_NULL_ALLOWED, SKIP_INVALID_ITERATOR, STRICT_MATH, TRACE_PREFIX, UBERSPECT_CLASSNAME, UNKNOWN_PREFIX, VM_ARGUMENTS_STRICT, VM_BODY_REFERENCE, VM_CONTEXT_LOCALSCOPE, VM_LIBRARY, VM_LIBRARY_AUTORELOAD, VM_LIBRARY_DEFAULT, VM_MAX_DEPTH, VM_MESSAGES_ON, VM_PERM_ALLOW_INLINE, VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, VM_PERM_INLINE_LOCAL, WARN_PREFIX
Constructor and Description |
---|
ReportVelocityEngine()
Init-less CTOR
|
ReportVelocityEngine(java.util.Properties p)
Construct a VelocityEngine instance with the specified initial properties.
|
ReportVelocityEngine(java.lang.String propsFilename)
Construct a VelocityEngine with the initial properties defined in the file
propsFilename
|
Modifier and Type | Method and Description |
---|---|
void |
addProperty(java.lang.String key,
java.lang.Object value)
Add a Velocity Runtime property.
|
void |
clearProperty(java.lang.String key)
Clear a Velocity Runtime property.
|
void |
debug(java.lang.Object message)
Deprecated.
Use getLog() and call warn() on it.
|
void |
error(java.lang.Object message)
Deprecated.
Use getLog() and call warn() on it.
|
boolean |
evaluate(org.apache.velocity.context.Context context,
java.io.Writer writer,
java.lang.String logTag,
java.io.InputStream instream)
|
boolean |
evaluate(org.apache.velocity.context.Context context,
java.io.Writer writer,
java.lang.String logTag,
java.io.Reader reader)
Renders the input reader using the context into the output writer.
|
boolean |
evaluate(org.apache.velocity.context.Context context,
java.io.Writer out,
java.lang.String logTag,
java.lang.String instring)
renders the input string using the context into the output writer.
|
java.lang.Object |
getApplicationAttribute(java.lang.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.
|
org.apache.velocity.runtime.log.Log |
getLog()
Returns a convenient Log instance that wraps the current LogChute.
|
java.lang.Object |
getProperty(java.lang.String key)
Get a Velocity Runtime property.
|
org.apache.velocity.runtime.RuntimeInstance |
getRuntimeInstance() |
org.apache.velocity.Template |
getTemplate(java.lang.String name)
Returns a
Template from the Velocity
resource management system. |
org.apache.velocity.Template |
getTemplate(java.lang.String name,
java.lang.String encoding)
Returns a
Template from the Velocity
resource management system. |
void |
info(java.lang.Object message)
Deprecated.
Use getLog() and call warn() on it.
|
void |
init()
initialize the Velocity runtime engine, using the default
properties of the Velocity distribution
|
void |
init(java.util.Properties p)
initialize the Velocity runtime engine, using default properties
plus the properties in the passed in java.util.Properties object
|
void |
init(java.lang.String propsFilename)
initialize the Velocity runtime engine, using default properties
plus the properties in the properties file passed in as the arg
|
boolean |
invokeVelocimacro(java.lang.String vmName,
java.lang.String logTag,
java.lang.String[] params,
org.apache.velocity.context.Context context,
java.io.Writer writer)
Invokes a currently registered Velocimacro with the params provided
and places the rendered stream into the writer.
|
void |
loadDirective(java.lang.String directiveClass)
Instantiates and loads the directive with some basic checks.
|
boolean |
mergeTemplate(java.lang.String templateName,
org.apache.velocity.context.Context context,
java.io.Writer writer)
|
boolean |
mergeTemplate(java.lang.String templateName,
java.lang.String encoding,
org.apache.velocity.context.Context context,
java.io.Writer writer)
merges a template and puts the rendered stream into the writer
|
void |
removeDirective(java.lang.String name)
Remove a directive.
|
boolean |
resourceExists(java.lang.String resourceName)
Determines if a resource is accessable via the currently
configured resource loaders.
|
void |
setApplicationAttribute(java.lang.Object key,
java.lang.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.
|
void |
setExtendedProperties(org.apache.commons.collections.ExtendedProperties configuration)
Set an entire configuration at once.
|
void |
setProperty(java.lang.String key,
java.lang.Object value)
Set a Velocity Runtime property.
|
void |
setRuntimeInstance(org.apache.velocity.runtime.RuntimeInstance runtimeInstance) |
boolean |
templateExists(java.lang.String resourceName)
Deprecated.
Use resourceExists(String) instead.
|
void |
warn(java.lang.Object message)
Deprecated.
Use getLog() and call warn() on it.
|
public ReportVelocityEngine()
public ReportVelocityEngine(java.lang.String propsFilename)
propsFilename
- property file namepublic ReportVelocityEngine(java.util.Properties p)
p
- properties for velocity enginepublic org.apache.velocity.runtime.RuntimeInstance getRuntimeInstance()
public void setRuntimeInstance(org.apache.velocity.runtime.RuntimeInstance runtimeInstance)
public void init()
init
in class org.apache.velocity.app.VelocityEngine
public void init(java.lang.String propsFilename)
init
in class org.apache.velocity.app.VelocityEngine
propsFilename
- file containing properties to use to initialize
the Velocity runtimepublic void init(java.util.Properties p)
init
in class org.apache.velocity.app.VelocityEngine
p
- Proprties object containing initialization propertiespublic void setProperty(java.lang.String key, java.lang.Object value)
setProperty
in class org.apache.velocity.app.VelocityEngine
key
- keyvalue
- valuepublic void addProperty(java.lang.String key, java.lang.Object value)
addProperty
in class org.apache.velocity.app.VelocityEngine
key
- keyvalue
- valuepublic void clearProperty(java.lang.String key)
clearProperty
in class org.apache.velocity.app.VelocityEngine
key
- of property to clearpublic void setExtendedProperties(org.apache.commons.collections.ExtendedProperties configuration)
setExtendedProperties
in class org.apache.velocity.app.VelocityEngine
configuration
- a configurationpublic java.lang.Object getProperty(java.lang.String key)
getProperty
in class org.apache.velocity.app.VelocityEngine
key
- property to retrievepublic boolean evaluate(org.apache.velocity.context.Context context, java.io.Writer out, java.lang.String logTag, java.lang.String instring) throws org.apache.velocity.exception.ParseErrorException, org.apache.velocity.exception.MethodInvocationException, org.apache.velocity.exception.ResourceNotFoundException
evaluate
in class org.apache.velocity.app.VelocityEngine
context
- context to use in rendering input stringout
- Writer in which to render the outputlogTag
- string to be used as the template name for log
messages in case of errorinstring
- input string containing the VTL to be renderedorg.apache.velocity.exception.ParseErrorException
- The template could not be parsed.org.apache.velocity.exception.MethodInvocationException
- A method on a context object could not be invoked.org.apache.velocity.exception.ResourceNotFoundException
- A referenced resource could not be loaded.public boolean evaluate(org.apache.velocity.context.Context context, java.io.Writer writer, java.lang.String logTag, java.io.InputStream instream) throws org.apache.velocity.exception.ParseErrorException, org.apache.velocity.exception.MethodInvocationException, org.apache.velocity.exception.ResourceNotFoundException, java.io.IOException
evaluate
in class org.apache.velocity.app.VelocityEngine
context
- context to use in rendering input stringwriter
- Writer in which to render the outputlogTag
- string to be used as the template name for log messages
in case of errorinstream
- input stream containing the VTL to be renderedorg.apache.velocity.exception.ParseErrorException
- The template could not be parsed.org.apache.velocity.exception.MethodInvocationException
- A method on a context object could not be invoked.org.apache.velocity.exception.ResourceNotFoundException
- A referenced resource could not be loaded.java.io.IOException
- i/o problem while reading templatepublic boolean evaluate(org.apache.velocity.context.Context context, java.io.Writer writer, java.lang.String logTag, java.io.Reader reader) throws org.apache.velocity.exception.ParseErrorException, org.apache.velocity.exception.MethodInvocationException, org.apache.velocity.exception.ResourceNotFoundException
evaluate
in class org.apache.velocity.app.VelocityEngine
context
- context to use in rendering input stringwriter
- Writer in which to render the outputlogTag
- string to be used as the template name for log messages
in case of errorreader
- Reader containing the VTL to be renderedorg.apache.velocity.exception.ParseErrorException
- The template could not be parsed.org.apache.velocity.exception.MethodInvocationException
- A method on a context object could not be invoked.org.apache.velocity.exception.ResourceNotFoundException
- A referenced resource could not be loaded.public boolean invokeVelocimacro(java.lang.String vmName, java.lang.String logTag, java.lang.String[] params, org.apache.velocity.context.Context context, java.io.Writer writer)
invokeVelocimacro
in class org.apache.velocity.app.VelocityEngine
vmName
- name of Velocimacro to calllogTag
- string to be used for template name in case of error. if null,
the vmName will be usedparams
- keys for args used to invoke Velocimacro, in java format
rather than VTL (eg "foo" or "bar" rather than "$foo" or "$bar")context
- Context object containing data/objects used for rendering.writer
- Writer for output streampublic boolean mergeTemplate(java.lang.String templateName, org.apache.velocity.context.Context context, java.io.Writer writer) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException, org.apache.velocity.exception.MethodInvocationException
mergeTemplate( String templateName, String encoding,
Context context, Writer writer )
mergeTemplate
in class org.apache.velocity.app.VelocityEngine
templateName
- name of template to be used in mergecontext
- filled context to be used in mergewriter
- writer to write template intoorg.apache.velocity.exception.ResourceNotFoundException
- A referenced resource could not be loaded.org.apache.velocity.exception.ParseErrorException
- The template could not be parsed.org.apache.velocity.exception.MethodInvocationException
- A method on a context object could not be invoked.public boolean mergeTemplate(java.lang.String templateName, java.lang.String encoding, org.apache.velocity.context.Context context, java.io.Writer writer) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException, org.apache.velocity.exception.MethodInvocationException
mergeTemplate
in class org.apache.velocity.app.VelocityEngine
templateName
- name of template to be used in mergeencoding
- encoding used in templatecontext
- filled context to be used in mergewriter
- writer to write template intoorg.apache.velocity.exception.ResourceNotFoundException
- A referenced resource could not be loaded.org.apache.velocity.exception.ParseErrorException
- The template could not be parsed.org.apache.velocity.exception.MethodInvocationException
- A method on a context object could not be invoked.public org.apache.velocity.Template getTemplate(java.lang.String name) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException
Template
from the Velocity
resource management system.getTemplate
in class org.apache.velocity.app.VelocityEngine
name
- The file name of the desired template.org.apache.velocity.exception.ResourceNotFoundException
- if template not found
from any available source.org.apache.velocity.exception.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.public org.apache.velocity.Template getTemplate(java.lang.String name, java.lang.String encoding) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException
Template
from the Velocity
resource management system.getTemplate
in class org.apache.velocity.app.VelocityEngine
name
- The file name of the desired template.encoding
- The character encoding to use for the template.org.apache.velocity.exception.ResourceNotFoundException
- if template not found
from any available source.org.apache.velocity.exception.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.public boolean resourceExists(java.lang.String resourceName)
resourceExists
in class org.apache.velocity.app.VelocityEngine
resourceName
- name of the resource to search forpublic boolean templateExists(java.lang.String resourceName)
templateExists
in class org.apache.velocity.app.VelocityEngine
resourceName
- template nameresourceExists(String)
public org.apache.velocity.runtime.log.Log getLog()
getLog
in class org.apache.velocity.app.VelocityEngine
public void warn(java.lang.Object message)
warn
in class org.apache.velocity.app.VelocityEngine
message
- log messagepublic void info(java.lang.Object message)
info
in class org.apache.velocity.app.VelocityEngine
message
- log messagepublic void error(java.lang.Object message)
error
in class org.apache.velocity.app.VelocityEngine
message
- log messagepublic void debug(java.lang.Object message)
debug
in class org.apache.velocity.app.VelocityEngine
message
- log messagepublic void setApplicationAttribute(java.lang.Object key, java.lang.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. 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.
setApplicationAttribute
in class org.apache.velocity.app.VelocityEngine
key
- object 'name' under which the object is storedvalue
- object to store under this keypublic java.lang.Object getApplicationAttribute(java.lang.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. This allows communication between the application environment and custom pluggable components of the Velocity engine, such as ResourceLoaders and LogChutes.
getApplicationAttribute
in class org.apache.velocity.app.VelocityEngine
key
- object 'name' under which the object is storedpublic void removeDirective(java.lang.String name)
removeDirective
in class org.apache.velocity.app.VelocityEngine
name
- name of the directive.public void loadDirective(java.lang.String directiveClass)
loadDirective
in class org.apache.velocity.app.VelocityEngine
directiveClass
- classname of directive to loadCopyright © 2010 - No Magic Asia