public static boolean evaluate( Context context, Writer writer,
String logTag, Reader reader )
throws ParseErrorException, MethodInvocationException,
ResourceNotFoundException,IOException
{
SimpleNode nodeTree = null;
try
{
nodeTree = RuntimeSingleton.parse( reader, logTag );
}
catch ( ParseException pex )
{
throw new ParseErrorException( pex );
}
/*
* now we want to init and render
*/
if (nodeTree != null)
{
InternalContextAdapterImpl ica =
new InternalContextAdapterImpl( context );
ica.pushCurrentTemplateName( logTag );
try
{
try
{
nodeTree.init( ica, RuntimeSingleton.getRuntimeServices() );
}
catch( Exception e )
{
getLog().error("Velocity.evaluate() : init exception for tag = "+logTag, e);
}
/*
* now render, and let any exceptions fly
*/
nodeTree.render( ica, writer );
}
finally
{
ica.popCurrentTemplateName();
}