Search in sources :

Example 1 with PARAGRAPH

use of biblemulticonverter.schema.haggai.PARAGRAPH in project BibleMultiConverter by schierlm.

the class HaggaiXML method parseChapterObject.

private void parseChapterObject(Object e3, Chapter chapter, Map<BookID, String> abbrMap, List<Headline> headlineBuffer) throws IOException {
    if (e3 instanceof CAPTION) {
        CAPTION caption = (CAPTION) e3;
        Headline h = new Headline(9);
        if (parseContent(h.getAppendVisitor(), caption.getContent(), abbrMap)) {
            h.trimWhitespace();
            h.finished();
            headlineBuffer.add(h);
        }
    } else if (e3 instanceof REMARK) {
        REMARK remark = (REMARK) e3;
        Verse v = chapter.getVerses().get(chapter.getVerses().size() - 1);
        if (remark.getContent().size() != 1)
            return;
        String remarkText = normalize((String) remark.getContent().get(0), true).trim();
        v.getAppendVisitor().visitFootnote().visitText(remarkText);
    } else if (e3 instanceof PROLOG) {
        PROLOG prolog = (PROLOG) e3;
        if (chapter.getProlog() != null)
            return;
        FormattedText prologText = new FormattedText();
        if (parseContent(prologText.getAppendVisitor(), prolog.getContent(), abbrMap)) {
            prologText.trimWhitespace();
            prologText.finished();
            chapter.setProlog(prologText);
        }
    } else if (e3 instanceof PARAGRAPH) {
        PARAGRAPH para = (PARAGRAPH) e3;
        for (Object ee3 : para.getCAPTIONOrPROLOGOrREMARK()) {
            parseChapterObject(ee3, chapter, abbrMap, headlineBuffer);
        }
        chapter.getVerses().get(chapter.getVerses().size() - 1).getAppendVisitor().visitLineBreak(LineBreakKind.PARAGRAPH);
    } else if (e3 instanceof JAXBElement<?>) {
        JAXBElement<?> je = (JAXBElement<?>) e3;
        if (je.getName().getLocalPart().equals("VERSE") && je.getValue() instanceof VERSE) {
            VERSE vers = (VERSE) je.getValue();
            int vnumber = vers.getVnumber().intValue();
            if (vnumber == 0)
                vnumber = chapter.getVerses().size() + 1;
            String verseNumber = "" + vnumber;
            while (chapter.getVerseIndex(verseNumber) != -1) {
                String infix = "";
                for (char ch = 'a'; ch <= 'z'; ch++) {
                    if (chapter.getVerseIndex(vnumber + infix + ch) == -1) {
                        verseNumber = vnumber + infix + ch;
                        break;
                    }
                }
                infix += "-";
            }
            Verse verse = new Verse(verseNumber);
            Visitor<RuntimeException> visitor = verse.getAppendVisitor();
            boolean contentFound = false;
            if (headlineBuffer.size() > 0) {
                for (Headline h : headlineBuffer) {
                    h.accept(visitor.visitHeadline(h.getDepth()));
                }
                headlineBuffer.clear();
                contentFound = true;
            }
            contentFound |= parseContent(visitor, vers.getContent(), abbrMap);
            if (contentFound) {
                verse.trimWhitespace();
                chapter.getVerses().add(verse);
            }
        } else {
            throw new IOException(je.getName() + "/" + je.getDeclaredType());
        }
    } else {
        throw new IOException(e3.getClass().toString());
    }
}
Also used : PARAGRAPH(biblemulticonverter.schema.haggai.PARAGRAPH) VERSE(biblemulticonverter.schema.haggai.VERSE) FormattedText(biblemulticonverter.data.FormattedText) JAXBElement(javax.xml.bind.JAXBElement) IOException(java.io.IOException) Headline(biblemulticonverter.data.FormattedText.Headline) PROLOG(biblemulticonverter.schema.haggai.PROLOG) CAPTION(biblemulticonverter.schema.haggai.CAPTION) REMARK(biblemulticonverter.schema.haggai.REMARK) VirtualVerse(biblemulticonverter.data.VirtualVerse) Verse(biblemulticonverter.data.Verse)

Aggregations

FormattedText (biblemulticonverter.data.FormattedText)1 Headline (biblemulticonverter.data.FormattedText.Headline)1 Verse (biblemulticonverter.data.Verse)1 VirtualVerse (biblemulticonverter.data.VirtualVerse)1 CAPTION (biblemulticonverter.schema.haggai.CAPTION)1 PARAGRAPH (biblemulticonverter.schema.haggai.PARAGRAPH)1 PROLOG (biblemulticonverter.schema.haggai.PROLOG)1 REMARK (biblemulticonverter.schema.haggai.REMARK)1 VERSE (biblemulticonverter.schema.haggai.VERSE)1 IOException (java.io.IOException)1 JAXBElement (javax.xml.bind.JAXBElement)1