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());
}
}
Aggregations