be.re.repo.mod
Class ZippedDocumentExchanger

java.lang.Object
  extended by be.re.repo.mod.ZippedDocumentExchanger

public class ZippedDocumentExchanger
extends Object

Implements a mechanism to exchange properties with zipped documents in formats such as ODF, ePub, Office Open XML, etc. The documents are processed in a streaming-oriented fashion.

Author:
Werner Donné

Nested Class Summary
static interface ZippedDocumentExchanger.Get
           
static interface ZippedDocumentExchanger.Set
           
 
Constructor Summary
ZippedDocumentExchanger()
           
 
Method Summary
static InputStream get(InputStream in, Set<Property> properties, ZippedDocumentExchanger.Get get, String[] entryPatterns)
          Retrieves properties from the document.
static InputStream set(InputStream in, Set<Property> newProperties, Set<Property> oldProperties, ZippedDocumentExchanger.Set set, String[] entryPatterns)
          Updates properties in the document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZippedDocumentExchanger

public ZippedDocumentExchanger()
Method Detail

get

public static InputStream get(InputStream in,
                              Set<Property> properties,
                              ZippedDocumentExchanger.Get get,
                              String[] entryPatterns)
                       throws IOException
Retrieves properties from the document.

Parameters:
in - the original document stream.
properties - the set into which the extracted properties should be placed.
get - the object that is called for each selected ZIP-entry,
entryPatterns - the regular expressions that select the ZIP-entries based on their name. If the array is empty no entries will be selected at all.
Returns:
The transformed document stream. In this case the document won't have changed, because only properties are extracted.
Throws:
IOException

set

public static InputStream set(InputStream in,
                              Set<Property> newProperties,
                              Set<Property> oldProperties,
                              ZippedDocumentExchanger.Set set,
                              String[] entryPatterns)
                       throws IOException
Updates properties in the document.

Parameters:
in - the original document stream.
newProperties - the complete set of properties that is to be updated in the document. A module is allowed to modify this set according to its validation rules. The repository will then use the modified set.
oldProperties - the properties the document currently has. This may be usefull for the validation of newProperties.
set - the object that is called for each selected ZIP-entry,
entryPatterns - the regular expressions that select the ZIP-entries based on their name. If the array is empty no entries will be selected at all.
Returns:
the transformed document stream.
Throws:
IOException