Class AbstractXDocReport
java.lang.Object
fr.opensagres.xdocreport.document.AbstractXDocReport
- All Implemented Interfaces:
IXDocReport,Serializable
Abstract class for
IXDocReport to implement to manage docx, odt...- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPreprocessor(String entryName, IXDocPreprocessor preprocessor) Register a processor for the entry name.voidClear data.voidconvert(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.converter.Options options, OutputStream out) Generate report and Convert it to another format (PDF, XHTML, etc).voidconvert(Map<String, Object> contextMap, fr.opensagres.xdocreport.converter.Options options, OutputStream out) Generate report and Convert it to another format (PDF, XHTML, etc).fr.opensagres.xdocreport.template.IContextCreate an empty context to register Java model.fr.opensagres.xdocreport.template.IContextcreateContext(Map<String, Object> contextMap) Create a new instance ofIContextto put the Java model.fr.opensagres.xdocreport.template.formatter.FieldsMetadataCreate fields metadata.protected abstract IImageRegistrycreateImageRegistry(fr.opensagres.xdocreport.core.io.IEntryReaderProvider readerProvider, fr.opensagres.xdocreport.core.io.IEntryWriterProvider writerProvider, fr.opensagres.xdocreport.core.io.IEntryOutputStreamProvider outputStreamProvider) Create an image registry.protected voiddoPostprocessIfNeeded(fr.opensagres.xdocreport.core.io.XDocArchive outputArchive) voiddump(fr.opensagres.xdocreport.template.IContext context, DumperOptions options, OutputStream out) Dumpvoiddump(fr.opensagres.xdocreport.template.IContext context, InputStream documentIn, DumperOptions options, OutputStream out) DumpvoidextractFields(fr.opensagres.xdocreport.template.FieldsExtractor extractor) Extract declared fields which use syntax of the template egine of the report.voidextractFields(fr.opensagres.xdocreport.template.FieldsExtractor extractor, fr.opensagres.xdocreport.template.ITemplateEngine templateEngine) Extract declared fields which use syntax of the given template egine of the report.fr.opensagres.xdocreport.converter.IConvertergetConverter(fr.opensagres.xdocreport.converter.Options options) Returns converter for the report and options.<T> TReturns custom data.protected abstract String[]Returns default entries which define XML document to merge with Java model with template engine for odt, docx...getDumper(DumperOptions options) Returns the dumper for the given options.fr.opensagres.xdocreport.template.formatter.FieldsMetadataReturns fields metadata used to manage lazy loop for table row.getId()Returns the id of theIXDocReport.longReturns the last modified time when the report is loaded.fr.opensagres.xdocreport.core.io.XDocArchiveReturns the original zipped XML document (odt, docx...) and null if : no load was done. cache for original document is false (seeIXDocReport.setCacheOriginalDocument(boolean).fr.opensagres.xdocreport.core.io.XDocArchiveReturns the preprocessed zipped XML document (odt, docx...) and null if no load was done.fr.opensagres.xdocreport.template.ITemplateEngineReturns template engine (velocity, freemarker..) to use to merge Java model with the XML files of the from entries of the zipped XML Document (odt, docx...) defined bygetXMLEntries().String[]Returns XML entries which define XML document to merge with Java model with template engine.booleanReturns true if report was processed and false otherwise.voidload(InputStream sourceStream) Load XML document (odt, docx...) from input stream.protected voidonAfterPreprocessing(Map<String, Object> sharedContext, fr.opensagres.xdocreport.core.io.XDocArchive preprocessedArchive) On after preprocessing.protected voidonAfterProcessTemplateEngine(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.core.io.XDocArchive outputArchive) On after process template engine.protected voidonBeforePreprocessing(Map<String, Object> sharedContext, fr.opensagres.xdocreport.core.io.XDocArchive preprocessedArchive) On before preprocessing.protected voidonBeforeProcessTemplateEngine(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.core.io.XDocArchive outputArchive) On before process template engine.voidForce the preprocessing step.voidprocess(fr.opensagres.xdocreport.template.IContext context, OutputStream out) Merge the docx, odt document with Java model from the context and register the result to the output stream.voidprocess(fr.opensagres.xdocreport.template.IContext context, String entryName, OutputStream out) Generate report by merging Java model frm the context with XML Document (odt, docx...) preprocessed and store the result into output stream.voidprocess(Map<String, Object> contextMap, OutputStream out) Merge the docx, odt document with Java model from the context Map and register the result to the output stream.voidMerge the docx, odt document with Java model from the context Map and register the entryName transformed to the output stream.protected abstract voidRegister preprocessors.voidClear processor.voidremovePreprocessor(String entryName) Remove processor for the entry name.voidsave(ProcessState processState, OutputStream out) Save original|preprocessed XML document archive in the given output stream.voidsaveEntry(String entryName, ProcessState processState, OutputStream out) Save original|preprocessed entryName from XML document archive in the given output stream.voidsetCacheOriginalDocument(boolean cacheOriginalDocument) Set cache or not for original document archive.voidReturns XML entries which define XML document to merge with Java model with template engine.voidsetDocumentArchive(fr.opensagres.xdocreport.core.io.XDocArchive documentArchive) Returns the zipped XML document (odt, docx...).voidsetFieldsMetadata(fr.opensagres.xdocreport.template.formatter.FieldsMetadata fieldsMetadata) Set fields metadata used to manage lazy loop for table row.voidSet the id of theIXDocReport.voidsetTemplateEngine(fr.opensagres.xdocreport.template.ITemplateEngine templateEngine) Register template engine (velocity, freemarker..) to use to merge Java model with the XML files of the from entries of the zipped XML Document (odt, docx...) defined bygetXMLEntries().voidsetXMLEntries(String[] xmlEntries) Set XML entries which define XML document to merge with Java model with template engine.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface fr.opensagres.xdocreport.document.IXDocReport
getKind, getMimeMapping
-
Constructor Details
-
AbstractXDocReport
protected AbstractXDocReport()
-
-
Method Details
-
getId
Description copied from interface:IXDocReportReturns the id of theIXDocReport. This id is used to cache an instance ofIXDocReportwithand get instance from cache with- Specified by:
getIdin interfaceIXDocReport
-
setId
Description copied from interface:IXDocReportSet the id of theIXDocReport. This id is used to cache an instance ofIXDocReportwithand get instance from cache with- Specified by:
setIdin interfaceIXDocReport
-
load
public void load(InputStream sourceStream) throws IOException, fr.opensagres.xdocreport.core.XDocReportException Description copied from interface:IXDocReportLoad XML document (odt, docx...) from input stream.- Specified by:
loadin interfaceIXDocReport- Parameters:
sourceStream- stream of the XML Document zip (odt, docx...).- Throws:
IOException- when XML Document zip (odt, docx...) cannot be read.fr.opensagres.xdocreport.core.XDocReportException- when preprocessing withIXDocPreprocessorcannot be done.
-
setDocumentArchive
public void setDocumentArchive(fr.opensagres.xdocreport.core.io.XDocArchive documentArchive) throws IOException, fr.opensagres.xdocreport.core.XDocReportException Description copied from interface:IXDocReportReturns the zipped XML document (odt, docx...).- Specified by:
setDocumentArchivein interfaceIXDocReport- Parameters:
documentArchive-XDocArchive.- Throws:
fr.opensagres.xdocreport.core.XDocReportException- when preprocessing withIXDocPreprocessorcannot be done.IOException
-
getOriginalDocumentArchive
public fr.opensagres.xdocreport.core.io.XDocArchive getOriginalDocumentArchive()Description copied from interface:IXDocReportReturns the original zipped XML document (odt, docx...) and null if :- no load was done.
- cache for original document is false (see
IXDocReport.setCacheOriginalDocument(boolean).
- Specified by:
getOriginalDocumentArchivein interfaceIXDocReport- Returns:
-
getPreprocessedDocumentArchive
public fr.opensagres.xdocreport.core.io.XDocArchive getPreprocessedDocumentArchive()Description copied from interface:IXDocReportReturns the preprocessed zipped XML document (odt, docx...) and null if no load was done.- Specified by:
getPreprocessedDocumentArchivein interfaceIXDocReport- Returns:
-
getTemplateEngine
public fr.opensagres.xdocreport.template.ITemplateEngine getTemplateEngine()Returns template engine (velocity, freemarker..) to use to merge Java model with the XML files of the from entries of the zipped XML Document (odt, docx...) defined bygetXMLEntries().- Specified by:
getTemplateEnginein interfaceIXDocReport- Returns:
-
setTemplateEngine
public void setTemplateEngine(fr.opensagres.xdocreport.template.ITemplateEngine templateEngine) Register template engine (velocity, freemarker..) to use to merge Java model with the XML files of the from entries of the zipped XML Document (odt, docx...) defined bygetXMLEntries().- Specified by:
setTemplateEnginein interfaceIXDocReport
-
addPreprocessor
Register a processor for the entry name.- Specified by:
addPreprocessorin interfaceIXDocReport- Parameters:
entryName-preprocessor-
-
removePreprocessor
Remove processor for the entry name.- Specified by:
removePreprocessorin interfaceIXDocReport- Parameters:
entryName-
-
removeAllPreprocessors
public void removeAllPreprocessors()Clear processor.- Specified by:
removeAllPreprocessorsin interfaceIXDocReport
-
setFieldsMetadata
public void setFieldsMetadata(fr.opensagres.xdocreport.template.formatter.FieldsMetadata fieldsMetadata) Set fields metadata used to manage lazy loop for table row.- Specified by:
setFieldsMetadatain interfaceIXDocReport
-
getFieldsMetadata
public fr.opensagres.xdocreport.template.formatter.FieldsMetadata getFieldsMetadata()Returns fields metadata used to manage lazy loop for table row.- Specified by:
getFieldsMetadatain interfaceIXDocReport- Returns:
-
createFieldsMetadata
public fr.opensagres.xdocreport.template.formatter.FieldsMetadata createFieldsMetadata()Create fields metadata.- Specified by:
createFieldsMetadatain interfaceIXDocReport- Returns:
-
preprocess
Description copied from interface:IXDocReportForce the preprocessing step.- Specified by:
preprocessin interfaceIXDocReport- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionIOException
-
onBeforePreprocessing
protected void onBeforePreprocessing(Map<String, Object> sharedContext, fr.opensagres.xdocreport.core.io.XDocArchive preprocessedArchive) throws fr.opensagres.xdocreport.core.XDocReportExceptionOn before preprocessing.- Parameters:
sharedContext-preprocessedArchive-- Throws:
fr.opensagres.xdocreport.core.XDocReportException
-
onAfterPreprocessing
protected void onAfterPreprocessing(Map<String, Object> sharedContext, fr.opensagres.xdocreport.core.io.XDocArchive preprocessedArchive) throws fr.opensagres.xdocreport.core.XDocReportExceptionOn after preprocessing.- Parameters:
sharedContext-preprocessedArchive-- Throws:
fr.opensagres.xdocreport.core.XDocReportException
-
getXMLEntries
Returns XML entries which define XML document to merge with Java model with template engine.- Returns:
-
setXMLEntries
Set XML entries which define XML document to merge with Java model with template engine.- Parameters:
xmlEntries-
-
createContext
public fr.opensagres.xdocreport.template.IContext createContext() throws fr.opensagres.xdocreport.core.XDocReportExceptionCreate an empty context to register Java model.- Specified by:
createContextin interfaceIXDocReport- Returns:
- Throws:
fr.opensagres.xdocreport.core.XDocReportException
-
createContext
public fr.opensagres.xdocreport.template.IContext createContext(Map<String, Object> contextMap) throws fr.opensagres.xdocreport.core.XDocReportExceptionDescription copied from interface:IXDocReportCreate a new instance ofIContextto put the Java model.- Specified by:
createContextin interfaceIXDocReport- Returns:
- Throws:
fr.opensagres.xdocreport.core.XDocReportException
-
process
public void process(Map<String, Object> contextMap, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, IOExceptionDescription copied from interface:IXDocReportMerge the docx, odt document with Java model from the context Map and register the result to the output stream.- Specified by:
processin interfaceIXDocReportout- output stream where merge must be saved.- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionIOException
-
process
public void process(Map<String, Object> contextMap, String entryName, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, IOExceptionDescription copied from interface:IXDocReportMerge the docx, odt document with Java model from the context Map and register the entryName transformed to the output stream.- Specified by:
processin interfaceIXDocReportentryName- entry name- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionIOException
-
process
public void process(fr.opensagres.xdocreport.template.IContext context, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, IOException Description copied from interface:IXDocReportMerge the docx, odt document with Java model from the context and register the result to the output stream.- Specified by:
processin interfaceIXDocReport- Parameters:
context- of the Java model.out- output stream where merge must be saved.- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionIOException
-
process
public void process(fr.opensagres.xdocreport.template.IContext context, String entryName, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, IOException Generate report by merging Java model frm the context with XML Document (odt, docx...) preprocessed and store the result into output stream.- Specified by:
processin interfaceIXDocReport- Parameters:
context- of the Java model.entryName- entry name- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionIOException
-
doPostprocessIfNeeded
protected void doPostprocessIfNeeded(fr.opensagres.xdocreport.core.io.XDocArchive outputArchive) -
save
public void save(ProcessState processState, OutputStream out) throws IOException, fr.opensagres.xdocreport.core.XDocReportException Description copied from interface:IXDocReportSave original|preprocessed XML document archive in the given output stream.- Specified by:
savein interfaceIXDocReport- Throws:
IOExceptionfr.opensagres.xdocreport.core.XDocReportException
-
saveEntry
public void saveEntry(String entryName, ProcessState processState, OutputStream out) throws IOException, fr.opensagres.xdocreport.core.XDocReportException Description copied from interface:IXDocReportSave original|preprocessed entryName from XML document archive in the given output stream.- Specified by:
saveEntryin interfaceIXDocReport- Throws:
IOExceptionfr.opensagres.xdocreport.core.XDocReportException
-
extractFields
public void extractFields(fr.opensagres.xdocreport.template.FieldsExtractor extractor) throws fr.opensagres.xdocreport.core.XDocReportException, IOException Description copied from interface:IXDocReportExtract declared fields which use syntax of the template egine of the report.- Specified by:
extractFieldsin interfaceIXDocReport- Parameters:
extractor- the fields extractor.- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionIOException
-
extractFields
public void extractFields(fr.opensagres.xdocreport.template.FieldsExtractor extractor, fr.opensagres.xdocreport.template.ITemplateEngine templateEngine) throws fr.opensagres.xdocreport.core.XDocReportException, IOException Description copied from interface:IXDocReportExtract declared fields which use syntax of the given template egine of the report.- Specified by:
extractFieldsin interfaceIXDocReport- Parameters:
extractor- the fields extractor.templateEngine- the template engine.- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionIOException
-
getConverter
public fr.opensagres.xdocreport.converter.IConverter getConverter(fr.opensagres.xdocreport.converter.Options options) throws fr.opensagres.xdocreport.converter.XDocConverterException Description copied from interface:IXDocReportReturns converter for the report and options.- Specified by:
getConverterin interfaceIXDocReport- Returns:
- Throws:
fr.opensagres.xdocreport.converter.XDocConverterException
-
convert
public void convert(Map<String, Object> contextMap, fr.opensagres.xdocreport.converter.Options options, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, fr.opensagres.xdocreport.converter.XDocConverterException, IOExceptionDescription copied from interface:IXDocReportGenerate report and Convert it to another format (PDF, XHTML, etc).- Specified by:
convertin interfaceIXDocReport- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionfr.opensagres.xdocreport.converter.XDocConverterExceptionIOException
-
convert
public void convert(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.converter.Options options, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, fr.opensagres.xdocreport.converter.XDocConverterException, IOException Description copied from interface:IXDocReportGenerate report and Convert it to another format (PDF, XHTML, etc).- Specified by:
convertin interfaceIXDocReport- Throws:
fr.opensagres.xdocreport.core.XDocReportExceptionfr.opensagres.xdocreport.converter.XDocConverterExceptionIOException
-
onBeforeProcessTemplateEngine
protected void onBeforeProcessTemplateEngine(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.core.io.XDocArchive outputArchive) throws fr.opensagres.xdocreport.core.XDocReportException On before process template engine.- Parameters:
context-outputArchive-- Throws:
fr.opensagres.xdocreport.core.XDocReportException
-
onAfterProcessTemplateEngine
protected void onAfterProcessTemplateEngine(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.core.io.XDocArchive outputArchive) throws fr.opensagres.xdocreport.core.XDocReportException On after process template engine.- Parameters:
context-outputArchive-- Throws:
fr.opensagres.xdocreport.core.XDocReportException
-
getDefaultXMLEntries
Returns default entries which define XML document to merge with Java model with template engine for odt, docx...- Returns:
-
setData
Returns XML entries which define XML document to merge with Java model with template engine. If custom XML entries is not defined,getDefaultXMLEntries()are used.- Specified by:
setDatain interfaceIXDocReport
-
getData
Description copied from interface:IXDocReportReturns custom data.- Specified by:
getDatain interfaceIXDocReport- Returns:
-
clearData
Description copied from interface:IXDocReportClear data.- Specified by:
clearDatain interfaceIXDocReport
-
setCacheOriginalDocument
public void setCacheOriginalDocument(boolean cacheOriginalDocument) Description copied from interface:IXDocReportSet cache or not for original document archive.- Specified by:
setCacheOriginalDocumentin interfaceIXDocReport
-
registerPreprocessors
protected abstract void registerPreprocessors()Register preprocessors. -
isPreprocessed
public boolean isPreprocessed()Returns true if report was processed and false otherwise.- Specified by:
isPreprocessedin interfaceIXDocReport- Returns:
-
getLastModified
public long getLastModified()Returns the last modified time when the report is loaded.- Specified by:
getLastModifiedin interfaceIXDocReport- Returns:
-
createImageRegistry
protected abstract IImageRegistry createImageRegistry(fr.opensagres.xdocreport.core.io.IEntryReaderProvider readerProvider, fr.opensagres.xdocreport.core.io.IEntryWriterProvider writerProvider, fr.opensagres.xdocreport.core.io.IEntryOutputStreamProvider outputStreamProvider) Create an image registry.- Returns:
-
dump
public void dump(fr.opensagres.xdocreport.template.IContext context, DumperOptions options, OutputStream out) throws IOException, fr.opensagres.xdocreport.core.XDocReportException Description copied from interface:IXDocReportDump- Specified by:
dumpin interfaceIXDocReport- Throws:
IOExceptionfr.opensagres.xdocreport.core.XDocReportException
-
dump
public void dump(fr.opensagres.xdocreport.template.IContext context, InputStream documentIn, DumperOptions options, OutputStream out) throws IOException, fr.opensagres.xdocreport.core.XDocReportException Description copied from interface:IXDocReportDump- Specified by:
dumpin interfaceIXDocReport- Throws:
IOExceptionfr.opensagres.xdocreport.core.XDocReportException
-
getDumper
public IDumper getDumper(DumperOptions options) throws fr.opensagres.xdocreport.core.XDocReportException Description copied from interface:IXDocReportReturns the dumper for the given options.- Specified by:
getDumperin interfaceIXDocReport- Returns:
- Throws:
fr.opensagres.xdocreport.core.XDocReportException
-