Class DocxStamper<T>

java.lang.Object
org.wickedsource.docxstamper.DocxStamper<T>
Type Parameters:
T - The type of the context that can be stamped
All Implemented Interfaces:
OfficeStamper<org.docx4j.openpackaging.packages.WordprocessingMLPackage>

@Deprecated(since="1.6.8", forRemoval=true) public class DocxStamper<T> extends Object implements OfficeStamper<org.docx4j.openpackaging.packages.WordprocessingMLPackage>
Deprecated, for removal: This API element is subject to removal in a future version.
since 1.6.8, This class has been deprecated in the effort of the library modularization, because it exposes too many implementation details to library users, and makes it hard to extend the library comfortably. It is recommended to use the OfficeStampers methods instead. This class will not be exported in the future releases of the module.
The DocxStamper class is an implementation of the OfficeStamper interface that is used to stamp DOCX templates with a context object and write the result to an output stream.
Since:
1.0.0
Version:
${version}
Author:
Tom Hombergs, Joseph Verron
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 1.6.4, use OfficeStampers.docxStamper() instead.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a new DocxStamper with the given configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    stamp(InputStream template, Object contextRoot, OutputStream out)
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    stamp(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, Object contextRoot, OutputStream out)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Stamps the template with the context and writes the result to the outputStream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DocxStamper

      @Deprecated(since="1.6.4", forRemoval=true) public DocxStamper()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1.6.4, use OfficeStampers.docxStamper() instead.
      Creates a new DocxStamper with the default configuration.
    • DocxStamper

      public DocxStamper(OfficeStamperConfiguration configuration)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new DocxStamper with the given configuration.
      Parameters:
      configuration - the configuration to use for this DocxStamper.
  • Method Details

    • stamp

      public void stamp(InputStream template, Object contextRoot, OutputStream out) throws DocxStamperException
      Deprecated, for removal: This API element is subject to removal in a future version.

      Reads in a .docx template and "stamps" it into the given OutputStream, using the specified context object to fill out any expressions it finds.

      In the .docx template you have the following options to influence the "stamping" process:

      • Use expressions like ${name} or ${person.isOlderThan(18)} in the template's text. These expressions are resolved against the contextRoot object you pass into this method and are replaced by the results.
      • Use comments within the .docx template to mark certain paragraphs to be manipulated.

      Within comments, you can put expressions in which you can use the following methods by default:

      • displayParagraphIf(boolean) to conditionally display paragraphs or not
      • displayTableRowIf(boolean) to conditionally display table rows or not
      • displayTableIf(boolean) to conditionally display whole tables or not
      • repeatTableRow(List<Object>) to create a new table row for each object in the list and resolve expressions within the table cells against one of the objects within the list.

      If you need a wider vocabulary of methods available in the comments, you can create your own ICommentProcessor and register it via OfficeStamperConfiguration.addCommentProcessor(Class, Function).

      Throws:
      DocxStamperException
    • stamp

      public void stamp(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, Object contextRoot, OutputStream out) throws DocxStamperException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Stamps the template with the context and writes the result to the outputStream.

      Same as stamp(InputStream, Object, OutputStream) except that you may pass in a DOCX4J document as a template instead of an InputStream.

      Specified by:
      stamp in interface OfficeStamper<T>
      Parameters:
      document - template to stamp
      contextRoot - context to use for stamping
      out - output stream to write the result to
      Throws:
      DocxStamperException