Interface Paragraph

All Known Implementing Classes:
PowerpointParagraph, StandardParagraph

public interface Paragraph
The Paragraph interface represents a paragraph in a text document. It provides methods for replacing a placeholder within the paragraph and retrieving the paragraph as a string.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(Consumer<org.docx4j.wml.ContentAccessor> pConsumer)
    Applies the specified consumer function to the paragraph content.
    Returns the paragraph as a string.
    Collection<org.docx4j.wml.Comments.Comment>
    Retrieves a collection of comments associated with the paragraph.
    <T> Optional<T>
    parent(Class<T> aClass)
    Retrieves the parent of the current paragraph that matches the specified class type.
    Retrieves the parent table of the current paragraph, if it exists.
    Retrieves the parent table row of the current paragraph, if it exists.
    void
    Removes the paragraph from the document.
    void
    replace(Object start, Object end, Insert insert)
    Replaces a section of elements within the document, defined by the start and end objects, with the elements provided by the given insert.
    void
    replace(String expression, Insert insert)
    Replaces a specified placeholder within the paragraph with the provided insert.
    void
    replace(List<org.docx4j.wml.P> toRemove, List<org.docx4j.wml.P> toAdd)
    Replaces specified contiguous elements within the paragraph with new elements.
  • Method Details

    • replace

      void replace(List<org.docx4j.wml.P> toRemove, List<org.docx4j.wml.P> toAdd)
      Replaces specified contiguous elements within the paragraph with new elements.
      Parameters:
      toRemove - The list of elements to be removed from the paragraph.
      toAdd - The list of elements to be added to the paragraph.
    • remove

      void remove()
      Removes the paragraph from the document. This method is intended to be used when a paragraph needs to be deleted.
    • replace

      void replace(String expression, Insert insert)
      Replaces a specified placeholder within the paragraph with the provided insert.
      Parameters:
      expression - the expression to replace.
      insert - the insert containing elements that will replace the placeholder.
    • replace

      void replace(Object start, Object end, Insert insert)
      Replaces a section of elements within the document, defined by the start and end objects, with the elements provided by the given insert.
      Parameters:
      start - the starting object marking the beginning of the section to replace.
      end - the ending object marking the end of the section to replace.
      insert - the insert containing the elements that will replace the specified section.
    • asString

      String asString()
      Returns the paragraph as a string.
      Returns:
      the paragraph as a string
    • apply

      void apply(Consumer<org.docx4j.wml.ContentAccessor> pConsumer)
      Applies the specified consumer function to the paragraph content.
      Parameters:
      pConsumer - The consumer function to apply to the paragraph content.
    • parent

      <T> Optional<T> parent(Class<T> aClass)
      Retrieves the parent of the current paragraph that matches the specified class type.
      Type Parameters:
      T - The type of the parent element to be returned.
      Parameters:
      aClass - The class type to match for the parent element.
      Returns:
      An Optional containing the matched parent element if found, otherwise an empty Optional.
    • getComment

      Collection<org.docx4j.wml.Comments.Comment> getComment()
      Retrieves a collection of comments associated with the paragraph.
      Returns:
      a collection of Comments.Comment objects related to the paragraph
    • parentTableRow

      Optional<Table.Row> parentTableRow()
      Retrieves the parent table row of the current paragraph, if it exists.
      Returns:
      an Optional containing the parent Table.Row if the paragraph is within a table row, otherwise an empty Optional
    • parentTable

      Optional<Table> parentTable()
      Retrieves the parent table of the current paragraph, if it exists.
      Returns:
      an Optional containing the parent Table if the paragraph is within a table, otherwise an empty Optional