use of biblemulticonverter.schema.usx3.Figure in project BibleMultiConverter by schierlm.
the class USX3 method parseCharContent.
private void parseCharContent(List<Object> content, ParatextBook.ParatextCharacterContentContainer container) throws IOException {
for (Object o : content) {
if (o instanceof Optbreak) {
// is ignored in USFM as well
System.out.println("WARNING: Skipping optional break");
} else if (o instanceof Ref) {
Ref r = (Ref) o;
try {
container.getContent().add(ParatextCharacterContent.Reference.parse(r.getLoc(), r.getContent()));
} catch (IllegalArgumentException e) {
String location = unmarshallerLocationListener.getHumanReadableLocation(o);
System.out.println("WARNING: Unsupported structured reference format at " + location + " - replaced by plain text: " + r.getLoc());
final ParatextCharacterContent.Text text = ParatextCharacterContent.Text.from(r.getContent());
if (text != null) {
container.getContent().add(text);
}
}
} else if (o instanceof String) {
final ParatextCharacterContent.Text text = ParatextCharacterContent.Text.from((String) o);
if (text != null) {
container.getContent().add(text);
}
} else if (o instanceof Figure) {
System.out.println("WARNING: Skipping figure");
} else if (o instanceof Char) {
Char chr = (Char) o;
if (CHAR_STYLE_UNSUPPORTED.contains(chr.getStyle())) {
parseCharContent(chr.getContent(), container);
} else {
ParatextCharacterContent.AutoClosingFormatting f = new ParatextCharacterContent.AutoClosingFormatting(CHAR_STYLE_MAP.get(chr.getStyle()), false);
String lemma = chr.getLemma();
if (f.getKind() == ParatextCharacterContent.AutoClosingFormattingKind.WORDLIST && lemma != null && !lemma.isEmpty()) {
f.getAttributes().put("lemma", lemma);
}
container.getContent().add(f);
parseCharContent(chr.getContent(), f);
}
} else if (o instanceof Verse) {
container.getContent().add(handleVerse((Verse) o));
} else if (o instanceof Note) {
Note note = (Note) o;
ParatextCharacterContent.FootnoteXref nx = new ParatextCharacterContent.FootnoteXref(NOTE_STYLE_MAP.get(note.getStyle()), note.getCaller());
container.getContent().add(nx);
parseCharContent(note.getContent(), nx);
} else {
throw new IOException("Unsupported character content element: " + o.getClass().getName());
}
}
}
Aggregations