use of biblemulticonverter.schema.roundtripxml.FormattedTextType in project BibleMultiConverter by schierlm.
the class RoundtripXML method parseContent.
private void parseContent(Visitor<RuntimeException> visitor, List<Serializable> contentList) throws IOException {
for (Serializable content : contentList) {
if (content instanceof String) {
visitor.visitText((String) content);
} else if (content instanceof JAXBElement<?>) {
Object value = ((JAXBElement<?>) content).getValue();
Visitor<RuntimeException> next;
if (value instanceof FormattedTextType.Headline) {
next = visitor.visitHeadline(((FormattedTextType.Headline) value).getDepth());
} else if (value instanceof FormattedTextType.Footnote) {
next = visitor.visitFootnote();
} else if (value instanceof FormattedTextType.CrossReference) {
FormattedTextType.CrossReference xr = (FormattedTextType.CrossReference) value;
next = visitor.visitCrossReference(xr.getBookAbbr(), BookID.fromOsisId(xr.getBook()), xr.getFirstChapter(), xr.getFirstVerse(), xr.getLastChapter(), xr.getLastVerse());
} else if (value instanceof FormattedTextType.LineBreak) {
visitor.visitLineBreak(LineBreakKind.valueOf(((FormattedTextType.LineBreak) value).getKind().name()));
continue;
} else if (value instanceof FormattedTextType.DictionaryEntry) {
FormattedTextType.DictionaryEntry de = (FormattedTextType.DictionaryEntry) value;
next = visitor.visitDictionaryEntry(de.getDictionary(), de.getEntry());
} else if (value instanceof FormattedTextType.GrammarInformation) {
FormattedTextType.GrammarInformation gi = (FormattedTextType.GrammarInformation) value;
int[] strongs = null;
if (!gi.getStrongs().isEmpty()) {
strongs = new int[gi.getStrongs().size()];
for (int i = 0; i < strongs.length; i++) {
strongs[i] = gi.getStrongs().get(i);
}
}
String[] rmacs = null;
if (!gi.getRmac().isEmpty()) {
rmacs = (String[]) gi.getRmac().toArray(new String[gi.getRmac().size()]);
}
int[] sidxs = null;
if (!gi.getSourceIndices().isEmpty()) {
sidxs = new int[gi.getSourceIndices().size()];
for (int i = 0; i < sidxs.length; i++) {
sidxs[i] = gi.getSourceIndices().get(i);
}
}
next = visitor.visitGrammarInformation(strongs, rmacs, sidxs);
} else if (value instanceof FormattedTextType.FormattingInstruction) {
next = visitor.visitFormattingInstruction(FormattingInstructionKind.valueOf(((FormattedTextType.FormattingInstruction) value).getKind().name()));
} else if (value instanceof FormattedTextType.CssFormatting) {
next = visitor.visitCSSFormatting(((FormattedTextType.CssFormatting) value).getCss());
} else if (value instanceof FormattedTextType.ExtraAttribute) {
FormattedTextType.ExtraAttribute xa = (FormattedTextType.ExtraAttribute) value;
next = visitor.visitExtraAttribute(ExtraAttributePriority.valueOf(xa.getPrio().name()), xa.getCategory(), xa.getKey(), xa.getValue());
} else if (value instanceof FormattedTextType.Variation) {
List<String> vars = ((FormattedTextType.Variation) value).getVariations();
next = visitor.visitVariationText((String[]) vars.toArray(new String[vars.size()]));
} else if (value instanceof FormattedTextType.RawHTML) {
FormattedTextType.RawHTML rh = (FormattedTextType.RawHTML) value;
visitor.visitRawHTML(RawHTMLMode.valueOf(rh.getMode().name()), rh.getValue());
continue;
} else if (value instanceof FormattedTextType.VerseSeparator) {
visitor.visitVerseSeparator();
continue;
} else {
throw new IOException("Invalid JAXBElement value: " + value.getClass());
}
parseContent(next, ((FormattedTextType) value).getContent());
} else {
throw new IOException("Invalid content: " + content.getClass());
}
}
}
Aggregations