- All Implemented Interfaces:
OfficeStamperConfiguration
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 Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Creates a new configuration with default values. -
Method Summary
Modifier and TypeMethodDescriptionaddCommentProcessor(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.voidaddPreprocessor(PreProcessor preprocessor) Deprecated, for removal: This API element is subject to removal in a future version.Adds a preprocessor to the configuration.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.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.OfficeStamper<org.docx4j.openpackaging.packages.WordprocessingMLPackage> build()Deprecated, for removal: This API element is subject to removal in a future version.use newDocxStamper(OfficeStamperConfiguration)} insteadexposeInterfaceToExpressionLanguage(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.Deprecated, for removal: This API element is subject to removal in a future version.Getter for the fieldcommentProcessors.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.Deprecated, for removal: This API element is subject to removal in a future version.Getter for the fieldevaluationContextConfigurer.Deprecated, for removal: This API element is subject to removal in a future version.Getter for the fieldexpressionFunctions.Deprecated, for removal: This API element is subject to removal in a future version.Getter for the fieldlineBreakPlaceholder.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.Deprecated, for removal: This API element is subject to removal in a future version.Getter for the fieldpreprocessors.Deprecated, for removal: This API element is subject to removal in a future version.Retrieves the list of resolvers.org.springframework.expression.spel.SpelParserConfigurationDeprecated, for removal: This API element is subject to removal in a future version.Getter for the fieldspelParserConfiguration.Map<Class<?>, ITypeResolver<?>> Deprecated, for removal: This API element is subject to removal in a future version.This method's been deprecated since version 1.6.7Deprecated, for removal: This API element is subject to removal in a future version.Getter for the fieldunresolvedExpressionsDefaultValue.booleanDeprecated, for removal: This API element is subject to removal in a future version.isFailOnUnresolvedExpression.booleanDeprecated, for removal: This API element is subject to removal in a future version.isLeaveEmptyOnExpressionError.booleanDeprecated, 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.booleanDeprecated, for removal: This API element is subject to removal in a future version.isReplaceUnresolvedExpressions.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.Deprecated.This method's been deprecated since version 1.6.7.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.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.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.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.setEvaluationContextConfigurer(EvaluationContextConfigurer evaluationContextConfigurer) Deprecated, for removal: This API element is subject to removal in a future version.Provides anEvaluationContextConfigurerwhich may change the configuration of a SpringEvaluationContextwhich is used for evaluating expressions in comments and text.setFailOnUnresolvedExpression(boolean failOnUnresolvedExpression) Deprecated, for removal: This API element is subject to removal in a future version.If set to true, stamper will throw anDocxStamperExceptionif a variable expression or processor expression within the document or within the comments is encountered that cannot be resolved.setLineBreakPlaceholder(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.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.setSpelParserConfiguration(org.springframework.expression.spel.SpelParserConfiguration spelParserConfiguration) Deprecated, for removal: This API element is subject to removal in a future version.Sets theSpelParserConfigurationto use for expression parsing.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.
-
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.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-stamperRetrieves the default replacement value for null values.- Specified by:
nullReplacementValuein interfaceOfficeStamperConfiguration- Returns:
- the
Optionalcontaining the default replacement value, or an emptyOptionalif 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:
isFailOnUnresolvedExpressionin interfaceOfficeStamperConfiguration- Returns:
- a boolean
-
setFailOnUnresolvedExpression
Deprecated, for removal: This API element is subject to removal in a future version.If set to true, stamper will throw anDocxStamperExceptionif 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:
setFailOnUnresolvedExpressionin interfaceOfficeStamperConfiguration- Parameters:
failOnUnresolvedExpression- a boolean- Returns:
- a
DocxStamperConfigurationobject
-
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 useaddResolver(ObjectResolver)andResolvers.nullToDefault(String)instead.Sets the default value for null values in the document.- Specified by:
nullValuesDefaultin interfaceOfficeStamperConfiguration- 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 useaddResolver(ObjectResolver)andResolvers.nullToDefault(String)instead.Replaces null values with either empty string or a placeholder value, based on the given flag.- Specified by:
replaceNullValuesin interfaceOfficeStamperConfiguration- 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:
unresolvedExpressionsDefaultValuein interfaceOfficeStamperConfiguration- Parameters:
unresolvedExpressionsDefaultValue- value to use instead for expression that doesn't resolve- Returns:
- a
DocxStamperConfigurationobject - See Also:
-
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:
replaceUnresolvedExpressionsin interfaceOfficeStamperConfiguration- Parameters:
replaceUnresolvedExpressions- true to replace null value expression with resolved value (which is null), false to leave the expression as is- Returns:
- a
DocxStamperConfigurationobject
-
leaveEmptyOnExpressionError
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:
leaveEmptyOnExpressionErrorin interfaceOfficeStamperConfiguration- Parameters:
leaveEmpty- true to replace expressions with empty string when an error is caught while evaluating- Returns:
- a
DocxStamperConfigurationobject
-
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 theaddResolver(ObjectResolver)method for adding resolvers.Registers the given
ITypeResolverfor the given class. The registeredITypeResolver.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:
addTypeResolverin interfaceOfficeStamperConfiguration- 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
DocxStamperConfigurationobject
-
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:
exposeInterfaceToExpressionLanguagein interfaceOfficeStamperConfiguration- 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
DocxStamperConfigurationobject
-
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:
addCommentProcessorin interfaceOfficeStamperConfiguration- Parameters:
interfaceClass- the Interface which is implemented by the commentProcessor.commentProcessorFactory- the commentProcessor factory generating the specified interface.- Returns:
- a
DocxStamperConfigurationobject
-
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.use newDocxStamper(OfficeStamperConfiguration)} insteadCreates aDocxStamperinstance configured with this configuration.- Specified by:
buildin interfaceOfficeStamperConfiguration- Returns:
- a
DocxStamperobject
-
addPreprocessor
Deprecated, for removal: This API element is subject to removal in a future version.Adds a preprocessor to the configuration.- Specified by:
addPreprocessorin interfaceOfficeStamperConfiguration- 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:
isReplaceUnresolvedExpressionsin interfaceOfficeStamperConfiguration- Returns:
- a boolean
-
isLeaveEmptyOnExpressionError
public boolean isLeaveEmptyOnExpressionError()Deprecated, for removal: This API element is subject to removal in a future version.isLeaveEmptyOnExpressionError.
- Specified by:
isLeaveEmptyOnExpressionErrorin interfaceOfficeStamperConfiguration- Returns:
- a boolean
-
getUnresolvedExpressionsDefaultValue
Deprecated, for removal: This API element is subject to removal in a future version.Getter for the field
unresolvedExpressionsDefaultValue.- Specified by:
getUnresolvedExpressionsDefaultValuein interfaceOfficeStamperConfiguration- Returns:
- a
Stringobject
-
getLineBreakPlaceholder
Deprecated, for removal: This API element is subject to removal in a future version.Getter for the field
lineBreakPlaceholder.- Specified by:
getLineBreakPlaceholderin interfaceOfficeStamperConfiguration- Returns:
- a
Stringobject
-
setLineBreakPlaceholder
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:
setLineBreakPlaceholderin interfaceOfficeStamperConfiguration- Parameters:
lineBreakPlaceholder- the String that should be replaced with line breaks during stamping.- Returns:
- the configuration object for chaining.
-
getEvaluationContextConfigurer
Deprecated, for removal: This API element is subject to removal in a future version.Getter for the field
evaluationContextConfigurer.- Specified by:
getEvaluationContextConfigurerin interfaceOfficeStamperConfiguration- Returns:
- a
EvaluationContextConfigurerobject
-
setEvaluationContextConfigurer
public DocxStamperConfiguration setEvaluationContextConfigurer(EvaluationContextConfigurer evaluationContextConfigurer) Deprecated, for removal: This API element is subject to removal in a future version.Provides anEvaluationContextConfigurerwhich may change the configuration of a SpringEvaluationContextwhich is used for evaluating expressions in comments and text.- Specified by:
setEvaluationContextConfigurerin interfaceOfficeStamperConfiguration- Parameters:
evaluationContextConfigurer- the configurer to use.- Returns:
- a
DocxStamperConfigurationobject
-
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:
getSpelParserConfigurationin interfaceOfficeStamperConfiguration- Returns:
- a
SpelParserConfigurationobject
-
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 theSpelParserConfigurationto use for expression parsing.Note that this configuration will be used for all expressions in the document, including expressions in comments!
- Specified by:
setSpelParserConfigurationin interfaceOfficeStamperConfiguration- Parameters:
spelParserConfiguration- the configuration to use.- Returns:
- a
DocxStamperConfigurationobject
-
getExpressionFunctions
Deprecated, for removal: This API element is subject to removal in a future version.Getter for the field
expressionFunctions.- Specified by:
getExpressionFunctionsin interfaceOfficeStamperConfiguration- Returns:
- a
Mapobject
-
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.7Retrieves the map of type resolvers.- Specified by:
getTypeResolversin interfaceOfficeStamperConfiguration- Returns:
- the map of type resolvers
-
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:
getDefaultTypeResolverin interfaceOfficeStamperConfiguration- 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 throughaddResolver(ObjectResolver)by putting your default first in the list, or by usingsetResolvers(List)} and putting your fallback resolvers in the last place.Sets the default type resolver for the DocxStamperConfiguration.- Specified by:
setDefaultTypeResolverin interfaceOfficeStamperConfiguration- Parameters:
defaultResolver- The default type resolver to set.- Returns:
- The updated DocxStamperConfiguration instance.
-
getCommentProcessors
Deprecated, for removal: This API element is subject to removal in a future version.Getter for the field
commentProcessors.- Specified by:
getCommentProcessorsin interfaceOfficeStamperConfiguration- Returns:
- a
Mapobject
-
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:
isReplaceNullValuesin interfaceOfficeStamperConfiguration- Returns:
trueif null values should be replaced,falseotherwise.
-
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:
getNullValuesDefaultin interfaceOfficeStamperConfiguration- Returns:
- the default value for null values
-
getPreprocessors
Deprecated, for removal: This API element is subject to removal in a future version.Getter for the field
preprocessors.- Specified by:
getPreprocessorsin interfaceOfficeStamperConfiguration- Returns:
- a
Listobject
-
getResolvers
Deprecated, for removal: This API element is subject to removal in a future version.Retrieves the list of resolvers.- Specified by:
getResolversin interfaceOfficeStamperConfiguration- Returns:
- The list of object resolvers.
-
setResolvers
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:
setResolversin interfaceOfficeStamperConfiguration- Parameters:
resolvers- The list of ObjectResolvers to be set.- Returns:
- The updated DocxStamperConfiguration instance.
-
addResolver
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:
addResolverin interfaceOfficeStamperConfiguration- 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.
-
OfficeStamperConfigurations.standard()method andOfficeStamperConfigurationinterface instead. This class will not be exported in the future releases of the module.