Class PlaceholderHooker
java.lang.Object
pro.verron.officestamper.api.PlaceholderHooker
- All Implemented Interfaces:
PreProcessor
The PlaceholderHooker class is a pre-processor that prepares inline placeholders in a WordprocessingML
document. It searches for placeholders that match a given pattern and wraps them with a specified XML element to
ensure proper processing by the OfficeStamper engine.
This pre-processor is typically used to identify and mark inline expressions within paragraphs, making them recognizable for subsequent processing steps.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classATraversalUtilVisitorimplementation that collects paragraphs matching a given pattern. -
Constructor Summary
ConstructorsConstructorDescriptionPlaceholderHooker(String regex, String element) Constructs a newPlaceholderHookerinstance with the specified regular expression and XML element name.PlaceholderHooker(Pattern pattern, String element) Constructs a newPlaceholderHookerinstance with the specified pattern and XML element name. -
Method Summary
Modifier and TypeMethodDescriptionvoidprocess(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Processes the provided WordprocessingMLPackage document based on implementation-specific behavior.
-
Constructor Details
-
PlaceholderHooker
Constructs a newPlaceholderHookerinstance with the specified regular expression and XML element name.- Parameters:
regex- the regular expression pattern used to identify inline placeholders in the document. This pattern should contain at least two capturing groups where the second group represents the actual placeholder content.element- the name of the XML element to wrap around identified placeholders. This element will be used to mark the placeholders for further processing.
-
PlaceholderHooker
Constructs a newPlaceholderHookerinstance with the specified pattern and XML element name.- Parameters:
pattern- the compiled regular expression pattern used to identify inline placeholders in the document. This pattern should contain at least two capturing groups where the second group represents the actual placeholder content.element- the name of the XML element to wrap around identified placeholders. This element will be used to mark the placeholders for further processing.
-
-
Method Details
-
process
public void process(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Description copied from interface:PreProcessorProcesses the provided WordprocessingMLPackage document based on implementation-specific behavior. This method allows for manipulation or transformation of the document, such as modifying its content, sanitizing specific sections, or preparing the document for further actions.- Specified by:
processin interfacePreProcessor- Parameters:
document- the WordprocessingMLPackage document to be processed; cannot be null
-