Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.velocity.app.Velocity
Method Summary | |
static void |
|
static void |
|
static void |
|
static void |
|
static boolean | |
static boolean | |
static boolean | |
static Object |
|
static Template |
|
static Template |
|
static void |
|
static void |
|
static void |
|
static void |
|
static boolean |
|
static boolean |
|
static boolean |
|
static boolean |
|
static void |
|
static void |
|
static void |
|
static void |
|
static boolean |
|
static void |
|
public static void addProperty(String key, Object value)
Add a Velocity Runtime property.
- Parameters:
public static void clearProperty(String key)
Clear a Velocity Runtime property.
- Parameters:
key
- of property to clear
public static void debug(Object message)
Log a debug message.
- Parameters:
public static void error(Object message)
Log an error message.
- Parameters:
public static boolean evaluate(Context context, Writer writer, String logTag, InputStream instream) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException
Deprecated. Use
evaluate( Context context, Writer writer, String logTag, Reader reader )
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 stringlogTag
- string to be used as the template name for log messages in case of errorinstream
- input stream containing the VTL to be rendered
- Returns:
- true if successful, false otherwise. If false, see Velocity runtime log
public static boolean evaluate(Context context, Writer writer, String logTag, Reader reader) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException
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 stringlogTag
- string to be used as the template name for log messages in case of errorreader
- Reader containing the VTL to be rendered
- Returns:
- true if successful, false otherwise. If false, see Velocity runtime log
- Since:
- Velocity v1.1
public static boolean evaluate(Context context, Writer out, String logTag, String instring) throws ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException
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 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
- Returns:
- true if successful, false otherwise. If false, see Velocity runtime log
public static Object getProperty(String key)
Get a Velocity Runtime property.
- Parameters:
key
- property to retrieve
- Returns:
- property value or null if the property not currently set
public static Template getTemplate(String name) throws ResourceNotFoundException, ParseErrorException, Exception
Returns aTemplate
from the Velocity resource management system.
- Parameters:
name
- The file name of the desired template.
- Returns:
- The template.
- Throws:
ResourceNotFoundException
- if template not found from any available source.ParseErrorException
- if template cannot be parsed due to syntax (or other) error.
public static Template getTemplate(String name, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception
Returns aTemplate
from the Velocity resource management system.
- Parameters:
name
- The file name of the desired template.encoding
- The character encoding to use for the template.
- Returns:
- The template.
- Throws:
ResourceNotFoundException
- if template not found from any available source.ParseErrorException
- if template cannot be parsed due to syntax (or other) error.
- Since:
- Velocity v1.1
public static void info(Object message)
Log an info message.
- Parameters:
public static void init() throws Exception
initialize the Velocity runtime engine, using the default properties of the Velocity distribution
public static void init(Properties p) throws Exception
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
public static void init(String propsFilename) throws Exception
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 initialize the Velocity runtime
public static boolean invokeVelocimacro(String vmName, String logTag, 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 calllogTag
- string to be used for template name in case of errorcontext
- Context object containing data/objects used for rendering.writer
- Writer for output stream
- Returns:
- true if Velocimacro exists and successfully invoked, false otherwise.
public static boolean mergeTemplate(String templateName, String encoding, Context context, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
merges a template and puts the rendered stream into the writer
- Parameters:
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
- Returns:
- true if successful, false otherwise. Errors logged to velocity log
- Since:
- Velocity v1.1
public static boolean mergeTemplate(String templateName, Context context, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
Deprecated. Use
mergeTemplate( 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 mergecontext
- filled context to be used in mergewriter
- writer to write template into
- Returns:
- true if successful, false otherwise. Errors logged to velocity log.
public 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.
- Parameters:
resourceName
- The name of the resource to search for.
- Returns:
- Whether the resource was located.
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.
- Parameters:
key
- object 'name' under which the object is storedvalue
- object to store under this key
public static void setConfiguration(Configuration configuration)
Deprecated. Use
setExtendedProperties(ExtendedProperties)
Set an entire configuration at once. This is useful in cases where the parent application uses the Configuration class and the velocity configuration is a subset of the parent application's configuration.
- Parameters:
public static void setExtendedProperties(ExtendedProperties configuration)
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:
public static void setProperty(String key, Object value)
Set a Velocity Runtime property.
- Parameters:
public static boolean templateExists(String resourceName)
Deprecated. Use resourceExists(String) instead.
- See Also:
resourceExists(String)
public static void warn(Object message)
Log a warning message.
- Parameters: