diff options
Diffstat (limited to 'src/main/java/org/zwobble/mammoth/docx/NotesXmlReader.java')
| -rw-r--r-- | src/main/java/org/zwobble/mammoth/docx/NotesXmlReader.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/org/zwobble/mammoth/docx/NotesXmlReader.java b/src/main/java/org/zwobble/mammoth/docx/NotesXmlReader.java index 0838076..726c476 100644 --- a/src/main/java/org/zwobble/mammoth/docx/NotesXmlReader.java +++ b/src/main/java/org/zwobble/mammoth/docx/NotesXmlReader.java @@ -1,5 +1,6 @@ package org.zwobble.mammoth.docx; +import org.zwobble.mammoth.documents.NoteType; import org.zwobble.mammoth.results.Result; import org.zwobble.mammoth.documents.Note; import org.zwobble.mammoth.xml.XmlElement; @@ -10,16 +11,22 @@ import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; public class NotesXmlReader { + public static NotesXmlReader footnote(BodyXmlReader bodyReader) { + return new NotesXmlReader(bodyReader, "footnote", NoteType.FOOTNOTE); + } + private final BodyXmlReader bodyReader; - private final String noteType; + private final String tagName; + private final NoteType noteType; - public NotesXmlReader(BodyXmlReader bodyReader, String noteType) { + private NotesXmlReader(BodyXmlReader bodyReader, String tagName, NoteType noteType) { this.bodyReader = bodyReader; + this.tagName = tagName; this.noteType = noteType; } public Result<List<Note>> readElement(XmlElement element) { - Iterable<XmlElement> elements = filter(element.findChildren("w:" + noteType), this::isNoteElement); + Iterable<XmlElement> elements = filter(element.findChildren("w:" + tagName), this::isNoteElement); return Result.concat(transform(elements, this::readNoteElement)); } @@ -37,6 +44,7 @@ public class NotesXmlReader { return bodyReader.readElements(element.children()) .toResult() .map(children -> new Note( + noteType, element.getAttribute("w:id"), children)); } |
