AsciiDocCompiler.java

1
package pro.verron.officestamper.asciidoc;
2
3
import javafx.scene.Scene;
4
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
5
6
/// Facade utilities to parse AsciiDoc and compile it to different targets.
7
public final class AsciiDocCompiler {
8
9
    public static final AsciiDocToHtml MODEL_TO_HTML = new AsciiDocToHtml();
10
    public static final AsciiDocToFx MODEL_TO_SCENE = new AsciiDocToFx();
11
    public static final AsciiDocParser ASCIIDOC_TO_MODEL = new AsciiDocParser();
12
    public static final AsciiDocToDocx MODEL_TO_DOCX = new AsciiDocToDocx();
13
    private static final AsciiDocToText MODEL_TO_ASCIIDOC = new AsciiDocToText();
14
15
    private AsciiDocCompiler() {
16
        throw new IllegalStateException("Utility class");
17
    }
18
19
    /// Compiles the AsciiDoc source text directly to a WordprocessingMLPackage.
20
    ///
21
    /// @param asciidoc source text
22
    ///
23
    /// @return package with rendered content
24
    public static WordprocessingMLPackage toDocx(String asciidoc) {
25 1 1. toDocx : replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toDocx → NO_COVERAGE
        return toDocx(toModel(asciidoc));
26
    }
27
28
    /// Compiles the parsed model to a WordprocessingMLPackage.
29
    ///
30
    /// @param model parsed model
31
    ///
32
    /// @return package with rendered content
33
    public static WordprocessingMLPackage toDocx(AsciiDocModel model) {
34 1 1. toDocx : replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toDocx → KILLED
        return MODEL_TO_DOCX.apply(model);
35
    }
36
37
    /// Parses AsciiDoc source text into an [AsciiDocModel].
38
    ///
39
    /// @param asciidoc source text
40
    ///
41
    /// @return parsed model
42
    public static AsciiDocModel toModel(String asciidoc) {
43 1 1. toModel : replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toModel → NO_COVERAGE
        return ASCIIDOC_TO_MODEL.apply(asciidoc);
44
    }
45
46
    /// Compiles the AsciiDoc source text directly to a JavaFX Scene.
47
    ///
48
    /// @param asciidoc source text
49
    ///
50
    /// @return scene with rendered content
51
    public static Scene toScene(String asciidoc) {
52
        var model = ASCIIDOC_TO_MODEL.apply(asciidoc);
53 1 1. toScene : replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toScene → NO_COVERAGE
        return MODEL_TO_SCENE.apply(model);
54
    }
55
56
    /// Compiles the parsed model to a JavaFX Scene.
57
    ///
58
    /// @param model parsed model
59
    ///
60
    /// @return scene with rendered content
61
    public static Scene toScene(AsciiDocModel model) {
62 1 1. toScene : replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toScene → NO_COVERAGE
        return MODEL_TO_SCENE.apply(model);
63
    }
64
65
    /// Compiles the AsciiDoc source text directly to HTML.
66
    ///
67
    /// @param asciidoc source text
68
    ///
69
    /// @return HTML representation
70
    public static String toHtml(String asciidoc) {
71
        var model = ASCIIDOC_TO_MODEL.apply(asciidoc);
72 1 1. toHtml : replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toHtml → NO_COVERAGE
        return MODEL_TO_HTML.apply(model);
73
    }
74
75
    /// Compiles the parsed model to HTML.
76
    ///
77
    /// @param model parsed model
78
    ///
79
    /// @return HTML representation
80
    public static String toHtml(AsciiDocModel model) {
81 1 1. toHtml : replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toHtml → NO_COVERAGE
        return MODEL_TO_HTML.apply(model);
82
    }
83
84
    /// Compiles a WordprocessingMLPackage into the textual AsciiDoc representation used by tests. This mirrors the
85
    /// legacy Stringifier output to preserve expectations.
86
    ///
87
    /// @param pkg a Word document package
88
    ///
89
    /// @return textual representation
90
    public static String toAsciidoc(WordprocessingMLPackage pkg) {
91
        var model = toModel(pkg);
92 1 1. toAsciidoc : replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toAsciidoc → KILLED
        return MODEL_TO_ASCIIDOC.apply(model);
93
    }
94
95
    /// Parses a Word document into an [AsciiDocModel].
96
    ///
97
    /// @param pkg a Word document package
98
    ///
99
    /// @return parsed model
100
    public static AsciiDocModel toModel(WordprocessingMLPackage pkg) {
101
        var compiler = new DocxToAsciiDoc(pkg);
102 1 1. toModel : replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toModel → KILLED
        return compiler.apply(pkg);
103
    }
104
105
    /// Compiles the parsed model to its textual AsciiDoc representation.
106
    ///
107
    /// @param model parsed model
108
    ///
109
    /// @return textual representation
110
    public static String toAsciidoc(AsciiDocModel model) {
111 1 1. toAsciidoc : replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toAsciidoc → NO_COVERAGE
        return MODEL_TO_ASCIIDOC.apply(model);
112
    }
113
}

Mutations

25

1.1
Location : toDocx
Killed by : none
replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toDocx → NO_COVERAGE

34

1.1
Location : toDocx
Killed by : pro.verron.officestamper.asciidoc.test.DocxToAsciiDocTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.asciidoc.test.DocxToAsciiDocTest]/[method:shouldRenderNestedTable()]
replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toDocx → KILLED

43

1.1
Location : toModel
Killed by : none
replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toModel → NO_COVERAGE

53

1.1
Location : toScene
Killed by : none
replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toScene → NO_COVERAGE

62

1.1
Location : toScene
Killed by : none
replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toScene → NO_COVERAGE

72

1.1
Location : toHtml
Killed by : none
replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toHtml → NO_COVERAGE

81

1.1
Location : toHtml
Killed by : none
replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toHtml → NO_COVERAGE

92

1.1
Location : toAsciidoc
Killed by : pro.verron.officestamper.asciidoc.test.DocxToAsciiDocTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.asciidoc.test.DocxToAsciiDocTest]/[method:shouldRenderNestedTable()]
replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toAsciidoc → KILLED

102

1.1
Location : toModel
Killed by : pro.verron.officestamper.asciidoc.test.DocxToAsciiDocTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.asciidoc.test.DocxToAsciiDocTest]/[method:shouldRenderNestedTable()]
replaced return value with null for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toModel → KILLED

111

1.1
Location : toAsciidoc
Killed by : none
replaced return value with "" for pro/verron/officestamper/asciidoc/AsciiDocCompiler::toAsciidoc → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.1