From 4a48895d643616a1bddd7cf6c71a25f8e0a87687 Mon Sep 17 00:00:00 2001 From: Paul Rambags Date: Mon, 14 Oct 2019 11:05:09 +0200 Subject: [PATCH] #106: Added @Deprecate annotations, removed unused ATTR_USE_TOC_TEXT_RESUMED, improved description in toc-text test files. --- .../resource-files/dp2/toc-text-expected.pef | 2 +- .../resource-files/dp2/toc-text-input.obfl | 2 +- .../formatter/impl/obfl/ObflParserImpl.java | 23 ++++++++++++++++--- .../dotify/formatter/impl/obfl/ObflQName.java | 1 - 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-expected.pef b/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-expected.pef index 4ebc251a..18ec3077 100644 --- a/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-expected.pef +++ b/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-expected.pef @@ -3,7 +3,7 @@ toc-text - Tests toc-text. + Tests toc-text with mixed content. application/x-pef+xml diff --git a/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-input.obfl b/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-input.obfl index 8e1fc0cb..5c3b6b61 100644 --- a/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-input.obfl +++ b/integrationtest/org/daisy/dotify/formatter/test/resource-files/dp2/toc-text-input.obfl @@ -2,7 +2,7 @@ toc-text - Tests toc-text. + Tests toc-text with mixed content. diff --git a/src/org/daisy/dotify/formatter/impl/obfl/ObflParserImpl.java b/src/org/daisy/dotify/formatter/impl/obfl/ObflParserImpl.java index 9370842a..a297c6a3 100644 --- a/src/org/daisy/dotify/formatter/impl/obfl/ObflParserImpl.java +++ b/src/org/daisy/dotify/formatter/impl/obfl/ObflParserImpl.java @@ -1193,13 +1193,12 @@ private void parseTocEntry(XMLEvent event, XMLEventIterator input, TableOfConten while (input.hasNext()) { event=input.nextEvent(); if (event.isCharacters()) { - // TODO: deprecated (#106) - remove in a future version - toc.addChars(event.asCharacters().getData(), tp); + tocEntryAddChars(toc, event, tp); } else if (equalsStart(event, ObflQName.TOC_TEXT)) { parseTocText(event, input, toc, tp); } else if (equalsStart(event, ObflQName.TOC_ENTRY)) { parseTocEntry(event, input, toc, tp); - } else if (processAsBlockContents(toc, event, input, tp)) { + } else if (tocEntryProcessAsBlockContents(toc, event, input, tp)) { // TODO: deprecated (#106) - remove this if clause in a future version //done! } @@ -1212,6 +1211,24 @@ else if (equalsEnd(event, ObflQName.TOC_ENTRY)) { } } + /** + * Adds characters from a toc-entry to the toc + * @deprecated the characters should be placed inside the toc-text element, see #106 + */ + @Deprecated + private void tocEntryAddChars(TableOfContents toc, XMLEvent event, TextProperties tp) { + toc.addChars(event.asCharacters().getData(), tp); + } + + /** + * Adds block contents from a toc-entry to the toc + * @deprecated the block contents should be placed inside the toc-text element, see #106 + */ + @Deprecated + private boolean tocEntryProcessAsBlockContents(TableOfContents toc, XMLEvent event, XMLEventIterator input, TextProperties tp) throws XMLStreamException { + return processAsBlockContents(toc, event, input, tp); + } + private void parseTocText(XMLEvent event, XMLEventIterator input, TableOfContents toc, TextProperties tp) throws XMLStreamException { tp = getTextProperties(event, tp); while (input.hasNext()) { diff --git a/src/org/daisy/dotify/formatter/impl/obfl/ObflQName.java b/src/org/daisy/dotify/formatter/impl/obfl/ObflQName.java index 02a66d5c..ac39dfaa 100644 --- a/src/org/daisy/dotify/formatter/impl/obfl/ObflQName.java +++ b/src/org/daisy/dotify/formatter/impl/obfl/ObflQName.java @@ -99,7 +99,6 @@ interface ObflQName { static final QName ATTR_COST = new QName("cost"); static final QName ATTR_URI = new QName("uri"); static final QName ATTR_VALUE = new QName("value"); - static final QName ATTR_USE_TOC_TEXT_RESUMED = new QName("use-toc-text-resumed"); static final QName TABLE = new QName(OBFL_NS, "table"); static final QName THEAD = new QName(OBFL_NS, "thead");