Class DocxStamperConfiguration

java.lang.Object
org.wickedsource.docxstamper.DocxStamperConfiguration
All Implemented Interfaces:
OfficeStamperConfiguration

@Deprecated(since="1.6.8", forRemoval=true) public class DocxStamperConfiguration extends Object implements OfficeStamperConfiguration
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 OfficeStamperConfigurations.standard() method and OfficeStamperConfiguration interface instead. This class will not be exported in the future releases of the module.
The DocxStamperConfiguration class represents the configuration for the DocxStamper class. It provides methods to customize the behavior of the stamper.
Since:
1.0.3
Version:
${version}
Author:
Joseph Verron, Tom Hombergs
  • Constructor Details

    • DocxStamperConfiguration

      public DocxStamperConfiguration()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new configuration with default values.
  • Method Details

    • nullReplacementValue

      @Deprecated(since="1.6.7") public Optional<String> nullReplacementValue()
      Deprecated.
      This method's been deprecated since version 1.6.7. You shouldn't have to use it, it was a crutch use for inner working of docx-stamper
      Retrieves the default replacement value for null values.
      Specified by:
      nullReplacementValue in interface OfficeStamperConfiguration
      Returns:
      the Optional containing the default replacement value, or an empty Optional if no default replacement value is found
    • isFailOnUnresolvedExpression

      public boolean isFailOnUnresolvedExpression()
      Deprecated, for removal: This API element is subject to removal in a future version.

      isFailOnUnresolvedExpression.

      Specified by:
      isFailOnUnresolvedExpression in interface OfficeStamperConfiguration
      Returns:
      a boolean
    • setFailOnUnresolvedExpression

      public DocxStamperConfiguration setFailOnUnresolvedExpression(boolean failOnUnresolvedExpression)
      Deprecated, for removal: This API element is subject to removal in a future version.
      If set to true, stamper will throw an DocxStamperException 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.
      Specified by:
      setFailOnUnresolvedExpression in interface OfficeStamperConfiguration
      Parameters:
      failOnUnresolvedExpression - a boolean
      Returns:
      a DocxStamperConfiguration object
    • nullValuesDefault

      @Deprecated(since="1.6.7", forRemoval=true) public DocxStamperConfiguration nullValuesDefault(String nullValuesDefault)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method has been deprecated since version 1.6.7. It is recommended to use addResolver(ObjectResolver) and Resolvers.nullToDefault(String) instead.
      Sets the default value for null values in the document.
      Specified by:
      nullValuesDefault in interface OfficeStamperConfiguration
      Parameters:
      nullValuesDefault - The default value for null values.
      Returns:
      The updated DocxStamperConfiguration object.
    • replaceNullValues

      @Deprecated(since="1.6.7", forRemoval=true) public DocxStamperConfiguration replaceNullValues(boolean replaceNullValues)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method has been deprecated since version 1.6.7. It is recommended to use addResolver(ObjectResolver) and Resolvers.nullToDefault(String) instead.
      Replaces null values with either empty string or a placeholder value, based on the given flag.
      Specified by:
      replaceNullValues in interface OfficeStamperConfiguration
      Parameters:
      replaceNullValues - Flag indicating whether to replace null values or not.
      Returns:
      The updated DocxStamperConfiguration object.
    • unresolvedExpressionsDefaultValue

      public DocxStamperConfiguration unresolvedExpressionsDefaultValue(String unresolvedExpressionsDefaultValue)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Indicates the default value to use for expressions that doesn't resolve.
      Specified by:
      unresolvedExpressionsDefaultValue in interface OfficeStamperConfiguration
      Parameters:
      unresolvedExpressionsDefaultValue - value to use instead for expression that doesn't resolve
      Returns:
      a DocxStamperConfiguration object
      See Also:
      • replaceUnresolvedExpressions
    • replaceUnresolvedExpressions

      public DocxStamperConfiguration replaceUnresolvedExpressions(boolean replaceUnresolvedExpressions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Indicates if a default value should replace expressions that don't resolve.
      Specified by:
      replaceUnresolvedExpressions in interface OfficeStamperConfiguration
      Parameters:
      replaceUnresolvedExpressions - true to replace null value expression with resolved value (which is null), false to leave the expression as is
      Returns:
      a DocxStamperConfiguration object
    • leaveEmptyOnExpressionError

      public DocxStamperConfiguration leaveEmptyOnExpressionError(boolean leaveEmpty)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
      Specified by:
      leaveEmptyOnExpressionError in interface OfficeStamperConfiguration
      Parameters:
      leaveEmpty - true to replace expressions with empty string when an error is caught while evaluating
      Returns:
      a DocxStamperConfiguration object
    • addTypeResolver

      @Deprecated(since="1.6.7", forRemoval=true) public <T> DocxStamperConfiguration addTypeResolver(Class<T> resolvedType, ITypeResolver<T> resolver)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method has been deprecated since version 1.6.7, and it is scheduled for removal. It's recommended to use the addResolver(ObjectResolver) method for adding resolvers.

      Registers the given ITypeResolver for the given class. The registered ITypeResolver.resolve(WordprocessingMLPackage, Object) 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.

      Specified by:
      addTypeResolver in interface OfficeStamperConfiguration
      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.
      Returns:
      a DocxStamperConfiguration object
    • exposeInterfaceToExpressionLanguage

      public DocxStamperConfiguration exposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Exposes all methods of a given interface to the expression language.
      Specified by:
      exposeInterfaceToExpressionLanguage in interface OfficeStamperConfiguration
      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.
      Returns:
      a DocxStamperConfiguration object
    • addCommentProcessor

      public DocxStamperConfiguration addCommentProcessor(Class<?> interfaceClass, Function<ParagraphPlaceholderReplacer,CommentProcessor> commentProcessorFactory)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Registers the specified ICommentProcessor as an implementation of the specified interface.
      Specified by:
      addCommentProcessor in interface OfficeStamperConfiguration
      Parameters:
      interfaceClass - the Interface which is implemented by the commentProcessor.
      commentProcessorFactory - the commentProcessor factory generating the specified interface.
      Returns:
      a DocxStamperConfiguration object
    • build

      @Deprecated(forRemoval=true, since="1.6.4") public OfficeStamper<org.docx4j.openpackaging.packages.WordprocessingMLPackage> build()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a DocxStamper instance configured with this configuration.
      Specified by:
      build in interface OfficeStamperConfiguration
      Returns:
      a DocxStamper object
    • addPreprocessor

      public void addPreprocessor(PreProcessor preprocessor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds a preprocessor to the configuration.
      Specified by:
      addPreprocessor in interface OfficeStamperConfiguration
      Parameters:
      preprocessor - the preprocessor to add.
    • isReplaceUnresolvedExpressions

      public boolean isReplaceUnresolvedExpressions()
      Deprecated, for removal: This API element is subject to removal in a future version.

      isReplaceUnresolvedExpressions.

      Specified by:
      isReplaceUnresolvedExpressions in interface OfficeStamperConfiguration
      Returns:
      a boolean
    • isLeaveEmptyOnExpressionError

      public boolean isLeaveEmptyOnExpressionError()
      Deprecated, for removal: This API element is subject to removal in a future version.

      isLeaveEmptyOnExpressionError.

      Specified by:
      isLeaveEmptyOnExpressionError in interface OfficeStamperConfiguration
      Returns:
      a boolean
    • getUnresolvedExpressionsDefaultValue

      public String getUnresolvedExpressionsDefaultValue()
      Deprecated, for removal: This API element is subject to removal in a future version.

      Getter for the field unresolvedExpressionsDefaultValue.

      Specified by:
      getUnresolvedExpressionsDefaultValue in interface OfficeStamperConfiguration
      Returns:
      a String object
    • getLineBreakPlaceholder

      public String getLineBreakPlaceholder()
      Deprecated, for removal: This API element is subject to removal in a future version.

      Getter for the field lineBreakPlaceholder.

      Specified by:
      getLineBreakPlaceholder in interface OfficeStamperConfiguration
      Returns:
      a String object
    • setLineBreakPlaceholder

      public DocxStamperConfiguration setLineBreakPlaceholder(@NonNull String lineBreakPlaceholder)
      Deprecated, for removal: This API element is subject to removal in a future version.
      The String provided as lineBreakPlaceholder will be replaced with a line break when stamping a document. If no lineBreakPlaceholder is provided, no replacement will take place.
      Specified by:
      setLineBreakPlaceholder in interface OfficeStamperConfiguration
      Parameters:
      lineBreakPlaceholder - the String that should be replaced with line breaks during stamping.
      Returns:
      the configuration object for chaining.
    • getEvaluationContextConfigurer

      public EvaluationContextConfigurer getEvaluationContextConfigurer()
      Deprecated, for removal: This API element is subject to removal in a future version.

      Getter for the field evaluationContextConfigurer.

      Specified by:
      getEvaluationContextConfigurer in interface OfficeStamperConfiguration
      Returns:
      a EvaluationContextConfigurer object
    • setEvaluationContextConfigurer

      public DocxStamperConfiguration setEvaluationContextConfigurer(EvaluationContextConfigurer evaluationContextConfigurer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Provides an EvaluationContextConfigurer which may change the configuration of a Spring EvaluationContext which is used for evaluating expressions in comments and text.
      Specified by:
      setEvaluationContextConfigurer in interface OfficeStamperConfiguration
      Parameters:
      evaluationContextConfigurer - the configurer to use.
      Returns:
      a DocxStamperConfiguration object
    • getSpelParserConfiguration

      public org.springframework.expression.spel.SpelParserConfiguration getSpelParserConfiguration()
      Deprecated, for removal: This API element is subject to removal in a future version.

      Getter for the field spelParserConfiguration.

      Specified by:
      getSpelParserConfiguration in interface OfficeStamperConfiguration
      Returns:
      a SpelParserConfiguration object
    • setSpelParserConfiguration

      public DocxStamperConfiguration setSpelParserConfiguration(org.springframework.expression.spel.SpelParserConfiguration spelParserConfiguration)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the SpelParserConfiguration to use for expression parsing.

      Note that this configuration will be used for all expressions in the document, including expressions in comments!

      Specified by:
      setSpelParserConfiguration in interface OfficeStamperConfiguration
      Parameters:
      spelParserConfiguration - the configuration to use.
      Returns:
      a DocxStamperConfiguration object
    • getExpressionFunctions

      public Map<Class<?>,Object> getExpressionFunctions()
      Deprecated, for removal: This API element is subject to removal in a future version.

      Getter for the field expressionFunctions.

      Specified by:
      getExpressionFunctions in interface OfficeStamperConfiguration
      Returns:
      a Map object
    • getTypeResolvers

      @Deprecated(since="1.6.7", forRemoval=true) public Map<Class<?>,ITypeResolver<?>> getTypeResolvers()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method's been deprecated since version 1.6.7
      Retrieves the map of type resolvers.
      Specified by:
      getTypeResolvers in interface OfficeStamperConfiguration
      Returns:
      the map of type resolvers
    • getDefaultTypeResolver

      @Deprecated(since="1.6.7", forRemoval=true) public ITypeResolver<Object> getDefaultTypeResolver()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method's been deprecated since version 1.6.7 and is scheduled for removal. You should not have to use it, it was a clutch for previous version of docx-stamper.
      Returns the default type resolver.

      This method returns the default type resolver from a list of resolvers. It filters the resolvers to only include instances of ITypeResolver, and returns the first one found. If no type resolver is found, null is returned.

      Specified by:
      getDefaultTypeResolver in interface OfficeStamperConfiguration
      Returns:
      the default type resolver, or null if not found
    • setDefaultTypeResolver

      @Deprecated(since="1.6.7", forRemoval=true) public DocxStamperConfiguration setDefaultTypeResolver(ITypeResolver<? super Object> defaultResolver)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method is deprecated and scheduled for removal in version 1.6.7. Please set your "default" resolver through addResolver(ObjectResolver) by putting your default first in the list, or by using setResolvers(List)} and putting your fallback resolvers in the last place.
      Sets the default type resolver for the DocxStamperConfiguration.
      Specified by:
      setDefaultTypeResolver in interface OfficeStamperConfiguration
      Parameters:
      defaultResolver - The default type resolver to set.
      Returns:
      The updated DocxStamperConfiguration instance.
    • getCommentProcessors

      public Map<Class<?>,Function<ParagraphPlaceholderReplacer,CommentProcessor>> getCommentProcessors()
      Deprecated, for removal: This API element is subject to removal in a future version.

      Getter for the field commentProcessors.

      Specified by:
      getCommentProcessors in interface OfficeStamperConfiguration
      Returns:
      a Map object
    • isReplaceNullValues

      @Deprecated(since="1.6.7", forRemoval=true) public boolean isReplaceNullValues()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method's been deprecated since version 1.6.7 and will be removed in a future release. You shouldn't have to use it, it was a clutch for docx-stamper workings.
      Gets the flag indicating whether null values should be replaced.
      Specified by:
      isReplaceNullValues in interface OfficeStamperConfiguration
      Returns:
      true if null values should be replaced, false otherwise.
    • getNullValuesDefault

      @Deprecated(since="1.6.7", forRemoval=true) public String getNullValuesDefault()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method has been deprecated since version 1.6.7 and is scheduled for removal. You shouldn't have to use it, it was a clutch for docx-stamper workings.
      Retrieves the default value used for representing null values.
      Specified by:
      getNullValuesDefault in interface OfficeStamperConfiguration
      Returns:
      the default value for null values
    • getPreprocessors

      public List<PreProcessor> getPreprocessors()
      Deprecated, for removal: This API element is subject to removal in a future version.

      Getter for the field preprocessors.

      Specified by:
      getPreprocessors in interface OfficeStamperConfiguration
      Returns:
      a List object
    • getResolvers

      public List<ObjectResolver> getResolvers()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Retrieves the list of resolvers.
      Specified by:
      getResolvers in interface OfficeStamperConfiguration
      Returns:
      The list of object resolvers.
    • setResolvers

      public DocxStamperConfiguration setResolvers(List<ObjectResolver> resolvers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the resolvers for resolving objects in the DocxStamperConfiguration.

      This method is the evolution of the method addTypeResolver, and the order in which the resolvers are ordered is determinant - the first resolvers in the list will be tried first. If a fallback resolver is desired, it should be placed last in the list.

      Specified by:
      setResolvers in interface OfficeStamperConfiguration
      Parameters:
      resolvers - The list of ObjectResolvers to be set.
      Returns:
      The updated DocxStamperConfiguration instance.
    • addResolver

      public DocxStamperConfiguration addResolver(ObjectResolver resolver)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds a resolver to the list of resolvers in the `DocxStamperConfiguration` object. Resolvers are used to resolve objects during the stamping process.
      Specified by:
      addResolver in interface OfficeStamperConfiguration
      Parameters:
      resolver - The resolver to be added. This resolver should implement the `ObjectResolver` interface.
      Returns:
      The modified `DocxStamperConfiguration` object, with the resolver added to the beginning of the resolver list.