|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RuntimeServices
Interface for internal runtime services that are needed by the various components w/in Velocity. This was taken from the old Runtime singleton, and anything not necessary was removed. Currently implemented by RuntimeInstance.
Method Summary | |
---|---|
void |
addProperty(String key,
Object value)
Add a property to the configuration. |
boolean |
addVelocimacro(String name,
Node macro,
String[] argArray,
String sourceTemplate)
Adds a new Velocimacro. |
boolean |
addVelocimacro(String name,
String macro,
String[] argArray,
String sourceTemplate)
Deprecated. Use addVelocimacro(String, Node, String[], String) instead |
void |
clearProperty(String key)
Clear the values pertaining to a particular property. |
Parser |
createNewParser()
Create a new parser instance. |
boolean |
dumpVMNamespace(String namespace)
tells the vmFactory to dump the specified namespace. |
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. |
ExtendedProperties |
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. |
Introspector |
getIntrospector()
Returns the configured method introspection/reflection implementation. |
String |
getLoaderNameForResource(String resourceName)
Determines is a template exists, and returns name of the loader that provides it. |
Log |
getLog()
Returns a convenient Log instance that wraps the current LogChute. |
Object |
getProperty(String key)
Allows an external caller to get a property. |
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,
String templateName)
Returns the appropriate VelocimacroProxy object if strVMname is a valid current Velocimacro. |
Directive |
getVelocimacro(String vmName,
String templateName,
String renderingTemplate)
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 ExtendedProperties 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 |
isInitialized()
Returns true if the RuntimeInstance has been successfully initialized. |
boolean |
isVelocimacro(String vmName,
String templateName)
Checks to see if a VM exists |
SimpleNode |
parse(Reader reader,
String templateName)
Parse the input and return the root of AST node structure. |
SimpleNode |
parse(Reader reader,
String templateName,
boolean dumpNamespace)
Parse the input and return the root of the AST node structure. |
SimpleNode |
parse(String string,
String templateName)
Wraps the String in a StringReader and passes it off to parse(Reader,String) . |
Object |
setApplicationAttribute(Object key,
Object value)
Set the specified application attribute. |
void |
setConfiguration(ExtendedProperties configuration)
Allow an external system to set an ExtendedProperties object to use. |
void |
setProperty(String key,
Object value)
Allows an external system to set a property in the Velocity Runtime. |
Methods inherited from interface org.apache.velocity.runtime.RuntimeLogger |
---|
debug, error, info, warn |
Method Detail |
---|
void init()
void setProperty(String key, Object value)
key
- property keyvalue
- property valuevoid setConfiguration(ExtendedProperties 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 return
void init(Properties p)
p
- void init(String configurationFile)
configurationFile
- SimpleNode parse(String string, String templateName) throws ParseException
parse(Reader,String)
.
ParseException
SimpleNode parse(Reader reader, String templateName) throws ParseException
reader
- inputstream retrieved by a resource loadertemplateName
- name of the template being parsed
ParseException
SimpleNode parse(Reader reader, String templateName, boolean dumpNamespace) throws ParseException
reader
- inputstream retrieved by a resource loadertemplateName
- name of the template being parseddumpNamespace
- flag to dump the Velocimacro namespace for this template
ParseException
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 rendered
ParseErrorException
- 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.
IOException
- While rendering to the writer, an I/O problem occured.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 rendered
ParseErrorException
- 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 stream
Template 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 "ISO-8859-1"
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 manager
name
- The name of the desired template.encoding
- Character encoding of the template
ResourceNotFoundException
- 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 get
ResourceNotFoundException
- 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 use
ResourceNotFoundException
- if template not found
from any available source.
ParseErrorException
String getLoaderNameForResource(String resourceName)
resourceName
- Name of template or content resource
String getString(String key, String defaultValue)
key
- property keydefaultValue
- default value to return if key not
found in resource manager.
Directive getVelocimacro(String vmName, String templateName)
vmName
- Name of velocimacro requestedtemplateName
- Name of the namespace.
Directive getVelocimacro(String vmName, String templateName, String renderingTemplate)
vmName
- Name of velocimacro requestedtemplateName
- Name of the namespace.renderingTemplate
- Name of the 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.
boolean addVelocimacro(String name, String macro, String[] argArray, String sourceTemplate)
name
- Name of velocimacromacro
- String form of macro bodyargArray
- Array of strings, containing the
#macro() arguments. the 0th is the name.sourceTemplate
-
boolean addVelocimacro(String name, Node macro, String[] argArray, String sourceTemplate)
name
- Name of velocimacromacro
- root AST node of the parsed macroargArray
- Array of strings, containing the
#macro() arguments. the 0th is the name.sourceTemplate
-
boolean isVelocimacro(String vmName, String templateName)
vmName
- Name of velocimacrotemplateName
-
boolean dumpVMNamespace(String namespace)
namespace
-
String getString(String key)
key
- property key
int getInt(String key)
key
- property key
int getInt(String key, int defaultValue)
key
- property keydefaultValue
- default value
boolean getBoolean(String key, boolean def)
key
- property keydef
- default default value if property not found
ExtendedProperties 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()
Log getLog()
EventCartridge getApplicationEventCartridge()
Introspector getIntrospector()
boolean isInitialized()
Parser createNewParser()
Directive getDirective(String name)
name
- name of the directive
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |