Class DocxStamperConfiguration
- Version:
- 1.6.6
- Author:
- Joseph Verron
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCommentProcessor(Class<?> interfaceClass, CommentProcessorBuilder commentProcessorFactory) Registers the specified ICommentProcessor as an implementation of the specified interface.voidaddPreprocessor(PreProcessor preprocessor) Adds a preprocessor to the configuration.addTypeResolver(Class<T> resolvedType, ITypeResolver<T> resolver) Registers the given ITypeResolver for the given class.<T> DocxStamper<T> build()Deprecated, for removal: This API element is subject to removal in a future version.use new DocxStamper(DocxStamperConfiguration configuration) insteadexposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation) Exposes all methods of a given interface to the expression language.Getter for the fieldcommentProcessors.Getter for the fielddefaultTypeResolver.Getter for the fieldevaluationContextConfigurer.Getter for the fieldexpressionFunctions.Getter for the fieldlineBreakPlaceholder.Getter for the fieldnullValuesDefault.Getter for the fieldpreprocessors.org.springframework.expression.spel.SpelParserConfigurationGetter for the fieldspelParserConfiguration.Map<Class<?>, ITypeResolver<?>> Getter for the fieldtypeResolvers.Getter for the fieldunresolvedExpressionsDefaultValue.booleanisFailOnUnresolvedExpression.booleanisLeaveEmptyOnExpressionError.booleanisReplaceNullValues.booleanisReplaceUnresolvedExpressions.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.nullReplacementValue.nullValuesDefault(String nullValuesDefault) Indicates if expressions that resolve to null should be replaced by a global default value.replaceNullValues(boolean replaceNullValues) Indicates if expressions that resolve to null should be processed.replaceUnresolvedExpressions(boolean replaceUnresolvedExpressions) Indicates if expressions that doesn't resolve should be replaced by a default value.setDefaultTypeResolver(ITypeResolver<? super Object> defaultTypeResolver) Setter for the fielddefaultTypeResolver.setEvaluationContextConfigurer(EvaluationContextConfigurer evaluationContextConfigurer) Provides anEvaluationContextConfigurerwhich may change the configuration of a SpringEvaluationContextwhich is used for evaluating expressions in comments and text.setFailOnUnresolvedExpression(boolean failOnUnresolvedExpression) 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) The String provided as lineBreakPlaceholder will be replaced with a line break when stamping a document.setSpelParserConfiguration(org.springframework.expression.spel.SpelParserConfiguration spelParserConfiguration) Sets theSpelParserConfigurationto use for expression parsing.unresolvedExpressionsDefaultValue(String unresolvedExpressionsDefaultValue) Indicates the default value to use for expressions that doesn't resolve.
-
Constructor Details
-
DocxStamperConfiguration
public DocxStamperConfiguration()Creates a new configuration with default values.
-
-
Method Details
-
nullReplacementValue
nullReplacementValue.
- Returns:
- the
ITypeResolverfor the given type or the default resolver if no resolver is registered for the given type.
-
isFailOnUnresolvedExpression
public boolean isFailOnUnresolvedExpression()isFailOnUnresolvedExpression.
- Returns:
- a boolean
-
setLineBreakPlaceholder
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.- 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 anEvaluationContextConfigurerwhich may change the configuration of a SpringEvaluationContextwhich is used for evaluating expressions in comments and text.- Parameters:
evaluationContextConfigurer- the configurer to use.- Returns:
- a
DocxStamperConfigurationobject
-
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- Returns:
- a
DocxStamperConfigurationobject - See Also:
-
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- Returns:
- a
DocxStamperConfigurationobject
-
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- Returns:
- a
DocxStamperConfigurationobject - See Also:
-
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- Returns:
- a
DocxStamperConfigurationobject
-
leaveEmptyOnExpressionError
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- Returns:
- a
DocxStamperConfigurationobject
-
addTypeResolver
public <T> DocxStamperConfiguration addTypeResolver(Class<T> resolvedType, ITypeResolver<T> 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.- Returns:
- a
DocxStamperConfigurationobject
-
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.- Returns:
- a
DocxStamperConfigurationobject
-
addCommentProcessor
public DocxStamperConfiguration addCommentProcessor(Class<?> interfaceClass, CommentProcessorBuilder 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.- Returns:
- a
DocxStamperConfigurationobject
-
build
Deprecated, for removal: This API element is subject to removal in a future version.use new DocxStamper(DocxStamperConfiguration configuration) insteadCreates aDocxStamperinstance configured with this configuration.- Type Parameters:
T- a T class- Returns:
- a
DocxStamperobject
-
setDefaultTypeResolver
public DocxStamperConfiguration setDefaultTypeResolver(ITypeResolver<? super Object> defaultTypeResolver) Setter for the field
defaultTypeResolver.- Parameters:
defaultTypeResolver- aITypeResolverobject- Returns:
- a
DocxStamperConfigurationobject
-
addPreprocessor
Adds a preprocessor to the configuration.- Parameters:
preprocessor- the preprocessor to add.
-
setSpelParserConfiguration
public DocxStamperConfiguration setSpelParserConfiguration(org.springframework.expression.spel.SpelParserConfiguration spelParserConfiguration) Sets theSpelParserConfigurationto use for expression parsing.Note that this configuration will be used for all expressions in the document, including expressions in comments!
- Parameters:
spelParserConfiguration- the configuration to use.- Returns:
- a
DocxStamperConfigurationobject
-
setFailOnUnresolvedExpression
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.- Parameters:
failOnUnresolvedExpression- a boolean- Returns:
- a
DocxStamperConfigurationobject
-
isReplaceUnresolvedExpressions
public boolean isReplaceUnresolvedExpressions()isReplaceUnresolvedExpressions.
- Returns:
- a boolean
-
isLeaveEmptyOnExpressionError
public boolean isLeaveEmptyOnExpressionError()isLeaveEmptyOnExpressionError.
- Returns:
- a boolean
-
getUnresolvedExpressionsDefaultValue
Getter for the field
unresolvedExpressionsDefaultValue.- Returns:
- a
Stringobject
-
getLineBreakPlaceholder
Getter for the field
lineBreakPlaceholder.- Returns:
- a
Stringobject
-
getEvaluationContextConfigurer
Getter for the field
evaluationContextConfigurer.- Returns:
- a
EvaluationContextConfigurerobject
-
getSpelParserConfiguration
public org.springframework.expression.spel.SpelParserConfiguration getSpelParserConfiguration()Getter for the field
spelParserConfiguration.- Returns:
- a
SpelParserConfigurationobject
-
getExpressionFunctions
Getter for the field
expressionFunctions.- Returns:
- a
Mapobject
-
getTypeResolvers
Getter for the field
typeResolvers.- Returns:
- a
Mapobject
-
getDefaultTypeResolver
Getter for the field
defaultTypeResolver.- Returns:
- a
ITypeResolverobject
-
getCommentProcessors
Getter for the field
commentProcessors.- Returns:
- a
Mapobject
-
isReplaceNullValues
public boolean isReplaceNullValues()isReplaceNullValues.
- Returns:
- a boolean
-
getNullValuesDefault
Getter for the field
nullValuesDefault.- Returns:
- a
Stringobject
-
getPreprocessors
Getter for the field
preprocessors.- Returns:
- a
Listobject
-