fr.opensagres.xdocreport.core.io
Class XDocArchive

java.lang.Object
  extended by fr.opensagres.xdocreport.core.io.XDocArchive
All Implemented Interfaces:
IEntryInputStreamProvider, IEntryOutputStreamProvider, IEntryReaderProvider, IEntryWriterProvider

public class XDocArchive
extends Object
implements IEntryInputStreamProvider, IEntryReaderProvider, IEntryWriterProvider, IEntryOutputStreamProvider

XDocArchive is used to load zipped XML document archive (docx, odt...) XDocArchive cache each entry zip to transform content stream with IXDocPreprocessor and ITemplateEngine.


Constructor Summary
XDocArchive()
           
XDocArchive(boolean trackLastModified)
           
 
Method Summary
 XDocArchive createCopy()
          Create a copy of the XDocArchive.
 void dispose()
           
 IEntryInfo getEntryInfo(String entryName)
           
 InputStream getEntryInputStream(String entryName)
          Returns an InputStream from the cache entries of the given entry.
 Set<String> getEntryNames()
          Returns the entry names of the XML document archive by using cache entries.
 Set<String> getEntryNames(String wildcard)
           
 OutputStream getEntryOutputStream(String entryName)
          Returns an OutputStream from the cache entries for writing the content of the given entry.
 Reader getEntryReader(String entryName)
          Returns a Reader (UTF-8) from the cache entries of the given entry.
 Writer getEntryWriter(String entryName)
          Returns an Writer from the cache entries for writing the content of the given entry.
static InputStream getInputStream(XDocArchive archive)
          Returns the input stream of the given XDocArchive.
 long getLastModifiedEntry(String entryName)
           
 boolean hasEntry(String entryName)
          Returns true if XDocArchive contains an entry with the given name.
static XDocArchive readZip(InputStream sourceStream)
          Read zip from input stream and returns an instance of XDocArchive which cache each entry from the zip into a Map.
static void setEntry(XDocArchive archive, String entryName, InputStream input)
          Set the given input stream in the given entry of the document archive.
static void writeEntry(XDocArchive archive, String entryName, OutputStream outputStream)
          Write the given entry from the document archive in the given output stream.
static void writeZip(XDocArchive archive, OutputStream outputStream)
          Write XML document archive in the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XDocArchive

public XDocArchive()

XDocArchive

public XDocArchive(boolean trackLastModified)
Method Detail

getEntryNames

public Set<String> getEntryNames()
Returns the entry names of the XML document archive by using cache entries.

Returns:

getEntryNames

public Set<String> getEntryNames(String wildcard)

getEntryInputStream

public InputStream getEntryInputStream(String entryName)
Returns an InputStream from the cache entries of the given entry.

Specified by:
getEntryInputStream in interface IEntryInputStreamProvider
Parameters:
entryName -
Returns:

getEntryReader

public Reader getEntryReader(String entryName)
Returns a Reader (UTF-8) from the cache entries of the given entry.

Specified by:
getEntryReader in interface IEntryReaderProvider
Parameters:
entryName -
Returns:

getEntryOutputStream

public OutputStream getEntryOutputStream(String entryName)
Returns an OutputStream from the cache entries for writing the content of the given entry.

Specified by:
getEntryOutputStream in interface IEntryOutputStreamProvider
Parameters:
entryName -
Returns:
an OutputStream

getEntryWriter

public Writer getEntryWriter(String entryName)
Returns an Writer from the cache entries for writing the content of the given entry.

Specified by:
getEntryWriter in interface IEntryWriterProvider
Parameters:
entryName -
Returns:
a Writer

createCopy

public XDocArchive createCopy()
Create a copy of the XDocArchive.

Returns:

hasEntry

public boolean hasEntry(String entryName)
Returns true if XDocArchive contains an entry with the given name.

Parameters:
entryName -
Returns:

readZip

public static XDocArchive readZip(InputStream sourceStream)
                           throws IOException
Read zip from input stream and returns an instance of XDocArchive which cache each entry from the zip into a Map.

Parameters:
sourceStream - stream of odt, docx file.
Returns:
Throws:
IOException

setEntry

public static void setEntry(XDocArchive archive,
                            String entryName,
                            InputStream input)
                     throws IOException
Set the given input stream in the given entry of the document archive.

Parameters:
archive -
inputStream -
Throws:
IOException

writeEntry

public static void writeEntry(XDocArchive archive,
                              String entryName,
                              OutputStream outputStream)
                       throws IOException
Write the given entry from the document archive in the given output stream.

Parameters:
archive -
outputStream -
Throws:
IOException

writeZip

public static void writeZip(XDocArchive archive,
                            OutputStream outputStream)
                     throws IOException
Write XML document archive in the given output stream.

Parameters:
archive -
outputStream -
Throws:
IOException

getInputStream

public static InputStream getInputStream(XDocArchive archive)
                                  throws IOException
Returns the input stream of the given XDocArchive.

Parameters:
archive -
Returns:
the input stream of the given XDocArchive.
Throws:
IOException

getLastModifiedEntry

public long getLastModifiedEntry(String entryName)

getEntryInfo

public IEntryInfo getEntryInfo(String entryName)

dispose

public void dispose()


Copyright © 2013. All rights reserved.