Class PlaceholderHooker

java.lang.Object
pro.verron.officestamper.api.PlaceholderHooker
All Implemented Interfaces:
PreProcessor

public class PlaceholderHooker extends Object implements 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.

  • Constructor Details

    • PlaceholderHooker

      public PlaceholderHooker(String regex, String element)
      Constructs a new PlaceholderHooker instance 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

      public PlaceholderHooker(Pattern pattern, String element)
      Constructs a new PlaceholderHooker instance 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: PreProcessor
      Processes 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:
      process in interface PreProcessor
      Parameters:
      document - the WordprocessingMLPackage document to be processed; cannot be null