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.

public class StreamStamper<T extends org.docx4j.openpackaging.packages.OpcPackage> extends Object
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 Details

    • StreamStamper

      public StreamStamper(Function<InputStream,T> loader, OfficeStamper<T> stamper)
      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 stamp
      context - context to use for stamping
      outputStream - output stream to write the result to
      Throws:
      OfficeStamperException - if the stamping fails for any reason