ccc.plugins.scripting
Class AbstractTextProcessor

java.lang.Object
  extended by ccc.plugins.scripting.AbstractTextProcessor
All Implemented Interfaces:
TextProcessor
Direct Known Subclasses:
ScriptRunner, VelocityProcessor

public abstract class AbstractTextProcessor
extends java.lang.Object
implements TextProcessor

Abstract base class for implementing text processors.

Author:
Civic Computing Ltd.

Constructor Summary
AbstractTextProcessor()
           
 
Method Summary
protected  void handleException(java.lang.Exception e, java.lang.String engine, java.lang.String title, int lineNo, int colNo)
          Handle a processor exception.
 java.lang.String render(Script template, Context context)
          Render a resource with the specified template.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ccc.plugins.scripting.TextProcessor
render, setWhitelist
 

Constructor Detail

AbstractTextProcessor

public AbstractTextProcessor()
Method Detail

render

public final java.lang.String render(Script template,
                                     Context context)
                              throws ProcessingException
Render a resource with the specified template.

The rendered output will be stored in memory as a String. Therefore, caution should be taken that this method is not used to generate large output, otherwise an OutOfMemoryError could be thrown.

Specified by:
render in interface TextProcessor
Parameters:
template - The template used to render the resource.
context - Additional values that are passed to the template.
Returns:
The html rendering as a string.
Throws:
ProcessingException - If an error occurs during rendering.

handleException

protected final void handleException(java.lang.Exception e,
                                     java.lang.String engine,
                                     java.lang.String title,
                                     int lineNo,
                                     int colNo)
                              throws ProcessingException
Handle a processor exception.

Parameters:
e - The engine-specific exception.
engine - The name of the text processing engine.
title - The title of the script.
lineNo - The line that caused the exception.
colNo - The column that caused the exception.
Throws:
ProcessingException - A processing exception wrapping the engine-specific exception.


Copyright © 2010. All Rights Reserved.