TextualDocxPart.java

1
package pro.verron.officestamper.core;
2
3
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
4
import org.docx4j.openpackaging.parts.Part;
5
import org.docx4j.wml.ContentAccessor;
6
import pro.verron.officestamper.api.DocxPart;
7
8
import java.util.List;
9
10
/// Represents a textual part of a DOCX document, encapsulating the content and structure of the part while enabling
11
/// various operations such as accessing paragraphs, runs, and related parts. This class functions as a concrete
12
/// implementation of the [DocxPart] interface. It manages the association with the XML structure of a DOCX document.
13
public final class TextualDocxPart
14
        implements DocxPart {
15
    private final WordprocessingMLPackage document;
16
    private final Part part;
17
    private final ContentAccessor contentAccessor;
18
19
    /// Constructs a [TextualDocxPart] using the provided `document`. This constructor initializes the instance with the
20
    /// main document part and content accessor derived from the provided `WordprocessingMLPackage`.
21
    ///
22
    /// @param document the [WordprocessingMLPackage] representing the document to be processed.
23
    public TextualDocxPart(WordprocessingMLPackage document) {
24
        this(document, document.getMainDocumentPart(), document.getMainDocumentPart());
25
    }
26
27
    /// Constructs a [TextualDocxPart] using the specified `document`, `part`, and `contentAccessor`.
28
    ///
29
    /// @param document the [WordprocessingMLPackage] representing the document to be processed.
30
    /// @param part the specific part of the document being processed.
31
    /// @param contentAccessor the content accessor associated with the document part.
32
    public TextualDocxPart(WordprocessingMLPackage document, Part part, ContentAccessor contentAccessor) {
33
        this.document = document;
34
        this.part = part;
35
        this.contentAccessor = contentAccessor;
36
    }
37
38
    /// Retrieves the part associated with this instance of the document part.
39
    ///
40
    /// @return the [Part] object representing the specific part associated with this instance.
41
    @Override
42 1 1. part : replaced return value with null for pro/verron/officestamper/core/TextualDocxPart::part → TIMED_OUT
    public Part part() {return part;}
43
44
    /// Retrieves the list of content objects associated with this document part.
45
    ///
46
    /// @return a list of objects representing the content of the document part.
47
    @Override
48 1 1. content : replaced return value with Collections.emptyList for pro/verron/officestamper/core/TextualDocxPart::content → KILLED
    public List<Object> content() {return contentAccessor.getContent();}
49
50
    /// Returns the [WordprocessingMLPackage] instance representing the document associated with this part.
51
    ///
52
    /// @return the [WordprocessingMLPackage] instance representing the document.
53 1 1. document : replaced return value with null for pro/verron/officestamper/core/TextualDocxPart::document → KILLED
    public WordprocessingMLPackage document() {return document;}
54
}

Mutations

42

1.1
Location : part
Killed by : none
replaced return value with null for pro/verron/officestamper/core/TextualDocxPart::part → TIMED_OUT

48

1.1
Location : content
Killed by : pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest]/[test-template:fails(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/TextualDocxPart::content → KILLED

53

1.1
Location : document
Killed by : pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest]/[test-template:fails(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
replaced return value with null for pro/verron/officestamper/core/TextualDocxPart::document → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.0