Class DocxStamperConfiguration

java.lang.Object
org.wickedsource.docxstamper.DocxStamperConfiguration

public class DocxStamperConfiguration extends Object
Provides configuration parameters for DocxStamper.
  • Constructor Details

    • DocxStamperConfiguration

      public DocxStamperConfiguration()
  • Method Details

    • setLineBreakPlaceholder

      public DocxStamperConfiguration setLineBreakPlaceholder(String lineBreakPlaceholder)
      The String provided as lineBreakPlaceholder will be replaces with a line break when stamping a document. If no lineBreakPlaceholder is provided, no replacement will take place.
      Parameters:
      lineBreakPlaceholder - the String that should be replaced with line breaks during stamping.
      Returns:
      the configuration object for chaining.
    • setEvaluationContextConfigurer

      public DocxStamperConfiguration setEvaluationContextConfigurer(EvaluationContextConfigurer evaluationContextConfigurer)
      Provides an EvaluationContextConfigurer which may change the configuration of a Spring EvaluationContext which is used for evaluating expressions in comments and text.
      Parameters:
      evaluationContextConfigurer - the configurer to use.
    • setFailOnUnresolvedExpression

      public DocxStamperConfiguration setFailOnUnresolvedExpression(boolean failOnUnresolvedExpression)
      If set to true, stamper will throw an UnresolvedExpressionException if a variable expression or processor expression within the document or within the comments is encountered that cannot be resolved. Is set to true by default.
    • addCommentProcessor

      public DocxStamperConfiguration addCommentProcessor(Class<?> interfaceClass, ICommentProcessor commentProcessor)
      Registers the specified ICommentProcessor as an implementation of the specified interface.
      Parameters:
      interfaceClass - the Interface which is implemented by the commentProcessor.
      commentProcessor - the commentProcessor implementing the specified interface.
    • addTypeResolver

      public <T> DocxStamperConfiguration addTypeResolver(Class<T> resolvedType, ITypeResolver resolver)

      Registers the given ITypeResolver for the given class. The registered ITypeResolver's resolve() method will only be called with objects of the specified class.

      Note that each type can only be resolved by ONE ITypeResolver implementation. Multiple calls to addTypeResolver() with the same resolvedType parameter will override earlier calls.

      Type Parameters:
      T - the type resolved by the ITypeResolver.
      Parameters:
      resolvedType - the class whose objects are to be passed to the given ITypeResolver.
      resolver - the resolver to resolve objects of the given type.
    • exposeInterfaceToExpressionLanguage

      public DocxStamperConfiguration exposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation)
      Exposes all methods of a given interface to the expression language.
      Parameters:
      interfaceClass - the interface whose methods should be exposed in the expression language.
      implementation - the implementation that should be called to evaluate invocations of the interface methods within the expression language. Must implement the interface above.
    • leaveEmptyOnExpressionError

      public DocxStamperConfiguration leaveEmptyOnExpressionError(boolean leaveEmpty)
      If an error is caught while evaluating an expression the expression will be replaced with an empty string instead of leaving the original expression in the document.
      Parameters:
      leaveEmpty - true to replace expressions with empty string when an error is caught while evaluating
    • replaceNullValues

      public DocxStamperConfiguration replaceNullValues(boolean replaceNullValues)
      Indicates if expressions that resolve to null should be processed.
      Parameters:
      replaceNullValues - true to replace null value expression with resolved value (which is null), false to leave the expression as is
    • nullValuesDefault

      public DocxStamperConfiguration nullValuesDefault(String nullValuesDefault)
      Indicates if expressions that resolve to null should be replaced by a global default value.
      Parameters:
      nullValuesDefault - value to use instead for expression resolving to null
      See Also:
      • replaceNullValues
    • replaceUnresolvedExpressions

      public DocxStamperConfiguration replaceUnresolvedExpressions(boolean replaceUnresolvedExpressions)
      Indicates if expressions that doesn't resolve should be replaced by a default value.
      Parameters:
      replaceUnresolvedExpressions - true to replace null value expression with resolved value (which is null), false to leave the expression as is
    • unresolvedExpressionsDefaultValue

      public DocxStamperConfiguration unresolvedExpressionsDefaultValue(String unresolvedExpressionsDefaultValue)
      Indicates the default value to use for expressions that doesn't resolve.
      Parameters:
      unresolvedExpressionsDefaultValue - value to use instead for expression that doesn't resolve
      See Also:
      • replaceUnresolvedExpressions
    • build

      public DocxStamper build()
      Creates a DocxStamper instance configured with this configuration.
    • setDefaultTypeResolver

      public DocxStamperConfiguration setDefaultTypeResolver(ITypeResolver defaultTypeResolver)
    • isLeaveEmptyOnExpressionError

      public boolean isLeaveEmptyOnExpressionError()
    • isReplaceNullValues

      public boolean isReplaceNullValues()
    • getNullValuesDefault

      public String getNullValuesDefault()
    • isReplaceUnresolvedExpressions

      public boolean isReplaceUnresolvedExpressions()
    • getUnresolvedExpressionsDefaultValue

      public String getUnresolvedExpressionsDefaultValue()
    • getExpressionFunctions

      public Map<Class<?>,Object> getExpressionFunctions()