Class PlaceholderReplacer
java.lang.Object
org.wickedsource.docxstamper.replace.PlaceholderReplacer
Replaces expressions in a document with the values provided by the
ExpressionResolver.- Version:
- 1.6.6
- Author:
- Joseph Verron
-
Constructor Summary
ConstructorsConstructorDescriptionPlaceholderReplacer(TypeResolverRegistry typeResolverRegistry, ExpressionResolver expressionResolver, boolean replaceNullValues, String nullValuesDefault, boolean failOnUnresolvedExpression, boolean replaceUnresolvedExpressions, String unresolvedExpressionsDefaultValue, boolean leaveEmptyOnExpressionError, String lineBreakPlaceholder) Constructor for PlaceholderReplacer. -
Method Summary
Modifier and TypeMethodDescriptionvoidreplace(ParagraphWrapper p, String placeholder, String replacementObject) Replaces expressions in the given paragraph and replaces them with the values provided by the expression resolver.voidresolveExpressions(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, Object expressionContext) Finds expressions in a document and resolves them against the specified context object.voidresolveExpressionsForParagraph(org.docx4j.wml.P p, Object expressionContext, org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Finds expressions in the given paragraph and replaces them with the values provided by the expression resolver.
-
Constructor Details
-
PlaceholderReplacer
public PlaceholderReplacer(TypeResolverRegistry typeResolverRegistry, ExpressionResolver expressionResolver, boolean replaceNullValues, String nullValuesDefault, boolean failOnUnresolvedExpression, boolean replaceUnresolvedExpressions, String unresolvedExpressionsDefaultValue, boolean leaveEmptyOnExpressionError, String lineBreakPlaceholder) Constructor for PlaceholderReplacer.
- Parameters:
typeResolverRegistry- the registry containing all available type resolvers.expressionResolver- the expression resolver used to resolve expressions in the document.replaceNullValues- if set to true, null values are replaced with the value provided in the nullValuesDefault parameter.nullValuesDefault- the value to use when replacing null values.failOnUnresolvedExpression- if set to true, an exception is thrown when an expression cannot be resolved.replaceUnresolvedExpressions- if set to true, expressions that cannot be resolved are replaced by the value provided in the unresolvedExpressionsDefaultValue parameter.unresolvedExpressionsDefaultValue- the value to use when replacing unresolved expressions.leaveEmptyOnExpressionError- if set to true, expressions that cannot be resolved are replaced by an empty string.lineBreakPlaceholder- if set to a non-null value, all occurrences of this placeholder will be replaced with a line break.
-
-
Method Details
-
resolveExpressions
public void resolveExpressions(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, Object expressionContext) Finds expressions in a document and resolves them against the specified context object. The expressions in the document are then replaced by the resolved values.- Parameters:
document- the document in which to replace all expressions.expressionContext- the context root
-
resolveExpressionsForParagraph
public void resolveExpressionsForParagraph(org.docx4j.wml.P p, Object expressionContext, org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Finds expressions in the given paragraph and replaces them with the values provided by the expression resolver.- Parameters:
p- the paragraph in which to replace expressions.expressionContext- the context rootdocument- the document in which to replace all expressions.
-
replace
Replaces expressions in the given paragraph and replaces them with the values provided by the expression resolver.- Parameters:
p- the paragraph in which to replace expressions.placeholder- the placeholder to replace.replacementObject- the object to replace the placeholder with.
-