public class ODFEngine extends DefaultTemplateEngine implements StyledDocument
Modifier and Type | Class and Description |
---|---|
protected class |
ODFEngine.PostProcessHandler
Post processing content handler.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.List<java.awt.Color> |
colorList
Contains list of color being appended to report.
|
protected java.util.List<java.awt.Font> |
fontList
Contains list of font being appended to report.
|
protected java.util.List<ODFManifest> |
manifestList
Contains list of manifest being appended to report.
|
protected java.util.List<ODFStyle> |
styleList
Contains list of style object being appended to report.
|
velocityContext
context, isAborted, preProcessFile, processFile, properties
Constructor and Description |
---|
ODFEngine()
A class constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
addColor(java.awt.Color color)
Appends the specified color to the document's color table.
|
int |
addFont(java.awt.Font font)
Appends the specified font to the document's font table.
|
int |
addList(List list)
Appends the specified list item to the document's style table.
|
int |
addObject(java.lang.Object object)
Appends object content into the document.
|
int |
addStyle(javax.swing.text.Style style)
Appends the specified style to the document's style table.
|
protected java.lang.String |
createComment(java.lang.String message)
Return a formatted comment from given message.
|
protected ParseErrorException |
createParseErrorWrapper(ParseErrorException parseError,
java.io.Reader source)
Create a ParseErrorException from the message.
|
Template |
createTemplate()
Creates a new
ODFTemplate object. |
Template |
createTemplate(java.io.File input,
java.io.File output)
Creates a new
ODFTemplate object. |
Template |
createTemplate(java.io.File input,
java.io.File output,
boolean ignoreLocation)
Creates a new
Template object. |
void |
evaluate(Template template)
Merge a template with current context and rendered stream into the writer.
|
java.util.Set<java.lang.String> |
getEntrySet()
Return ODF entry set.
|
Template |
getTemplate()
Return template.
|
protected void |
handleContent(java.lang.StringBuffer inProcessBuffer)
Format ODF content.xml before generate report.
|
protected void |
handleForPage(Template template,
java.lang.StringBuffer inProcessBuffer)
Handle the #forpage directive.
|
protected void |
handleForRow(Template template,
java.lang.StringBuffer inProcessBuffer)
Handle the #forrow directive.
|
protected void |
handleMeta(java.lang.StringBuffer inProcessBuffer)
Format ODF meta.xml before generate report.
|
protected void |
handleVTLSyntax(java.lang.StringBuffer odfContent)
Manage and format the VTL syntax along with ODF syntax.
|
protected int |
lineCount(java.lang.String content)
Count number of line from given content string.
|
protected void |
postProcess(Template template)
Perform a post-processing after the template has been evaluated.
|
protected TemplateException |
processVelocityException(Template template,
org.apache.velocity.exception.ParseErrorException e)
Call this method to process an Velocity exception and return in new format.
|
protected java.lang.String |
splitVTLExpression(java.lang.String content,
java.lang.String openTag,
java.lang.String closeTag)
Extract the VTL syntax from content.
|
protected void |
translate(Template template,
java.lang.StringBuffer inProcessBuffer)
Process the template in
inProcessBuffer into valid format. |
abort, checkFileNotFoundException, destroy, getClassLoader, getFormatter, handleImport, handleIncludeSection, handleSectionBegin, isNoSpaceException, preProcess, process, process, processException, processVelocityException, setClassLoader, setFormatter, setLatestLocation, setLocation, setProperty, trimTrailSpace
addContext, addInvalidReferenceHandler, addObserver, addReferenceInsertionHandler, evaluate, getConcurrentToolException, getContext, getCurrentRuntimeInstance, getInvalidReferenceHandler, getProcessSize, getProperties, getProperty, getReferenceInsertionHandler, isMemoryMode, notifyObservers, observers, setConcurrentToolException, setContext, setCurrentRuntimeInstance
protected java.util.List<java.awt.Color> colorList
protected java.util.List<java.awt.Font> fontList
protected java.util.List<ODFStyle> styleList
protected java.util.List<ODFManifest> manifestList
public Template createTemplate()
ODFTemplate
object.createTemplate
in interface ITemplateEngine
createTemplate
in class DefaultTemplateEngine
ODFTemplate
DefaultTemplateEngine.createTemplate(File, File)
public Template createTemplate(java.io.File input, java.io.File output) throws java.io.IOException
ODFTemplate
object.createTemplate
in interface ITemplateEngine
createTemplate
in class DefaultTemplateEngine
input
- template file.output
- output file.ODFTemplate
java.io.FileNotFoundException
- if the file does not exist, is a directory rather than a regular file,
or for some other reason cannot be opened.java.io.IOException
- If an I/O error occurspublic Template createTemplate(java.io.File input, java.io.File output, boolean ignoreLocation) throws java.io.IOException
Template
object.createTemplate
in class DefaultTemplateEngine
input
- template file.output
- output file.ignoreLocation
- true to ignore location property for child documentTemplate
java.io.FileNotFoundException
- if the file does not exist, is a directory rather than a regular file,
or for some other reason cannot be opened.java.io.IOException
- If an I/O error occurspublic Template getTemplate()
public java.util.Set<java.lang.String> getEntrySet()
protected void handleVTLSyntax(java.lang.StringBuffer odfContent)
odfContent
- the ODF content.protected java.lang.String splitVTLExpression(java.lang.String content, java.lang.String openTag, java.lang.String closeTag)
content
- the content.openTag
- current open tagcloseTag
- current closed tagprotected void handleMeta(java.lang.StringBuffer inProcessBuffer)
inProcessBuffer
- in process buffer.protected void handleContent(java.lang.StringBuffer inProcessBuffer)
inProcessBuffer
- in process buffer.protected void translate(Template template, java.lang.StringBuffer inProcessBuffer) throws ParseErrorException, java.io.IOException
inProcessBuffer
into valid format.translate
in class DefaultTemplateEngine
template
- Template source.inProcessBuffer
- in process buffer.ParseErrorException
- when error while translation, or syntax not recognized.java.io.IOException
- if IO Error occurs while reading template.protected void handleForPage(Template template, java.lang.StringBuffer inProcessBuffer) throws ParseErrorException
handleForPage
in class DefaultTemplateEngine
template
- Template source.inProcessBuffer
- in process buffer.ParseErrorException
- when error while translation, or syntax not recognized.protected void handleForRow(Template template, java.lang.StringBuffer inProcessBuffer) throws ParseErrorException
handleForRow
in class DefaultTemplateEngine
template
- Template source.inProcessBuffer
- in process buffer.ParseErrorException
- when error while translation, or syntax not recognized.public void evaluate(Template template) throws TemplateException
evaluate
in interface ITemplateEngine
evaluate
in class AbstractTemplateEngine
template
- Template being evaluatedParseErrorException
- if a syntax or other error which prevents it from being
parsed.InitializationEngineException
- error while initializing engineTemplateException
- other error while processing the templateITemplateEngine.evaluate(Template)
protected void postProcess(Template template) throws TemplateException
postProcess
in class DefaultTemplateEngine
template
- template after evaluated.ParseErrorException
- if a syntax or other error which prevents it from being
parsed.InitializationEngineException
- error while initializing engineTemplateException
- other error while processing the templateAbstractTemplateEngine.postProcess(com.nomagic.magicreport.Template)
protected ParseErrorException createParseErrorWrapper(ParseErrorException parseError, java.io.Reader source)
parseError
- root causesource
- source templateprotected TemplateException processVelocityException(Template template, org.apache.velocity.exception.ParseErrorException e)
DefaultTemplateEngine.processVelocityException(Template, org.apache.velocity.exception.ParseErrorException)
to return exception with valid ODF line count.processVelocityException
in class DefaultTemplateEngine
template
- Templatee
- Velocity exceptionprotected int lineCount(java.lang.String content)
lineCount
in class DefaultTemplateEngine
content
- the input stringprotected java.lang.String createComment(java.lang.String message)
createComment
in class DefaultTemplateEngine
message
- message to put in document commentpublic int addColor(java.awt.Color color)
addColor
in interface StyledDocument
color
- specified color.public int addFont(java.awt.Font font)
addFont
in interface StyledDocument
font
- specified font.public int addList(List list)
addList
in interface StyledDocument
list
- specified list.public int addStyle(javax.swing.text.Style style)
addStyle
in interface StyledDocument
style
- a style. Reproduce from StyleContext.NamedStylepublic int addObject(java.lang.Object object)
addObject
in interface StyledDocument
object
- adding objectCopyright © 2010 - No Magic Asia