Record Class IndexedRun

java.lang.Object
java.lang.Record
org.wickedsource.docxstamper.util.IndexedRun
Record Components:
startIndex - the start index of the run relative to the containing paragraph.
endIndex - the end index of the run relative to the containing paragraph.
indexInParent - the index of the run relative to the containing document.
run - the run itself.

public record IndexedRun(int startIndex, int endIndex, int indexInParent, org.docx4j.wml.R run) extends Record
Represents a run (i.e. a text fragment) in a paragraph. The run is indexed relative to the containing paragraph and also relative to the containing document.
  • Constructor Summary

    Constructors
    Constructor
    Description
    IndexedRun(int startIndex, int endIndex, int indexInParent, org.docx4j.wml.R run)
    Creates an instance of a IndexedRun record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the endIndex record component.
    boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    int
    Returns the value of the indexInParent record component.
    boolean
    isTouchedByRange(int globalStartIndex, int globalEndIndex)
    Determines whether the specified range of start and end index touches this run.
    void
    replace(int globalStartIndex, int globalEndIndex, String replacement)
    Replaces the substring starting at the given index with the given replacement string.
    org.docx4j.wml.R
    run()
    Returns the value of the run record component.
    int
    Returns the value of the startIndex record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IndexedRun

      public IndexedRun(int startIndex, int endIndex, int indexInParent, org.docx4j.wml.R run)
      Creates an instance of a IndexedRun record class.
      Parameters:
      startIndex - the value for the startIndex record component
      endIndex - the value for the endIndex record component
      indexInParent - the value for the indexInParent record component
      run - the value for the run record component
  • Method Details

    • isTouchedByRange

      public boolean isTouchedByRange(int globalStartIndex, int globalEndIndex)
      Determines whether the specified range of start and end index touches this run.

      Example:

      Given this run: [a,b,c,d,e,f,g,h,i,j]

      And the range [2,5]

      This method will return true, because the range touches the run at the indices 2, 3, 4 and 5.

      Parameters:
      globalStartIndex - the global index (meaning the index relative to multiple aggregated runs) at which to start the range.
      globalEndIndex - the global index (meaning the index relative to multiple aggregated runs) at which to end the range.
      Returns:
      true, if the range touches this run, false otherwise.
    • replace

      public void replace(int globalStartIndex, int globalEndIndex, String replacement)
      Replaces the substring starting at the given index with the given replacement string.
      Parameters:
      globalStartIndex - the global index (meaning the index relative to multiple aggregated runs) at which to start the replacement.
      globalEndIndex - the global index (meaning the index relative to multiple aggregated runs) at which to end the replacement.
      replacement - the string to replace the substring at the specified global index.
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • startIndex

      public int startIndex()
      Returns the value of the startIndex record component.
      Returns:
      the value of the startIndex record component
    • endIndex

      public int endIndex()
      Returns the value of the endIndex record component.
      Returns:
      the value of the endIndex record component
    • indexInParent

      public int indexInParent()
      Returns the value of the indexInParent record component.
      Returns:
      the value of the indexInParent record component
    • run

      public org.docx4j.wml.R run()
      Returns the value of the run record component.
      Returns:
      the value of the run record component