diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-14 14:27:47 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-14 14:27:47 +0000 |
| commit | a07cddd98e2fdad40d2226818b04be1787abc6cf (patch) | |
| tree | 7ebd1780ee00e35c82773c23d7e88a0c4ca19031 /src/main/java/org/zwobble/mammoth/docx/NotesXmlReader.java | |
| parent | b62ec02a9fe1379467342ad1001ccb99b4f21642 (diff) | |
Add notes to document
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)); } |
