Package org.wickedsource.docxstamper
Class DocxStamperConfiguration
java.lang.Object
org.wickedsource.docxstamper.DocxStamperConfiguration
Provides configuration parameters for DocxStamper.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCommentProcessor(Class<?> interfaceClass, ICommentProcessor commentProcessor) Registers the specified ICommentProcessor as an implementation of the specified interface.addTypeResolver(Class<T> resolvedType, ITypeResolver resolver) Registers the given ITypeResolver for the given class.build()Creates aDocxStamperinstance configured with this configuration.exposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation) Exposes all methods of a given interface to the expression language.booleanbooleanbooleanleaveEmptyOnExpressionError(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.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 defaultTypeResolver) 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 anUnresolvedExpressionExceptionif 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 replaces with a line break when stamping a document.unresolvedExpressionsDefaultValue(String unresolvedExpressionsDefaultValue) Indicates the default value to use for expressions that doesn't resolve.
-
Constructor Details
-
DocxStamperConfiguration
public DocxStamperConfiguration()
-
-
Method Details
-
setLineBreakPlaceholder
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 anEvaluationContextConfigurerwhich may change the configuration of a SpringEvaluationContextwhich is used for evaluating expressions in comments and text.- Parameters:
evaluationContextConfigurer- the configurer to use.
-
setFailOnUnresolvedExpression
If set to true, stamper will throw anUnresolvedExpressionExceptionif 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
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
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
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
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
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
Creates aDocxStamperinstance configured with this configuration. -
setDefaultTypeResolver
-
isLeaveEmptyOnExpressionError
public boolean isLeaveEmptyOnExpressionError() -
isReplaceNullValues
public boolean isReplaceNullValues() -
getNullValuesDefault
-
isReplaceUnresolvedExpressions
public boolean isReplaceUnresolvedExpressions() -
getUnresolvedExpressionsDefaultValue
-
getExpressionFunctions
-