Class AbstractXDocReport

java.lang.Object
fr.opensagres.xdocreport.document.AbstractXDocReport
All Implemented Interfaces:
IXDocReport, Serializable

public abstract class AbstractXDocReport extends Object implements IXDocReport
Abstract class for IXDocReport to implement to manage docx, odt...
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addPreprocessor(String entryName, IXDocPreprocessor preprocessor)
    Register a processor for the entry name.
    void
    Clear data.
    void
    convert(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).
    void
    convert(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.IContext
    Create an empty context to register Java model.
    fr.opensagres.xdocreport.template.IContext
    Create a new instance of IContext to put the Java model.
    fr.opensagres.xdocreport.template.formatter.FieldsMetadata
    Create fields metadata.
    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.
    protected void
    doPostprocessIfNeeded(fr.opensagres.xdocreport.core.io.XDocArchive outputArchive)
     
    void
    dump(fr.opensagres.xdocreport.template.IContext context, DumperOptions options, OutputStream out)
    Dump
    void
    dump(fr.opensagres.xdocreport.template.IContext context, InputStream documentIn, DumperOptions options, OutputStream out)
    Dump
    void
    extractFields(fr.opensagres.xdocreport.template.FieldsExtractor extractor)
    Extract declared fields which use syntax of the template egine of the report.
    void
    extractFields(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.IConverter
    getConverter(fr.opensagres.xdocreport.converter.Options options)
    Returns converter for the report and options.
    <T> T
    Returns custom data.
    protected abstract String[]
    Returns default entries which define XML document to merge with Java model with template engine for odt, docx...
    Returns the dumper for the given options.
    fr.opensagres.xdocreport.template.formatter.FieldsMetadata
    Returns fields metadata used to manage lazy loop for table row.
    Returns the id of the IXDocReport.
    long
    Returns the last modified time when the report is loaded.
    fr.opensagres.xdocreport.core.io.XDocArchive
    Returns the original zipped XML document (odt, docx...) and null if : no load was done. cache for original document is false (see IXDocReport.setCacheOriginalDocument(boolean).
    fr.opensagres.xdocreport.core.io.XDocArchive
    Returns the preprocessed zipped XML document (odt, docx...) and null if no load was done.
    fr.opensagres.xdocreport.template.ITemplateEngine
    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 by getXMLEntries().
    Returns XML entries which define XML document to merge with Java model with template engine.
    boolean
    Returns true if report was processed and false otherwise.
    void
    load(InputStream sourceStream)
    Load XML document (odt, docx...) from input stream.
    protected void
    onAfterPreprocessing(Map<String,Object> sharedContext, fr.opensagres.xdocreport.core.io.XDocArchive preprocessedArchive)
    On after preprocessing.
    protected void
    onAfterProcessTemplateEngine(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.core.io.XDocArchive outputArchive)
    On after process template engine.
    protected void
    onBeforePreprocessing(Map<String,Object> sharedContext, fr.opensagres.xdocreport.core.io.XDocArchive preprocessedArchive)
    On before preprocessing.
    protected void
    onBeforeProcessTemplateEngine(fr.opensagres.xdocreport.template.IContext context, fr.opensagres.xdocreport.core.io.XDocArchive outputArchive)
    On before process template engine.
    void
    Force the preprocessing step.
    void
    process(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.
    void
    process(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.
    void
    process(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.
    void
    process(Map<String,Object> contextMap, String entryName, OutputStream out)
    Merge the docx, odt document with Java model from the context Map and register the entryName transformed to the output stream.
    protected abstract void
    Register preprocessors.
    void
    Clear processor.
    void
    Remove processor for the entry name.
    void
    save(ProcessState processState, OutputStream out)
    Save original|preprocessed XML document archive in the given output stream.
    void
    saveEntry(String entryName, ProcessState processState, OutputStream out)
    Save original|preprocessed entryName from XML document archive in the given output stream.
    void
    setCacheOriginalDocument(boolean cacheOriginalDocument)
    Set cache or not for original document archive.
    void
    setData(String key, Object value)
    Returns XML entries which define XML document to merge with Java model with template engine.
    void
    setDocumentArchive(fr.opensagres.xdocreport.core.io.XDocArchive documentArchive)
    Returns the zipped XML document (odt, docx...).
    void
    setFieldsMetadata(fr.opensagres.xdocreport.template.formatter.FieldsMetadata fieldsMetadata)
    Set fields metadata used to manage lazy loop for table row.
    void
    Set the id of the IXDocReport.
    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 by getXMLEntries().
    void
    setXMLEntries(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, wait

    Methods inherited from interface fr.opensagres.xdocreport.document.IXDocReport

    getKind, getMimeMapping
  • Constructor Details

    • AbstractXDocReport

      protected AbstractXDocReport()
  • Method Details

    • getId

      public String getId()
      Description copied from interface: IXDocReport
      Returns the id of the IXDocReport. This id is used to cache an instance of IXDocReport with and get instance from cache with
      Specified by:
      getId in interface IXDocReport
    • setId

      public void setId(String id)
      Description copied from interface: IXDocReport
      Set the id of the IXDocReport. This id is used to cache an instance of IXDocReport with and get instance from cache with
      Specified by:
      setId in interface IXDocReport
    • load

      public void load(InputStream sourceStream) throws IOException, fr.opensagres.xdocreport.core.XDocReportException
      Description copied from interface: IXDocReport
      Load XML document (odt, docx...) from input stream.
      Specified by:
      load in interface IXDocReport
      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 with IXDocPreprocessor cannot be done.
    • setDocumentArchive

      public void setDocumentArchive(fr.opensagres.xdocreport.core.io.XDocArchive documentArchive) throws IOException, fr.opensagres.xdocreport.core.XDocReportException
      Description copied from interface: IXDocReport
      Returns the zipped XML document (odt, docx...).
      Specified by:
      setDocumentArchive in interface IXDocReport
      Parameters:
      documentArchive - XDocArchive.
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException - when preprocessing with IXDocPreprocessor cannot be done.
      IOException
    • getOriginalDocumentArchive

      public fr.opensagres.xdocreport.core.io.XDocArchive getOriginalDocumentArchive()
      Description copied from interface: IXDocReport
      Returns the original zipped XML document (odt, docx...) and null if :
      Specified by:
      getOriginalDocumentArchive in interface IXDocReport
      Returns:
    • getPreprocessedDocumentArchive

      public fr.opensagres.xdocreport.core.io.XDocArchive getPreprocessedDocumentArchive()
      Description copied from interface: IXDocReport
      Returns the preprocessed zipped XML document (odt, docx...) and null if no load was done.
      Specified by:
      getPreprocessedDocumentArchive in interface IXDocReport
      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 by getXMLEntries().
      Specified by:
      getTemplateEngine in interface IXDocReport
      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 by getXMLEntries().
      Specified by:
      setTemplateEngine in interface IXDocReport
    • addPreprocessor

      public void addPreprocessor(String entryName, IXDocPreprocessor preprocessor)
      Register a processor for the entry name.
      Specified by:
      addPreprocessor in interface IXDocReport
      Parameters:
      entryName -
      preprocessor -
    • removePreprocessor

      public void removePreprocessor(String entryName)
      Remove processor for the entry name.
      Specified by:
      removePreprocessor in interface IXDocReport
      Parameters:
      entryName -
    • removeAllPreprocessors

      public void removeAllPreprocessors()
      Clear processor.
      Specified by:
      removeAllPreprocessors in interface IXDocReport
    • setFieldsMetadata

      public void setFieldsMetadata(fr.opensagres.xdocreport.template.formatter.FieldsMetadata fieldsMetadata)
      Set fields metadata used to manage lazy loop for table row.
      Specified by:
      setFieldsMetadata in interface IXDocReport
    • getFieldsMetadata

      public fr.opensagres.xdocreport.template.formatter.FieldsMetadata getFieldsMetadata()
      Returns fields metadata used to manage lazy loop for table row.
      Specified by:
      getFieldsMetadata in interface IXDocReport
      Returns:
    • createFieldsMetadata

      public fr.opensagres.xdocreport.template.formatter.FieldsMetadata createFieldsMetadata()
      Create fields metadata.
      Specified by:
      createFieldsMetadata in interface IXDocReport
      Returns:
    • preprocess

      public void preprocess() throws fr.opensagres.xdocreport.core.XDocReportException, IOException
      Description copied from interface: IXDocReport
      Force the preprocessing step.
      Specified by:
      preprocess in interface IXDocReport
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      IOException
    • onBeforePreprocessing

      protected void onBeforePreprocessing(Map<String,Object> sharedContext, fr.opensagres.xdocreport.core.io.XDocArchive preprocessedArchive) throws fr.opensagres.xdocreport.core.XDocReportException
      On 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.XDocReportException
      On after preprocessing.
      Parameters:
      sharedContext -
      preprocessedArchive -
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
    • getXMLEntries

      public String[] getXMLEntries()
      Returns XML entries which define XML document to merge with Java model with template engine.
      Returns:
    • setXMLEntries

      public void setXMLEntries(String[] xmlEntries)
      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.XDocReportException
      Create an empty context to register Java model.
      Specified by:
      createContext in interface IXDocReport
      Returns:
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
    • createContext

      public fr.opensagres.xdocreport.template.IContext createContext(Map<String,Object> contextMap) throws fr.opensagres.xdocreport.core.XDocReportException
      Description copied from interface: IXDocReport
      Create a new instance of IContext to put the Java model.
      Specified by:
      createContext in interface IXDocReport
      Returns:
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
    • process

      public void process(Map<String,Object> contextMap, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, IOException
      Description copied from interface: IXDocReport
      Merge the docx, odt document with Java model from the context Map and register the result to the output stream.
      Specified by:
      process in interface IXDocReport
      out - output stream where merge must be saved.
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      IOException
    • process

      public void process(Map<String,Object> contextMap, String entryName, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, IOException
      Description copied from interface: IXDocReport
      Merge the docx, odt document with Java model from the context Map and register the entryName transformed to the output stream.
      Specified by:
      process in interface IXDocReport
      entryName - entry name
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      IOException
    • process

      public void process(fr.opensagres.xdocreport.template.IContext context, OutputStream out) throws fr.opensagres.xdocreport.core.XDocReportException, IOException
      Description copied from interface: IXDocReport
      Merge the docx, odt document with Java model from the context and register the result to the output stream.
      Specified by:
      process in interface IXDocReport
      Parameters:
      context - of the Java model.
      out - output stream where merge must be saved.
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      IOException
    • 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:
      process in interface IXDocReport
      Parameters:
      context - of the Java model.
      entryName - entry name
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      IOException
    • 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: IXDocReport
      Save original|preprocessed XML document archive in the given output stream.
      Specified by:
      save in interface IXDocReport
      Throws:
      IOException
      fr.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: IXDocReport
      Save original|preprocessed entryName from XML document archive in the given output stream.
      Specified by:
      saveEntry in interface IXDocReport
      Throws:
      IOException
      fr.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: IXDocReport
      Extract declared fields which use syntax of the template egine of the report.
      Specified by:
      extractFields in interface IXDocReport
      Parameters:
      extractor - the fields extractor.
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      IOException
    • 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: IXDocReport
      Extract declared fields which use syntax of the given template egine of the report.
      Specified by:
      extractFields in interface IXDocReport
      Parameters:
      extractor - the fields extractor.
      templateEngine - the template engine.
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      IOException
    • getConverter

      public fr.opensagres.xdocreport.converter.IConverter getConverter(fr.opensagres.xdocreport.converter.Options options) throws fr.opensagres.xdocreport.converter.XDocConverterException
      Description copied from interface: IXDocReport
      Returns converter for the report and options.
      Specified by:
      getConverter in interface IXDocReport
      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, IOException
      Description copied from interface: IXDocReport
      Generate report and Convert it to another format (PDF, XHTML, etc).
      Specified by:
      convert in interface IXDocReport
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      fr.opensagres.xdocreport.converter.XDocConverterException
      IOException
    • 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: IXDocReport
      Generate report and Convert it to another format (PDF, XHTML, etc).
      Specified by:
      convert in interface IXDocReport
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
      fr.opensagres.xdocreport.converter.XDocConverterException
      IOException
    • 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

      protected abstract String[] getDefaultXMLEntries()
      Returns default entries which define XML document to merge with Java model with template engine for odt, docx...
      Returns:
    • setData

      public void setData(String key, Object value)
      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:
      setData in interface IXDocReport
    • getData

      public <T> T getData(String key)
      Description copied from interface: IXDocReport
      Returns custom data.
      Specified by:
      getData in interface IXDocReport
      Returns:
    • clearData

      public void clearData(String key)
      Description copied from interface: IXDocReport
      Clear data.
      Specified by:
      clearData in interface IXDocReport
    • setCacheOriginalDocument

      public void setCacheOriginalDocument(boolean cacheOriginalDocument)
      Description copied from interface: IXDocReport
      Set cache or not for original document archive.
      Specified by:
      setCacheOriginalDocument in interface IXDocReport
    • registerPreprocessors

      protected abstract void registerPreprocessors()
      Register preprocessors.
    • isPreprocessed

      public boolean isPreprocessed()
      Returns true if report was processed and false otherwise.
      Specified by:
      isPreprocessed in interface IXDocReport
      Returns:
    • getLastModified

      public long getLastModified()
      Returns the last modified time when the report is loaded.
      Specified by:
      getLastModified in interface IXDocReport
      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: IXDocReport
      Dump
      Specified by:
      dump in interface IXDocReport
      Throws:
      IOException
      fr.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: IXDocReport
      Dump
      Specified by:
      dump in interface IXDocReport
      Throws:
      IOException
      fr.opensagres.xdocreport.core.XDocReportException
    • getDumper

      public IDumper getDumper(DumperOptions options) throws fr.opensagres.xdocreport.core.XDocReportException
      Description copied from interface: IXDocReport
      Returns the dumper for the given options.
      Specified by:
      getDumper in interface IXDocReport
      Returns:
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException