ExcelParagraph.java

1
package pro.verron.officestamper.experimental;
2
3
import org.xlsx4j.sml.CTRst;
4
5
/// The ExcelParagraph class represents a paragraph in an Excel document. It provides methods to replace expressions and
6
/// retrieve the aggregated text over all runs.
7
public class ExcelParagraph {
8
    private final CTRst paragraph;
9
10
    /// Constructs a new ParagraphWrapper for the given paragraph.
11
    ///
12
    /// @param paragraph the paragraph to wrap.
13
    public ExcelParagraph(CTRst paragraph) {
14
        this.paragraph = paragraph;
15
    }
16
17
    /// Replaces the given expression with the replacement object within the paragraph. The replacement object must be a
18
    /// valid DOCX4J Object.
19
    ///
20
    /// @param expression  the expression to replace.
21
    /// @param replacement the object to replace the expression.
22
    public void replace(String expression, String replacement) {
23
        var ctXstringWhitespace = paragraph.getT();
24
        var string = ctXstringWhitespace.getValue();
25
        var start = string.indexOf(expression);
26 1 1. replace : Replaced integer addition with subtraction → KILLED
        var end = start + expression.length();
27
        var next = string.substring(0, start) + replacement + string.substring(end);
28 1 1. replace : removed call to org/xlsx4j/sml/CTXstringWhitespace::setValue → KILLED
        ctXstringWhitespace.setValue(next);
29
    }
30
31
    /// {@inheritDoc}
32
    @Override
33
    public String toString() {
34 1 1. toString : replaced return value with "" for pro/verron/officestamper/experimental/ExcelParagraph::toString → NO_COVERAGE
        return asString();
35
    }
36
37
    /// Returns the aggregated text over all runs.
38
    ///
39
    /// @return the text of all runs.
40
    public String asString() {
41 1 1. asString : replaced return value with "" for pro/verron/officestamper/experimental/ExcelParagraph::asString → KILLED
        return paragraph.getR() + ": " + paragraph.getT()
42
                                                  .getValue();
43
    }
44
}

Mutations

26

1.1
Location : replace
Killed by : pro.verron.officestamper.test.BasicExcelTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicExcelTest]/[method:testStamper()]
Replaced integer addition with subtraction → KILLED

28

1.1
Location : replace
Killed by : pro.verron.officestamper.test.BasicExcelTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicExcelTest]/[method:testStamper()]
removed call to org/xlsx4j/sml/CTXstringWhitespace::setValue → KILLED

34

1.1
Location : toString
Killed by : none
replaced return value with "" for pro/verron/officestamper/experimental/ExcelParagraph::toString → NO_COVERAGE

41

1.1
Location : asString
Killed by : pro.verron.officestamper.test.BasicExcelTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicExcelTest]/[method:testStamper()]
replaced return value with "" for pro/verron/officestamper/experimental/ExcelParagraph::asString → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.0