Class ReplaceWithProcessor
java.lang.Object
org.wickedsource.docxstamper.processor.BaseCommentProcessor
org.wickedsource.docxstamper.processor.replaceExpression.ReplaceWithProcessor
- All Implemented Interfaces:
ICommentProcessor,IReplaceWithProcessor
Processor that replaces the current run with the provided expression.
This is useful for replacing an expression in a comment with the result of the expression.
- Version:
- ${version}
- Author:
- Joseph Verron
-
Field Summary
Fields inherited from class org.wickedsource.docxstamper.processor.BaseCommentProcessor
placeholderReplacer -
Method Summary
Modifier and TypeMethodDescriptionvoidcommitChanges(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) This method is called after all comments in the .docx template have been passed to the comment processor.static ICommentProcessorCreates a new processor that replaces the current run with the result of the expression.static ICommentProcessornewInstance(PlaceholderReplacer pr, String nullReplacementValue) Creates a new processor that replaces the current run with the result of the expression.voidreplaceWordWith(String expression) May be called to replace a single word inside a paragraph with an expression defined in a comment.voidreset()Resets all state in the comment processor so that it can be re-used in another stamping process.Methods inherited from class org.wickedsource.docxstamper.processor.BaseCommentProcessor
getCurrentCommentWrapper, getCurrentRun, getDocument, getParagraph, setCurrentCommentWrapper, setCurrentRun, setDocument, setParagraph
-
Method Details
-
newInstance
Creates a new processor that replaces the current run with the result of the expression.- Parameters:
pr- the placeholder replacer to usenullReplacementValue- aStringobject- Returns:
- the processor
-
newInstance
Creates a new processor that replaces the current run with the result of the expression.- Parameters:
pr- the placeholder replacer to use- Returns:
- the processor
-
commitChanges
public void commitChanges(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) This method is called after all comments in the .docx template have been passed to the comment processor. All manipulations of the .docx document SHOULD BE done in this method. If certain manipulations are already done within in the custom methods of a comment processor, the ongoing iteration over the paragraphs in the document may be disturbed.- Specified by:
commitChangesin interfaceICommentProcessor- Parameters:
document- The Word document that can be manipulated by using the DOCX4J api.
-
reset
public void reset()Resets all state in the comment processor so that it can be re-used in another stamping process.- Specified by:
resetin interfaceICommentProcessor
-
replaceWordWith
May be called to replace a single word inside a paragraph with an expression defined in a comment. The comment must be applied to a single word for the replacement to take effect!- Specified by:
replaceWordWithin interfaceIReplaceWithProcessor- Parameters:
expression- the expression to replace the text with
-