Interface ITypeResolver<T>

Type Parameters:
T - the type of the object this type resolver is responsible for.

@Deprecated(since="1.6.7", forRemoval=true) public interface ITypeResolver<T>
Deprecated, for removal: This API element is subject to removal in a future version.
as of version 1.6.7, replaced by ObjectResolver. The new resolver is more versatile, requires less reflection mechanism, and simplifies the internal workings of the docx-stamper project.

A type resolver is responsible for mapping an object of a certain Java class to an object of the DOCX4J api that can be put into the .docx document. Type resolvers are used to replace expressions within the .docx template.

Example: if an expression returns a Date object as result, this date object is passed to a DateResolver which creates a org.docx4j.wml.R object (run of text) containing the properly formatted date string.

To use your own type resolver, implement this interface and register your implementation by calling DocxStamper.getTypeResolverRegistry().addTypeResolver().

Since:
1.0.0
Version:
${version}
Author:
Joseph Verron, Tom Hombergs
  • Method Summary

    Modifier and Type
    Method
    Description
    org.docx4j.wml.R
    resolve(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, T expressionResult)
    Deprecated, for removal: This API element is subject to removal in a future version.
    This method is called when an expression is found in the .docx template.
  • Method Details

    • resolve

      org.docx4j.wml.R resolve(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, T expressionResult)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method is called when an expression is found in the .docx template. It creates an object of the DOCX4J api in the place of the found expression.
      Parameters:
      document - the Word document that can be accessed via the DOCX4J api.
      expressionResult - the result of an expression. Only objects of classes this type resolver is registered for within the TypeResolverRegistry are passed into this method.
      Returns:
      an object of the DOCX4J api (usually of type R = "run of text") that will be put in the place of an expression found in the .docx document.