Module pro.verron.officestamper
Package pro.verron.officestamper.api
Class StreamStamper<T extends org.docx4j.openpackaging.packages.OpcPackage>
java.lang.Object
pro.verron.officestamper.api.StreamStamper<T>
- Type Parameters:
T
- The type of the template that can be stamped. This type must extend OpcPackage.
This class implements the functionality of an OfficeStamper meant for dealing with streams of data. It delegates the executing
of the stamp operation to an OfficeStamper instance while providing the necessary mechanisms to work with streams.
- Since:
- 1.6.4
- Version:
- ${version}
- Author:
- Joseph Verron
-
Constructor Summary
ConstructorDescriptionStreamStamper
(Function<InputStream, T> loader, OfficeStamper<T> stamper) Constructs a new StreamStamper with the provided loader and stamper. -
Method Summary
Modifier and TypeMethodDescriptionvoid
stamp
(InputStream inputStream, Object context, OutputStream outputStream) Stamps the template present in the given InputStream with the context given and writes the result to the provided OutputStream.
-
Constructor Details
-
StreamStamper
Constructs a new StreamStamper with the provided loader and stamper.- Parameters:
loader
- A Function that takes in an InputStream and produces an instance of type T.stamper
- An OfficeStamper used to execute the stamp operation.
-
-
Method Details
-
stamp
public void stamp(InputStream inputStream, Object context, OutputStream outputStream) throws OfficeStamperException Stamps the template present in the given InputStream with the context given and writes the result to the provided OutputStream. This method first uses the loader to load the template from the InputStream into a type T instance, then uses the stamper to perform the stamp operation using the template and context, writing the result out to the OutputStream.- Parameters:
inputStream
- template to stampcontext
- context to use for stampingoutputStream
- output stream to write the result to- Throws:
OfficeStamperException
- if the stamping fails for any reason
-