fr.opensagres.xdocreport.document
Interface IXDocReport

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractXDocReport, DocxReport, ODPReport, ODSReport, ODTReport, PPTXReport

public interface IXDocReport
extends Serializable

XML Document reporting used to load XML document (odt, docx...) and generate reporting by merging it with Java data model by using a template engine ITemplateEngine.

To generate reporting, here steps to follow :

  1. Create an XML Document (docx with MS Word, odt with Open Office) by writing your fields with syntax wich depends on template engine :
  2. Create an instance of IXDocReport switch the type of the document:
  3. Initialize template engine by using setTemplateEngine(ITemplateEngine) to set the template engine (Velocity, Freemarker..) to use :
  4. Load XML Document (odt, docx) by using load(InputStream).
  5. Prepare your Java model by calling createContext() and put your Java model with IContext.put(String, Object). For instance :

    IContext context = report.createContext(); context.put("name", "word");

  6. Merge the docx, odt document with Java model by calling process(IContext, OutputStream). For instance :

    report.process(context, new FileOutputStream(new File("myfile.odt")));

    This method call will generate myfile.odt file wich will contains Hello word!


Method Summary
 void addPreprocessor(String entryName, IXDocPreprocessor preprocessor)
          Register a processor for the entry name.
 void clearData(String key)
          Clear data.
 void convert(IContext context, Options options, OutputStream out)
          Generate report and Convert it to another format (PDF, XHTML, etc).
 void convert(Map<String,Object> contextMap, Options options, OutputStream out)
          Generate report and Convert it to another format (PDF, XHTML, etc).
 IContext createContext()
          Create a new instance of IContext to put the Java model.
 IContext createContext(Map<String,Object> contextMap)
          Create a new instance of IContext to put the Java model.
 FieldsMetadata createFieldsMetadata()
          Create fields metadata.
 void dump(IContext context, DumperOptions options, OutputStream out)
          Dump
 void dump(IContext context, InputStream document, DumperOptions options, OutputStream out)
          Dump
 void extractFields(FieldsExtractor extractor)
          Extract declared fields which use syntax of the template egine of the report.
 void extractFields(FieldsExtractor extractor, ITemplateEngine templateEngine)
          Extract declared fields which use syntax of the given template egine of the report.
 IConverter getConverter(Options options)
          Returns converter for the report and options.
<T> T
getData(String key)
          Returns custom data.
 IDumper getDumper(DumperOptions options)
          Returns the dumper for the given options.
 FieldsMetadata getFieldsMetadata()
          Returns fields metadata used to manage lazy loop for table row.
 String getId()
          Returns the id of the IXDocReport.
 String getKind()
          Returns the kind of the report (ODT, docx...).
 long getLastModified()
          Returns the last modified time when the report is loaded.
 MimeMapping getMimeMapping()
          Returns mime mapping switch the kind of the report (odt, docx...).
 XDocArchive getOriginalDocumentArchive()
          Returns the original zipped XML document (odt, docx...) and null if : no load was done.
 XDocArchive getPreprocessedDocumentArchive()
          Returns the preprocessed zipped XML document (odt, docx...) and null if no load was done.
 ITemplateEngine getTemplateEngine()
          Returns the template engine (Velocity, Freemarker..) to use switch the syntax used in the XML document.
 boolean isPreprocessed()
          Returns true if report was processed and false otherwise.
 void load(InputStream sourceStream)
          Load XML document (odt, docx...) from input stream.
 void preprocess()
          Force the preprocessing step.
 void process(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(IContext context, String entryName, OutputStream outputStream)
          Merge the docx, odt document with Java model from the context and register the entryName transformed to the 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 outputStream)
          Merge the docx, odt document with Java model from the context Map and register the entryName transformed to the output stream.
 void removeAllPreprocessors()
          Clear processor.
 void removePreprocessor(String entryName)
          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)
          Store custom data.
 void setDocumentArchive(XDocArchive documentArchive)
          Returns the zipped XML document (odt, docx...).
 void setFieldsMetadata(FieldsMetadata metadata)
          Set fields metadat used to manage lazy loop in table row.
 void setId(String id)
          Set the id of the IXDocReport.
 void setTemplateEngine(ITemplateEngine templateEngine)
          Set the template engine (Velocity, Freemarker..) to use switch the syntax used in the XML document.
 

