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 extendOpcPackage.
This class implements the functionality of an
OfficeStamper meant for dealing with streams of data. It delegates
the execution 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
ConstructorsConstructorDescriptionStreamStamper(Function<InputStream, T> loader, OfficeStamper<T> stamper, BiConsumer<T, OutputStream> exporter) Constructs a newStreamStamperwith the provided loader, stamper and exporter. -
Method Summary
Modifier and TypeMethodDescriptionvoidstamp(InputStream inputStream, Object context, OutputStream outputStream) Stamps the template present in the given InputStream with the context given and writes the result to the providedOutputStream.
-
Constructor Details
-
StreamStamper
public StreamStamper(Function<InputStream, T> loader, OfficeStamper<T> stamper, BiConsumer<T, OutputStream> exporter) Constructs a newStreamStamperwith the provided loader, stamper and exporter.- Parameters:
loader- A Function that takes in anInputStreamand produces an instance of typeT.stamper- AnOfficeStamperused to execute the stamp operation.exporter- ABiConsumerthat exports the stamped document to anOutputStream.
-
-
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 providedOutputStream. This method first uses the loader to load the template from theInputStreaminto a typeTinstance, 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
-