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
ConstructorsConstructorDescriptionIndexedRun(int startIndex, int endIndex, int indexInParent, org.docx4j.wml.R run) Creates an instance of aIndexedRunrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintendIndex()Returns the value of theendIndexrecord component.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.intReturns the value of theindexInParentrecord component.booleanisTouchedByRange(int globalStartIndex, int globalEndIndex) Determines whether the specified range of start and end index touches this run.voidReplaces the substring starting at the given index with the given replacement string.org.docx4j.wml.Rrun()Returns the value of therunrecord component.intReturns the value of thestartIndexrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
IndexedRun
public IndexedRun(int startIndex, int endIndex, int indexInParent, org.docx4j.wml.R run) Creates an instance of aIndexedRunrecord class.- Parameters:
startIndex- the value for thestartIndexrecord componentendIndex- the value for theendIndexrecord componentindexInParent- the value for theindexInParentrecord componentrun- the value for therunrecord 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
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
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
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. -
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. -
startIndex
public int startIndex()Returns the value of thestartIndexrecord component.- Returns:
- the value of the
startIndexrecord component
-
endIndex
public int endIndex()Returns the value of theendIndexrecord component.- Returns:
- the value of the
endIndexrecord component
-
indexInParent
public int indexInParent()Returns the value of theindexInParentrecord component.- Returns:
- the value of the
indexInParentrecord component
-
run
public org.docx4j.wml.R run()Returns the value of therunrecord component.- Returns:
- the value of the
runrecord component
-