Package org.wickedsource.docxstamper
Class DocxStamperConfiguration
- java.lang.Object
-
- org.wickedsource.docxstamper.DocxStamperConfiguration
-
public class DocxStamperConfiguration extends Object
Provides configuration parameters for DocxStamper.
-
-
Constructor Summary
Constructors Constructor Description DocxStamperConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DocxStamperConfigurationaddCommentProcessor(Class<?> interfaceClass, ICommentProcessor commentProcessor)Registers the specified ICommentProcessor as an implementation of the specified interface.<T> DocxStamperConfigurationaddTypeResolver(Class<T> resolvedType, ITypeResolver resolver)Registers the given ITypeResolver for the given class.DocxStamperbuild()Creates aDocxStamperinstance configured with this configuration.DocxStamperConfigurationexposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation)Exposes all methods of a given interface to the expression language.Map<Class<?>,Object>getCommentProcessors()EvaluationContextConfigurergetEvaluationContextConfigurer()Map<Class<?>,Object>getExpressionFunctions()StringgetLineBreakPlaceholder()StringgetNullValuesDefault()StringgetUnresolvedExpressionsDefaultValue()booleanisFailOnUnresolvedExpression()booleanisLeaveEmptyOnExpressionError()booleanisReplaceNullValues()booleanisReplaceUnresolvedExpressions()DocxStamperConfigurationleaveEmptyOnExpressionError(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.DocxStamperConfigurationnullValuesDefault(String nullValuesDefault)Indicates if expressions that resolve to null should be replaced by a global default value.DocxStamperConfigurationreplaceNullValues(boolean replaceNullValues)Indicates if expressions that resolve to null should be processed.DocxStamperConfigurationreplaceUnresolvedExpressions(boolean replaceUnresolvedExpressions)Indicates if expressions that doesn't resolve should be replaced by a default value.DocxStamperConfigurationsetDefaultTypeResolver(ITypeResolver defaultTypeResolver)DocxStamperConfigurationsetEvaluationContextConfigurer(EvaluationContextConfigurer evaluationContextConfigurer)Provides anEvaluationContextConfigurerwhich may change the configuration of a SpringEvaluationContextwhich is used for evaluating expressions in comments and text.DocxStamperConfigurationsetFailOnUnresolvedExpression(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.DocxStamperConfigurationsetLineBreakPlaceholder(String lineBreakPlaceholder)The String provided as lineBreakPlaceholder will be replaces with a line break when stamping a document.DocxStamperConfigurationunresolvedExpressionsDefaultValue(String unresolvedExpressionsDefaultValue)Indicates the default value to use for expressions that doesn't resolve.
-
-
-
Method Detail
-
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.
-
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
public DocxStamperConfiguration 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. 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
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.
-
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
-
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
-
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
-
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
-
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
public DocxStamper build()
Creates aDocxStamperinstance configured with this configuration.
-
getEvaluationContextConfigurer
public EvaluationContextConfigurer getEvaluationContextConfigurer()
-
isFailOnUnresolvedExpression
public boolean isFailOnUnresolvedExpression()
-
setDefaultTypeResolver
public DocxStamperConfiguration setDefaultTypeResolver(ITypeResolver defaultTypeResolver)
-
isLeaveEmptyOnExpressionError
public boolean isLeaveEmptyOnExpressionError()
-
isReplaceNullValues
public boolean isReplaceNullValues()
-
getNullValuesDefault
public String getNullValuesDefault()
-
isReplaceUnresolvedExpressions
public boolean isReplaceUnresolvedExpressions()
-
getUnresolvedExpressionsDefaultValue
public String getUnresolvedExpressionsDefaultValue()
-
getLineBreakPlaceholder
public String getLineBreakPlaceholder()
-
-