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

    • isReplaceNullValues

      public boolean isReplaceNullValues()
    • getNullValuesDefault

      public String getNullValuesDefault()
    • nullReplacementValue

      public Optional<String> nullReplacementValue()
    • isFailOnUnresolvedExpression

      public boolean isFailOnUnresolvedExpression()
    • 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.
    • isReplaceUnresolvedExpressions

      public boolean isReplaceUnresolvedExpressions()
    • getUnresolvedExpressionsDefaultValue

      public String getUnresolvedExpressionsDefaultValue()
    • isLeaveEmptyOnExpressionError

      public boolean isLeaveEmptyOnExpressionError()
    • getLineBreakPlaceholder

      public String getLineBreakPlaceholder()
    • 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.
    • getExpressionFunctions

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

      public EvaluationContextConfigurer getEvaluationContextConfigurer()
    • 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.
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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.
    • addCommentProcessor

      public DocxStamperConfiguration addCommentProcessor(Class<?> interfaceClass, org.wickedsource.docxstamper.DocxStamperConfiguration.CommentProcessorFactory commentProcessorFactory)
      Registers the specified ICommentProcessor as an implementation of the specified interface.
      Parameters:
      interfaceClass - the Interface which is implemented by the commentProcessor.
      commentProcessorFactory - the commentProcessor factory generating the specified interface.
    • build

      @Deprecated(forRemoval=true, since="1.6.4") public <T> DocxStamper<T> build()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use new DocxStamper(DocxStamperConfiguration configuration) instead
      Creates a DocxStamper instance configured with this configuration.
    • getCommentProcessors

      public Map<Class<?>,org.wickedsource.docxstamper.DocxStamperConfiguration.CommentProcessorFactory> getCommentProcessors()
    • setDefaultTypeResolver

      public DocxStamperConfiguration setDefaultTypeResolver(ITypeResolver defaultTypeResolver)
    • getPreprocessors

      public List<PreProcessor> getPreprocessors()
    • addPreprocessor

      public void addPreprocessor(PreProcessor preprocessor)