OfficeStampers.java

1
package pro.verron.officestamper.preset;
2
3
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
4
import pro.verron.officestamper.api.OfficeStamper;
5
import pro.verron.officestamper.api.OfficeStamperConfiguration;
6
import pro.verron.officestamper.api.OfficeStamperException;
7
import pro.verron.officestamper.api.StreamStamper;
8
import pro.verron.officestamper.core.DocxStamper;
9
import pro.verron.officestamper.utils.openpackaging.OpenpackagingUtils;
10
11
/// [OfficeStampers] is a utility class that provides factory methods for creating document stampers for Office
12
/// documents. This class offers convenient methods to create stampers for DOCX documents with various configurations.
13
///
14
/// The stampers created by this utility can apply various preprocessing steps to enhance the document processing
15
/// capabilities.
16
public class OfficeStampers {
17
18
    private OfficeStampers() {
19
        throw new OfficeStamperException("Utility classes should not be instantiated");
20
    }
21
22
    /// Creates a new instance of a [StreamStamper] for handling [WordprocessingMLPackage] documents with a default full
23
    /// configuration.
24
    ///
25
    /// @return a [StreamStamper] instance for stamping [WordprocessingMLPackage] documents
26
    /// @see OfficeStamperConfigurations#full()
27
    public static StreamStamper<WordprocessingMLPackage> docxStamper() {
28 1 1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE
        return docxStamper(OfficeStamperConfigurations.full());
29
    }
30
31
    /// Creates a [StreamStamper] instance that processes [WordprocessingMLPackage] (DOCX) documents by applying
32
    /// stamping with the given configuration.
33
    ///
34
    /// The returned stamper is designed to handle the transformation of DOCX templates using provided context data.
35
    ///
36
    /// @param configuration an instance of [OfficeStamperConfiguration] that defines the behavior and
37
    ///         preprocessing steps of the stamper
38
    /// @return a [StreamStamper] of [WordprocessingMLPackage] configured to process DOCX documents
39
    public static StreamStamper<WordprocessingMLPackage> docxStamper(OfficeStamperConfiguration configuration) {
40
        var stamper = docxPackageStamper(configuration);
41 1 1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE
        return new StreamStamper<>(OpenpackagingUtils::loadWord, stamper, OpenpackagingUtils::exportWord);
42
    }
43
44
    /// Creates an [OfficeStamper] instance for processing [WordprocessingMLPackage] documents with the specified
45
    /// configuration.
46
    ///
47
    /// @param configuration an instance of [OfficeStamperConfiguration] that defines the behavior of the
48
    ///         stamper
49
    ///
50
    /// @return an [OfficeStamper] for [WordprocessingMLPackage] configured to process DOCX documents
51
    public static OfficeStamper<WordprocessingMLPackage> docxPackageStamper(OfficeStamperConfiguration configuration) {
52 1 1. docxPackageStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxPackageStamper → KILLED
        return new DocxStamper(configuration);
53
    }
54
}

Mutations

28

1.1
Location : docxStamper
Killed by : none
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE

41

1.1
Location : docxStamper
Killed by : none
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE

52

1.1
Location : docxPackageStamper
Killed by : pro.verron.officestamper.test.DateFormatTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DateFormatTests]/[test-template:features(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxPackageStamper → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.5 support