diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-24 20:57:33 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-24 20:57:33 +0000 |
| commit | d4ac19bac1d0e1315d129c39de56121def95007b (patch) | |
| tree | 57b533fe35eb7e745c3a7676f3292e8392f51345 | |
| parent | b693b50ba55ab80cb7df90f150bf6585ba9fdc09 (diff) | |
Rename Mammoth to DocumentConverter
| -rw-r--r-- | src/main/java/org/zwobble/mammoth/DocumentConverter.java (renamed from src/main/java/org/zwobble/mammoth/Mammoth.java) | 20 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/MammothTests.java | 16 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/main/java/org/zwobble/mammoth/Mammoth.java b/src/main/java/org/zwobble/mammoth/DocumentConverter.java index e979afc..31464e7 100644 --- a/src/main/java/org/zwobble/mammoth/Mammoth.java +++ b/src/main/java/org/zwobble/mammoth/DocumentConverter.java @@ -27,27 +27,27 @@ import java.util.zip.ZipFile; import static org.zwobble.mammoth.internal.docx.DocumentReader.readDocument; import static org.zwobble.mammoth.internal.util.MammothLists.list; -public class Mammoth { +public class DocumentConverter { private final DocumentToHtmlOptions options; - public Mammoth() { + public DocumentConverter() { this(DocumentToHtmlOptions.DEFAULT.addStyleMap(DefaultStyles.DEFAULT_STYLE_MAP)); } - private Mammoth(DocumentToHtmlOptions options) { + private DocumentConverter(DocumentToHtmlOptions options) { this.options = options; } - public Mammoth idPrefix(String idPrefix) { - return new Mammoth(options.idPrefix(idPrefix)); + public DocumentConverter idPrefix(String idPrefix) { + return new DocumentConverter(options.idPrefix(idPrefix)); } - public Mammoth preserveEmptyParagraphs() { - return new Mammoth(options.preserveEmptyParagraphs()); + public DocumentConverter preserveEmptyParagraphs() { + return new DocumentConverter(options.preserveEmptyParagraphs()); } - public Mammoth addStyleMap(String styleMap) { - return new Mammoth(options.addStyleMap(styleMap)); + public DocumentConverter addStyleMap(String styleMap) { + return new DocumentConverter(options.addStyleMap(styleMap)); } public Result<String> convertToHtml(InputStream stream) throws IOException { @@ -71,7 +71,7 @@ public class Mammoth { public static Result<String> extractRawText(File file) throws IOException { return withDocxFile(file, zipFile -> readDocument(Optional.of(file.toPath()), zipFile) - .map(Mammoth::extractRawTextOfChildren)); + .map(DocumentConverter::extractRawTextOfChildren)); } private static <T> T withDocxFile(File file, Function<DocxFile, T> function) throws IOException { diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java index 288c6a2..efb95f0 100644 --- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java @@ -1,7 +1,7 @@ package org.zwobble.mammoth.tests; import org.junit.Test; -import org.zwobble.mammoth.Mammoth; +import org.zwobble.mammoth.DocumentConverter; import org.zwobble.mammoth.results.Result; import java.io.File; @@ -79,7 +79,7 @@ public class MammothTests { Files.copy(TestData.file("external-picture.docx").toPath(), documentPath); Files.copy(TestData.file("tiny-picture.png").toPath(), tempDirectory.resolve("tiny-picture.png")); assertThat( - new Mammoth().convertToHtml(documentPath.toFile()), + new DocumentConverter().convertToHtml(documentPath.toFile()), deepEquals(success("<p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=\" /></p>"))); } finally { tempDirectory.toFile().delete(); @@ -93,7 +93,7 @@ public class MammothTests { Path documentPath = tempDirectory.resolve("external-picture.docx"); Files.copy(TestData.file("external-picture.docx").toPath(), documentPath); assertThat( - new Mammoth().convertToHtml(documentPath.toUri().toURL().openStream()), + new DocumentConverter().convertToHtml(documentPath.toUri().toURL().openStream()), allOf( hasProperty("value", equalTo("")), hasProperty("warnings", contains( @@ -110,7 +110,7 @@ public class MammothTests { Path documentPath = tempDirectory.resolve("external-picture.docx"); Files.copy(TestData.file("external-picture.docx").toPath(), documentPath); assertThat( - new Mammoth().convertToHtml(documentPath.toFile()), + new DocumentConverter().convertToHtml(documentPath.toFile()), allOf( hasProperty("value", equalTo("")), hasProperty("warnings", contains( @@ -191,17 +191,17 @@ public class MammothTests { @Test public void canExtractRawText() throws IOException { assertThat( - Mammoth.extractRawText(TestData.file("simple-list.docx")), + DocumentConverter.extractRawText(TestData.file("simple-list.docx")), deepEquals(success("Apple\n\nBanana\n\n"))); } private Result<String> convertToHtml(String name) throws IOException { File file = TestData.file(name); - return new Mammoth().convertToHtml(file); + return new DocumentConverter().convertToHtml(file); } - private Result<String> convertToHtml(String name, Function<Mammoth, Mammoth> configure) throws IOException { + private Result<String> convertToHtml(String name, Function<DocumentConverter, DocumentConverter> configure) throws IOException { File file = TestData.file(name); - return configure.apply(new Mammoth()).convertToHtml(file); + return configure.apply(new DocumentConverter()).convertToHtml(file); } } |
