|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.app.Velocity
public class Velocity
This class provides services to the application developer, such as :
Field Summary |
---|
Constructor Summary | |
---|---|
Velocity()
|
Method Summary | |
---|---|
static void |
addProperty(String key,
Object value)
Add a Velocity Runtime property. |
static void |
clearProperty(String key)
Clear a Velocity Runtime property. |
static boolean |
evaluate(Context context,
Writer writer,
String logTag,
InputStream instream)
Deprecated. Use evaluate( Context context, Writer writer,
String logTag, Reader reader ) |
static boolean |
evaluate(Context context,
Writer writer,
String logTag,
Reader reader)
Renders the input reader using the context into the output writer. |
static boolean |
evaluate(Context context,
Writer out,
String logTag,
String instring)
renders the input string using the context into the output writer. |
static Object |
getProperty(String key)
Get a Velocity Runtime property. |
static Template |
getTemplate(String name)
Returns a Template from the Velocity
resource management system. |
static Template |
getTemplate(String name,
String encoding)
Returns a Template from the Velocity
resource management system. |
static void |
init()
initialize the Velocity runtime engine, using the default properties of the Velocity distribution |
static void |
init(Properties p)
initialize the Velocity runtime engine, using default properties plus the properties in the passed in java.util.Properties object |
static void |
init(String propsFilename)
initialize the Velocity runtime engine, using default properties plus the properties in the properties file passed in as the arg |
static boolean |
invokeVelocimacro(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. |
static boolean |
mergeTemplate(String templateName,
Context context,
Writer writer)
Deprecated. Use mergeTemplate( String templateName, String encoding,
Context context, Writer writer ) |
static boolean |
mergeTemplate(String templateName,
String encoding,
Context context,
Writer writer)
merges a template and puts the rendered stream into the writer |
static boolean |
resourceExists(String resourceName)
Determines whether a resource is accessable via the currently configured resource loaders. |
static void |
setApplicationAttribute(Object key,
Object value)
Set the an ApplicationAttribue, which is an Object set by the application which is accessable from any component of the system that gets a RuntimeServices. |
static void |
setConfiguration(Configuration configuration)
Deprecated. Use setExtendedProperties( ExtendedProperties ) |
static void |
setExtendedProperties(org.apache.commons.collections.ExtendedProperties configuration)
Set an entire configuration at once. |
static void |
setProperty(String key,
Object value)
Set a Velocity Runtime property. |
static boolean |
templateExists(String resourceName)
Deprecated. Use resourceExists(String) instead. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Velocity()
Method Detail |
---|
public static void init() throws Exception
Exception
public static void init(String propsFilename) throws Exception
propsFilename
- file containing properties to use to initialize
the Velocity runtime
Exception
public static void init(Properties p) throws Exception
p
- Proprties object containing initialization properties
Exception
public static void setProperty(String key, Object value)
key
- value
- public static void addProperty(String key, Object value)
key
- value
- public static void clearProperty(String key)
key
- of property to clear@Deprecated public static void setConfiguration(Configuration configuration)
setExtendedProperties( ExtendedProperties )
configuration
- configurationpublic static void setExtendedProperties(org.apache.commons.collections.ExtendedProperties configuration)
configuration
- public static Object getProperty(String key)
key
- property to retrieve
public static boolean evaluate(Context context, Writer out, String logTag, String instring) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException
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
MethodInvocationException
ResourceNotFoundException
IOException
@Deprecated public static boolean evaluate(Context context, Writer writer, String logTag, InputStream instream) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException
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 errorinstream
- input stream containing the VTL to be rendered
ParseErrorException
MethodInvocationException
ResourceNotFoundException
IOException
public static boolean evaluate(Context context, Writer writer, String logTag, Reader reader) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException
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
MethodInvocationException
ResourceNotFoundException
IOException
public static 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 errorparams
- args used to invoke Velocimacro. In context key format :
eg "foo","bar" (rather than "$foo","$bar")context
- Context object containing data/objects used for rendering.writer
- Writer for output stream
@Deprecated public static boolean mergeTemplate(String templateName, Context context, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
mergeTemplate( String templateName, String encoding,
Context context, Writer writer )
templateName
- name of template to be used in mergecontext
- filled context to be used in mergewriter
- writer to write template into
ResourceNotFoundException
ParseErrorException
MethodInvocationException
Exception
public static boolean mergeTemplate(String templateName, String encoding, Context context, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
templateName
- name of template to be used in mergeencoding
- encoding used in templatecontext
- filled context to be used in mergewriter
- writer to write template into
ResourceNotFoundException
ParseErrorException
MethodInvocationException
Exception
public static Template getTemplate(String name) throws ResourceNotFoundException, ParseErrorException, Exception
Template
from the Velocity
resource management system.
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.
Exception
- if an error occurs in template initializationpublic static Template getTemplate(String name, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception
Template
from the Velocity
resource management system.
name
- The file name of the desired template.encoding
- The character encoding to use for the template.
ResourceNotFoundException
- if template not found
from any available source.
ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.
Exception
- if an error occurs in template initializationpublic static boolean resourceExists(String resourceName)
Determines whether a resource is accessable via the
currently configured resource loaders. Resource
is the generic
description of templates, static content, etc.
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.
resourceName
- The name of the resource to search for.
public static void setApplicationAttribute(Object key, Object value)
Set the an ApplicationAttribue, which is an Object set by the application which is accessable 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 loaders and loggers.
Note that there is no enfocement 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.
key
- object 'name' under which the object is storedvalue
- object to store under this key@Deprecated public static boolean templateExists(String resourceName)
resourceExists(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |