public interface RuntimeServices
Modifier and Type | Method and Description |
---|---|
void |
addProperty(String key,
Object value)
Add a property to the configuration.
|
boolean |
addVelocimacro(String name,
Node macro,
List<Macro.MacroArg> macroArgs,
Template definingTemplate)
Adds a new Velocimacro.
|
void |
clearProperty(String key)
Clear the values pertaining to a particular
property.
|
Parser |
createNewParser()
Create a new parser instance.
|
boolean |
evaluate(Context context,
Writer writer,
String logTag,
Reader reader)
Renders the input reader using the context into the output writer.
|
boolean |
evaluate(Context context,
Writer out,
String logTag,
String instring)
Renders the input string using the context into the output writer.
|
Object |
getApplicationAttribute(Object key)
Return the specified application attribute.
|
EventCartridge |
getApplicationEventCartridge()
Returns the event handlers for the application.
|
boolean |
getBoolean(String key,
boolean def)
Boolean property accessor method to hide the configuration implementation.
|
ExtProperties |
getConfiguration()
Return the velocity runtime configuration object.
|
ContentResource |
getContent(String name)
Returns a static content resource from the
resource manager.
|
ContentResource |
getContent(String name,
String encoding)
Returns a static content resource from the
resource manager.
|
Directive |
getDirective(String name)
Retrieve a previously instantiated directive.
|
int |
getInt(String key)
Int property accessor method to hide the configuration implementation.
|
int |
getInt(String key,
int defaultValue)
Int property accessor method to hide the configuration implementation.
|
String |
getLoaderNameForResource(String resourceName)
Determines is a template exists, and returns name of the loader that
provides it.
|
org.slf4j.Logger |
getLog()
Returns the configured logger.
|
org.slf4j.Logger |
getLog(String childNamespace)
Get a logger for the specified child namespace.
|
LogContext |
getLogContext()
Get the LogContext object used to tack locations in templates.
|
ParserConfiguration |
getParserConfiguration()
Get the replacement characters configured for this runtime service's parser
|
Object |
getProperty(String key)
Allows an external caller to get a property.
|
RuntimeConstants.SpaceGobbling |
getSpaceGobbling()
get space gobbling mode
|
String |
getString(String key)
String property accessor method to hide the configuration implementation
|
String |
getString(String key,
String defaultValue)
String property accessor method with default to hide the
configuration implementation.
|
Template |
getTemplate(String name)
Returns a
Template from the resource manager. |
Template |
getTemplate(String name,
String encoding)
Returns a
Template from the resource manager |
Uberspect |
getUberspect()
Returns the configured class introspection/reflection
implementation.
|
Directive |
getVelocimacro(String vmName,
Template renderingTemplate,
Template template)
Returns the appropriate VelocimacroProxy object if strVMname
is a valid current Velocimacro.
|
void |
init()
This is the primary initialization method in the Velocity
Runtime.
|
void |
init(Properties p)
Initialize the Velocity Runtime with a Properties
object.
|
void |
init(String configurationFile)
Initialize the Velocity Runtime with the name of
ExtProperties object.
|
boolean |
invokeVelocimacro(String vmName,
String logTag,
String[] params,
Context context,
Writer writer)
Invokes a currently registered Velocimacro with the params provided
and places the rendered stream into the writer.
|
boolean |
isHyphenAllowedInIdentifiers()
Get whether hyphens are allowed in identifiers
|
boolean |
isInitialized()
Returns true if the RuntimeInstance has been successfully initialized.
|
boolean |
isScopeControlEnabled(String scopeName)
Get whether to provide a scope control object for this scope
|
boolean |
isVelocimacro(String vmName,
Template template)
Checks to see if a VM exists
|
SimpleNode |
parse(Reader reader,
Template template)
Parse the input and return the root of
AST node structure.
|
Object |
setApplicationAttribute(Object key,
Object value)
Set the specified application attribute.
|
void |
setConfiguration(ExtProperties configuration)
Allow an external system to set an ExtProperties
object to use.
|
void |
setProperty(String key,
Object value)
Allows an external system to set a property in
the Velocity Runtime.
|
boolean |
useStringInterning()
Check whether the engine uses string interning
|
void init()
void setProperty(String key, Object value)
key
- property keyvalue
- property valuevoid setConfiguration(ExtProperties configuration)
configuration
- void addProperty(String key, Object value)
key
- value
- void clearProperty(String key)
key
- of property to clearObject getProperty(String key)
key
- property to returnvoid init(Properties p)
p
- void init(String configurationFile)
configurationFile
- SimpleNode parse(Reader reader, Template template) throws ParseException
reader
- inputstream retrieved by a resource loadertemplate
- template being parsedParseException
boolean evaluate(Context context, Writer out, String logTag, String instring)
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 renderedParseErrorException
- The template could not be parsed.MethodInvocationException
- A method on a context object could not be invoked.ResourceNotFoundException
- A referenced resource could not be loaded.boolean evaluate(Context context, Writer writer, String logTag, Reader reader)
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 renderedParseErrorException
- The template could not be parsed.MethodInvocationException
- A method on a context object could not be invoked.ResourceNotFoundException
- A referenced resource could not be loaded.boolean invokeVelocimacro(String vmName, String logTag, String[] params, Context context, Writer writer)
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 streamTemplate getTemplate(String name) throws ResourceNotFoundException, ParseErrorException
Template
from the resource manager.
This method assumes that the character encoding of the
template is set by the input.encoding
property. The default is UTF-8.name
- The file name of the desired template.ResourceNotFoundException
- if template not found
from any available source.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.Template getTemplate(String name, String encoding) throws ResourceNotFoundException, ParseErrorException
Template
from the resource managername
- The name of the desired template.encoding
- Character encoding of the templateResourceNotFoundException
- if template not found
from any available source.ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.ContentResource getContent(String name) throws ResourceNotFoundException, ParseErrorException
name
- Name of content resource to getResourceNotFoundException
- if template not found
from any available source.ParseErrorException
ContentResource getContent(String name, String encoding) throws ResourceNotFoundException, ParseErrorException
name
- Name of content resource to getencoding
- Character encoding to useResourceNotFoundException
- if template not found
from any available source.ParseErrorException
String getLoaderNameForResource(String resourceName)
resourceName
- Name of template or content resourceString getString(String key, String defaultValue)
key
- property keydefaultValue
- default value to return if key not
found in resource manager.Directive getVelocimacro(String vmName, Template renderingTemplate, Template template)
vmName
- Name of velocimacro requestedrenderingTemplate
- Template we are currently rendering. This
information is needed when VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL setting is true
and template contains a macro with the same name as the global macro library.template
- current templateboolean addVelocimacro(String name, Node macro, List<Macro.MacroArg> macroArgs, Template definingTemplate)
name
- Name of velocimacromacro
- root AST node of the parsed macromacroArgs
- Array of macro arguments, containing the
#macro() arguments and default values. the 0th is the name.definingTemplate
- template containing macro definitionboolean isVelocimacro(String vmName, Template template)
vmName
- Name of velocimacrotemplate
- Template "namespace"String getString(String key)
key
- property keyint getInt(String key)
key
- property keyint getInt(String key, int defaultValue)
key
- property keydefaultValue
- default valueboolean getBoolean(String key, boolean def)
key
- property keydef
- default default value if property not foundExtProperties getConfiguration()
Object getApplicationAttribute(Object key)
key
- The name of the attribute to retrieve.Object setApplicationAttribute(Object key, Object value)
key
- The name of the attribute to set.value
- The attribute value to set.Uberspect getUberspect()
org.slf4j.Logger getLog()
org.slf4j.Logger getLog(String childNamespace)
childNamespace
- LogContext getLogContext()
EventCartridge getApplicationEventCartridge()
boolean isInitialized()
Parser createNewParser()
Directive getDirective(String name)
name
- name of the directiveboolean useStringInterning()
RuntimeConstants.SpaceGobbling getSpaceGobbling()
boolean isHyphenAllowedInIdentifiers()
boolean isScopeControlEnabled(String scopeName)
scopeName
- ParserConfiguration getParserConfiguration()
Copyright © 2000–2021 The Apache Software Foundation. All rights reserved.