Class RTFEngine
java.lang.Object
java.util.Observable
com.nomagic.magicreport.engine.AbstractTemplateEngine
com.nomagic.magicreport.engine.velocity.DefaultTemplateEngine
com.nomagic.magicreport.engine.velocity.RTFEngine
- All Implemented Interfaces:
IExtensionTemplateEngine,com.nomagic.magicreport.engine.IRuntimeInstanceVelocityEngine,ITemplateEngine,StyledDocument
This class provides an instance of the Velocity template engine.
- Since:
- Jun 11, 2007 10:49:57 PM
- Version:
- 1.0 Jun 11, 2007
-
Field Summary
Fields inherited from class com.nomagic.magicreport.engine.velocity.DefaultTemplateEngine
velocityContextFields inherited from class com.nomagic.magicreport.engine.AbstractTemplateEngine
context, isAborted, preProcessFile, processFile, properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintAppends the specified color to the document's color table.intAppends the specified font to the document's font table.intAppends the specified list item to the document's style table.intAppends object content into the document.intAppends the specified style to the document's style table.protected StringcreateComment(String message) Return a formatted comment from given message.protected ParseErrorExceptioncreateParseErrorWrapper(ParseErrorException parseError, Reader source) Create a ParseErrorException from the message.protected voidhandleForPage(Template template, StringBuilder inProcessBuffer) Handle the #forpage directive.protected voidhandleForRow(Template template, StringBuilder inProcessBuffer) Handle the #forrow directive.protected voidhandleSectionBegin(Template template, StringBuilder inProcessBuffer) Handle the #sectionBegin directive.protected intCount number of line from given content string.protected voidpostProcess(Template template) Perform a post-processing after the template has been evaluated.protected voidpreProcess(Template template) Perform a pre-processing before evaluate the template.protected TemplateExceptionprocessVelocityException(Template template, org.apache.velocity.exception.ParseErrorException e) Call this method to process an Velocity exception and return in new format.voidsetProperty(String key, Object value) Set an engine Runtime property.protected voidtranslate(Template template, StringBuilder inProcessBuffer) Translate the RTF document into valid VTL document.Methods inherited from class com.nomagic.magicreport.engine.velocity.DefaultTemplateEngine
abort, checkFileNotFoundException, clearTools, createTemplate, createTemplate, createTemplate, destroy, getClassLoader, getFormatter, getResolvedSectionName, handleImport, handleIncludeSection, isNoSpaceException, process, process, processException, processVelocityException, setClassLoader, setFormatter, setLatestLocation, setLocation, setWriterForEvaluate, trimTrailSpaceMethods inherited from class com.nomagic.magicreport.engine.AbstractTemplateEngine
addContext, addInvalidReferenceHandler, addObserver, addReferenceInsertionHandler, evaluate, evaluate, getConcurrentToolException, getContext, getCurrentRuntimeInstance, getInvalidReferenceHandler, getProcessSize, getProperties, getProperty, getReferenceInsertionHandler, isMemoryMode, notifyObservers, observers, setConcurrentToolException, setContext, setCurrentRuntimeInstanceMethods inherited from class java.util.Observable
clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
-
Constructor Details
-
RTFEngine
public RTFEngine()Create instance of engine.
-
-
Method Details
-
setProperty
Set an engine Runtime property.- Specified by:
setPropertyin interfaceITemplateEngine- Overrides:
setPropertyin classDefaultTemplateEngine- Parameters:
key- the key to be placed into this property list.value- the value corresponding to key.- See Also:
-
lineCount
Count number of line from given content string.- Overrides:
lineCountin classDefaultTemplateEngine- Parameters:
content- the input string- Returns:
- number of line
-
translate
protected void translate(Template template, StringBuilder inProcessBuffer) throws ParseErrorException, IOException Translate the RTF document into valid VTL document.- Overrides:
translatein classDefaultTemplateEngine- Parameters:
template- templateinProcessBuffer- in process buffer- Throws:
ParseErrorException- if a syntax or other error which prevents it from being parsed.IOException- if IO Error occurs while reading template.- See Also:
-
handleForPage
protected void handleForPage(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle the #forpage directive.- Overrides:
handleForPagein classDefaultTemplateEngine- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
handleForRow
protected void handleForRow(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle the #forrow directive.- Overrides:
handleForRowin classDefaultTemplateEngine- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
handleSectionBegin
protected void handleSectionBegin(Template template, StringBuilder inProcessBuffer) throws ParseErrorException Handle the #sectionBegin directive.- Overrides:
handleSectionBeginin classDefaultTemplateEngine- Parameters:
template- Template source.inProcessBuffer- in process buffer.- Throws:
ParseErrorException- when error while translation, or syntax not recognized.
-
createComment
Return a formatted comment from given message. The default comment format return from this method is "{\\*\\ {0}}" where {0} is message;- Overrides:
createCommentin classDefaultTemplateEngine- Parameters:
message- message to put in document comment- Returns:
- comment
-
processVelocityException
protected TemplateException processVelocityException(Template template, org.apache.velocity.exception.ParseErrorException e) Call this method to process an Velocity exception and return in new format. OverrideDefaultTemplateEngine.processVelocityException(Template, org.apache.velocity.exception.ParseErrorException)to return exception with valid RTF line count.- Overrides:
processVelocityExceptionin classDefaultTemplateEngine- Parameters:
template- Templatee- Velocity exception- Returns:
- TemplateException
-
createParseErrorWrapper
protected ParseErrorException createParseErrorWrapper(ParseErrorException parseError, Reader source) Create a ParseErrorException from the message.- Parameters:
parseError- root causesource- source template- Returns:
- instance of ParseErrorException
-
preProcess
Perform a pre-processing before evaluate the template.- Overrides:
preProcessin classDefaultTemplateEngine- Parameters:
template- template before evaluated.- Throws:
ParseErrorException- if a syntax or other error which prevents it from being parsed.InitializationEngineException- error while initializing engineTemplateException- other error while processing the template- See Also:
-
postProcess
Perform a post-processing after the template has been evaluated.- Overrides:
postProcessin classDefaultTemplateEngine- Parameters:
template- template after evaluated.- Throws:
ParseErrorException- if a syntax or other error which prevents it from being parsed.InitializationEngineException- error while initializing engineTemplateException- other error while processing the template- See Also:
-
addColor
Appends the specified color to the document's color table. Returns an index of color from table.- Specified by:
addColorin interfaceStyledDocument- Parameters:
color- specified color.- Returns:
- index of color from color table in document.
-
addFont
Appends the specified font to the document's font table. Returns an index of font from table.- Specified by:
addFontin interfaceStyledDocument- Parameters:
font- specified font.- Returns:
- index of font from font table in document.
-
addList
Appends the specified list item to the document's style table. Returns an index of list from table.- Specified by:
addListin interfaceStyledDocument- Parameters:
list- type of list- Returns:
- listTableSize index of list
-
addStyle
Appends the specified style to the document's style table. Return an index of style from table.- Specified by:
addStylein interfaceStyledDocument- Parameters:
style- a style. Reproduce from StyleContext.NamedStyle- Returns:
- index of style from style table in document.
-
addObject
Appends object content into the document.- Specified by:
addObjectin interfaceStyledDocument- Parameters:
object- adding object- Returns:
- index to object
-