Class StandardParagraph

java.lang.Object
pro.verron.officestamper.core.StandardParagraph
All Implemented Interfaces:
Paragraph

public class StandardParagraph extends Object implements Paragraph

A "Run" defines a region of text within a docx document with a common set of properties. Word processors are relatively free in splitting a paragraph of text into multiple runs, so there is no strict rule to say over how many runs a word or a string of words is spread.

This class aggregates multiple runs so they can be treated as a single text, no matter how many runs the text spans. Call addRun(R, int) to add all runs that should be aggregated. Then, call methods to modify the aggregated text. Finally, call asString() to get the modified text.

Since:
1.0.8
Version:
${version}
Author:
Joseph Verron, Tom Hombergs
  • Constructor Details

    • StandardParagraph

      public StandardParagraph(org.docx4j.wml.P paragraph)
      Constructs a new ParagraphWrapper for the given paragraph.
      Parameters:
      paragraph - the paragraph to wrap.
  • Method Details

    • replace

      public void replace(Placeholder placeholder, Object replacement)
      Replaces the given expression with the replacement object within the paragraph. The replacement object must be a valid DOCX4J Object.
      Specified by:
      replace in interface Paragraph
      Parameters:
      placeholder - the expression to be replaced.
      replacement - the object to replace the expression.
    • asString

      public String asString()
      Returns the aggregated text over all runs.
      Specified by:
      asString in interface Paragraph
      Returns:
      the text of all runs.
    • toString

      public String toString()
      Overrides:
      toString in class Object