Method Detail

getKind

String getKind()
Returns the kind of the report (ODT, docx...).

Returns:

getId

String getId()
Returns the id of the IXDocReport. This id is used to cache an instance of IXDocReport with {@link XDocReportRegistry#loadReport(InputStream) and get instance from cache with

Returns:
the id of the IXDocReport

setId

void setId(String id)
Set the id of the IXDocReport. This id is used to cache an instance of IXDocReport with {@link XDocReportRegistry#loadReport(InputStream) and get instance from cache with

Parameters:
id - of the IXDocReport

load

void load(InputStream sourceStream)
          throws IOException,
                 XDocReportException
Load XML document (odt, docx...) from input stream.

Parameters:
sourceStream - stream of the XML Document zip (odt, docx...).
Throws:
IOException - when XML Document zip (odt, docx...) cannot be read.
XDocReportException - when preprocessing with IXDocPreprocessor cannot be done.

save

void save(ProcessState processState,
          OutputStream out)
          throws IOException,
                 XDocReportException
Save original|preprocessed XML document archive in the given output stream.

Parameters:
out -
Throws:
IOException
XDocReportException

saveEntry

void saveEntry(String entryName,
               ProcessState processState,
               OutputStream out)
               throws IOException,
                      XDocReportException
Save original|preprocessed entryName from XML document archive in the given output stream.

Parameters:
out -
Throws:
IOException
XDocReportException

setDocumentArchive

void setDocumentArchive(XDocArchive documentArchive)
                        throws IOException,
                               XDocReportException
Returns the zipped XML document (odt, docx...).

Parameters:
documentArchive - XDocArchive.
Throws:
XDocReportException - when preprocessing with IXDocPreprocessor cannot be done.
IOException

getOriginalDocumentArchive

XDocArchive getOriginalDocumentArchive()
Returns the original zipped XML document (odt, docx...) and null if :

Returns:

getPreprocessedDocumentArchive

XDocArchive getPreprocessedDocumentArchive()
Returns the preprocessed zipped XML document (odt, docx...) and null if no load was done.

Returns:

setTemplateEngine

void setTemplateEngine(ITemplateEngine templateEngine)
Set the template engine (Velocity, Freemarker..) to use switch the syntax used in the XML document.

Parameters:
templateEngine -

getTemplateEngine

ITemplateEngine getTemplateEngine()
Returns the template engine (Velocity, Freemarker..) to use switch the syntax used in the XML document.

Returns:

setFieldsMetadata

void setFieldsMetadata(FieldsMetadata metadata)
Set fields metadat used to manage lazy loop in table row.

Parameters:
metadata -

createContext

IContext createContext()
                       throws XDocReportException
Create a new instance of IContext to put the Java model.

Returns:
Throws:
XDocReportException

createContext

IContext createContext(Map<String,Object> contextMap)
                       throws XDocReportException
Create a new instance of IContext to put the Java model.

Returns:
Throws:
XDocReportException

process

void process(IContext context,
             OutputStream out)
             throws XDocReportException,
                    IOException
Merge the docx, odt document with Java model from the context and register the result to the output stream.

Parameters:
context - of the Java model.
out - output stream where merge must be saved.
Throws:
XDocReportException
IOException

process

void process(Map<String,Object> contextMap,
             OutputStream out)
             throws XDocReportException,
                    IOException
Merge the docx, odt document with Java model from the context Map and register the result to the output stream.

Parameters:
context - of the Java model.
out - output stream where merge must be saved.
Throws:
XDocReportException
IOException

process

void process(IContext context,
             String entryName,
             OutputStream outputStream)
             throws XDocReportException,
                    IOException
Merge the docx, odt document with Java model from the context and register the entryName transformed to the output stream.

Parameters:
context - of the Java model.
entryName - entry name
out - output stream where merge must be saved.
Throws:
XDocReportException
IOException

process

void process(Map<String,Object> contextMap,
             String entryName,
             OutputStream outputStream)
             throws XDocReportException,
                    IOException
Merge the docx, odt document with Java model from the context Map and register the entryName transformed to the output stream.

Parameters:
context - of the Java model.
entryName - entry name
out - output stream where merge must be saved.
Throws:
XDocReportException
IOException

getConverter

IConverter getConverter(Options options)
                        throws XDocConverterException
Returns converter for the report and options.

Parameters:
options -
Returns:
Throws:
XDocConverterException

convert

void convert(IContext context,
             Options options,
             OutputStream out)
             throws XDocReportException,
                    XDocConverterException,
                    IOException
Generate report and Convert it to another format (PDF, XHTML, etc).

Parameters:
context -
options -
out -
Throws:
XDocReportException
XDocConverterException
IOException

convert

void convert(Map<String,Object> contextMap,
             Options options,
             OutputStream out)
             throws XDocReportException,
                    XDocConverterException,
                    IOException
Generate report and Convert it to another format (PDF, XHTML, etc).

Parameters:
contextMap -
options -
out -
Throws:
XDocReportException
XDocConverterException
IOException

getMimeMapping

MimeMapping getMimeMapping()
Returns mime mapping switch the kind of the report (odt, docx...).

Returns:

setData

void setData(String key,
             Object value)
Store custom data.

Parameters:
key -
value -

clearData

void clearData(String key)
Clear data.

Parameters:
string -

getData

<T> T getData(String key)
Returns custom data.

Parameters:
key -
Returns:

extractFields

void extractFields(FieldsExtractor extractor,
                   ITemplateEngine templateEngine)
                   throws XDocReportException,
                          IOException
Extract declared fields which use syntax of the given template egine of the report.

Parameters:
extractor - the fields extractor.
templateEngine - the template engine.
Throws:
XDocReportException
IOException

extractFields

void extractFields(FieldsExtractor extractor)
                   throws XDocReportException,
                          IOException
Extract declared fields which use syntax of the template egine of the report.

Parameters:
extractor - the fields extractor.
Throws:
XDocReportException
IOException

setCacheOriginalDocument

void setCacheOriginalDocument(boolean cacheOriginalDocument)
Set cache or not for original document archive.

Parameters:
cache -

isPreprocessed

boolean isPreprocessed()
Returns true if report was processed and false otherwise.

Returns:

getLastModified

long getLastModified()
Returns the last modified time when the report is loaded.

Returns:

getFieldsMetadata

FieldsMetadata getFieldsMetadata()
Returns fields metadata used to manage lazy loop for table row.

Returns:

createFieldsMetadata

FieldsMetadata createFieldsMetadata()
Create fields metadata.

Returns:

addPreprocessor

void addPreprocessor(String entryName,
                     IXDocPreprocessor preprocessor)
Register a processor for the entry name.

Parameters:
entryName -
preprocessor -

removePreprocessor

void removePreprocessor(String entryName)
Remove processor for the entry name.

Parameters:
entryName -

removeAllPreprocessors

void removeAllPreprocessors()
Clear processor.


preprocess

void preprocess()
                throws XDocReportException,
                       IOException
Force the preprocessing step.

Throws:
XDocReportException
IOException

getDumper

IDumper getDumper(DumperOptions options)
                  throws XDocReportException
Returns the dumper for the given options.

Parameters:
options -
Returns:
Throws:
XDocReportException

dump

void dump(IContext context,
          InputStream document,
          DumperOptions options,
          OutputStream out)
          throws IOException,
                 XDocReportException
Dump

Parameters:
context -
kind -
options -
Throws:
IOException
XDocReportException

dump

void dump(IContext context,
          DumperOptions options,
          OutputStream out)
          throws IOException,
                 XDocReportException
Dump

Parameters:
context -
kind -
options -
Throws:
IOException
XDocReportException


Copyright © 2013. All rights reserved.