|
.NET Framework | |||||||||
PREV TYPE NEXT TYPE | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONST | PROP | METHOD | OP | EVENT | DETAIL: FIELD | CONST | PROP | METHOD | OP | EVENT |
This class provides a separate new-able instance of the Velocity template engine. The alternative model for use is using the Velocity class which employs the singleton model. Please ensure that you call one of the init() variants. This is critical for proper behavior. Coming soon : Velocity will call the parameter-less init() at the first use of this class if the init() wasn't explicitly called. While this will ensure that Velocity functions, it almost certainly won't function in the way you intend, so please make sure to call init().
Constructor Summary | |
---|---|
VelocityEngine() Initializes a new instance of the VelocityEngine class. |
Property Summary | |
---|---|
Commons.Collections.ExtendedProperties |
ExtendedProperties
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. |
Method Summary | |
---|---|
void |
AddProperty(string key, object value_Renamed) Add a Velocity Runtime property. |
void |
ClearProperty(string key) Clear a Velocity Runtime property. |
void |
Debug(object message) Log a debug message. |
void |
Error(object message) Log an error message. |
bool |
Evaluate(NVelocity.Context.IContext context, System.IO.TextWriter writer, string logTag, System.IO.TextReader reader) 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. |
bool |
Evaluate(NVelocity.Context.IContext context, System.IO.TextWriter writer, string logTag, System.IO.Stream instream) 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. |
bool |
Evaluate(NVelocity.Context.IContext context, System.IO.TextWriter out_Renamed, string logTag, string instring) 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. |
object |
GetProperty(string key) Get a Velocity Runtime property. |
NVelocity.Template |
GetTemplate(string name, string encoding) Returns a Templatefrom the Velocity resource management system. |
NVelocity.Template |
GetTemplate(string name) Returns a Templatefrom the Velocity resource management system. |
void |
Info(object message) Log an info message. |
void |
Init(Commons.Collections.ExtendedProperties p) initialize the Velocity runtime engine, using default properties plus the properties in the passed in java.util.Properties object |
void |
Init(string propsFilename) initialize the Velocity runtime engine, using default properties plus the properties in the properties file passed in as the arg |
void |
Init() initialize the Velocity runtime engine, using the default properties of the Velocity distribution |
bool |
InvokeVelocimacro(string vmName, string logTag, string[] params_Renamed, NVelocity.Context.IContext context, System.IO.TextWriter 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. |
bool |
MergeTemplate(string templateName, string encoding, NVelocity.Context.IContext context, System.IO.TextWriter writer) merges a template and puts the rendered stream into the writer |
bool |
MergeTemplate(string templateName, NVelocity.Context.IContext context, System.IO.TextWriter writer) merges a template and puts the rendered stream into the writer |
void |
SetApplicationAttribute(object key, object value_Renamed) 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. |
void |
SetProperty(string key, object value_Renamed) Set a Velocity Runtime property. |
bool | TemplateExists(string templateName) |
void |
Warn(object message) Log a warning message. |
Methods inherited from class System.Object |
---|
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString |
Constructor Detail |
---|
public VelocityEngine()
Initializes a new instance of the VelocityEngine class.
Property Detail |
---|
public Commons.Collections.ExtendedProperties ExtendedProperties
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:
ExtendedProperties
- configuration
Method Detail |
---|
public void AddProperty(string key, object value_Renamed)
Add a Velocity Runtime property.
Parameters:
String
- key
Object
- value
public void ClearProperty(string key)
Clear a Velocity Runtime property.
Parameters:
key
- of property to clear
public void Debug(object message)
Log a debug message.
Parameters:
Object
- message to logpublic void Error(object message)
Log an error message.
Parameters:
Object
- message to logpublic bool Evaluate(NVelocity.Context.IContext context, System.IO.TextWriter writer, string logTag, System.IO.TextReader reader)
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 string
out
- Writer in which to render the output
logTag
- string to be used as the template name for log messages
in case of error
reader
- Reader containing the VTL to be rendered
public bool Evaluate(NVelocity.Context.IContext context, System.IO.TextWriter writer, string logTag, System.IO.Stream instream)
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 string
out
- Writer in which to render the output
logTag
- string to be used as the template name for log messages
in case of error
instream
- input stream containing the VTL to be rendered
public bool Evaluate(NVelocity.Context.IContext context, System.IO.TextWriter out_Renamed, string logTag, string instring)
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 string
out
- Writer in which to render the output
logTag
- string to be used as the template name for log
messages in case of error
instring
- input string containing the VTL to be rendered
public object GetProperty(string key)
Get a Velocity Runtime property.
Parameters:
key
- property to retrieve
public NVelocity.Template GetTemplate(string name, string encoding)
Returns a
Templatefrom the Velocity resource management system.
Parameters:
name
- The file name of the desired template.
encoding
- The character encoding to use for the template.
public NVelocity.Template GetTemplate(string name)
Returns a
Templatefrom the Velocity resource management system.
Parameters:
name
- The file name of the desired template.
public void Info(object message)
Log an info message.
Parameters:
Object
- message to logpublic void Init(Commons.Collections.ExtendedProperties p)
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 propertiespublic void Init(string propsFilename)
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 runtimepublic void Init()
initialize the Velocity runtime engine, using the default properties of the Velocity distribution
public bool InvokeVelocimacro(string vmName, string logTag, string[] params_Renamed, NVelocity.Context.IContext context, System.IO.TextWriter 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 call
logTag
- string to be used for template name in case of error
params[]
- 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
public bool MergeTemplate(string templateName, string encoding, NVelocity.Context.IContext context, System.IO.TextWriter writer)
merges a template and puts the rendered stream into the writer
Parameters:
templateName
- name of template to be used in merge
encoding
- encoding used in template
context
- filled context to be used in merge
writer
- writer to write template into
public bool MergeTemplate(string templateName, NVelocity.Context.IContext context, System.IO.TextWriter writer)
merges a template and puts the rendered stream into the writer
Parameters:
templateName
- name of template to be used in merge
context
- filled context to be used in merge
writer
- writer to write template into
public void SetApplicationAttribute(object key, object value_Renamed)
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 keypublic void SetProperty(string key, object value_Renamed)
Set a Velocity Runtime property.
Parameters:
String
- keyObject
- valuepublic bool TemplateExists(string templateName)
public void Warn(object message)
Log a warning message.
Parameters:
Object
- message to log
|
.NET Framework | |||||||||
PREV TYPE NEXT TYPE | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONST | PROP | METHOD | OP | EVENT | DETAIL: FIELD | CONST | PROP | METHOD | OP | EVENT |