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 [WordprocessingMLPackage]. This constructor initializes the
20
    ///  instance with the
21
    /// main document part and content accessor derived from the provided [WordprocessingMLPackage].
22
    ///
23
    /// @param document the [WordprocessingMLPackage] representing the document to be processed.
24
    public TextualDocxPart(WordprocessingMLPackage document) {
25
        this(document, document.getMainDocumentPart(), document.getMainDocumentPart());
26
    }
27
28
    /// Constructs a [TextualDocxPart] using the specified [WordprocessingMLPackage], [Part], and [ContentAccessor].
29
    ///
30
    /// @param document the [WordprocessingMLPackage] representing the document to be processed.
31
    /// @param part the specific part of the document being processed.
32
    /// @param contentAccessor the content accessor associated with the document part.
33
    public TextualDocxPart(WordprocessingMLPackage document, Part part, ContentAccessor contentAccessor) {
34
        this.document = document;
35
        this.part = part;
36
        this.contentAccessor = contentAccessor;
37
    }
38
39
    /// Retrieves the part associated with this instance of the document part.
40
    ///
41
    /// @return the [Part] object representing the specific part associated with this instance.
42
    @Override
43 1 1. part : replaced return value with null for pro/verron/officestamper/core/TextualDocxPart::part → KILLED
    public Part part() {return part;}
44
45
    /// Retrieves the list of content objects associated with this document part.
46
    ///
47
    /// @return a list of objects representing the content of the document part.
48
    @Override
49 1 1. content : replaced return value with Collections.emptyList for pro/verron/officestamper/core/TextualDocxPart::content → KILLED
    public List<Object> content() {return contentAccessor.getContent();}
50
51
    /// Returns the [WordprocessingMLPackage] instance representing the document associated with this part.
52
    ///
53
    /// @return the [WordprocessingMLPackage] instance representing the document.
54 1 1. document : replaced return value with null for pro/verron/officestamper/core/TextualDocxPart::document → KILLED
    public WordprocessingMLPackage document() {return document;}
55
}

Mutations

43

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

49

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:#2]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/TextualDocxPart::content → KILLED

54

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:#2]
replaced return value with null for pro/verron/officestamper/core/TextualDocxPart::document → KILLED

Active mutators

Tests examined


Report generated by PIT 1.23.1 support