Search in sources :

Example 1 with Optbreak

use of biblemulticonverter.schema.usx3.Optbreak 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());
        }
    }
}
Also used : IOException(java.io.IOException) Optbreak(biblemulticonverter.schema.usx3.Optbreak) Figure(biblemulticonverter.schema.usx3.Figure) Ref(biblemulticonverter.schema.usx3.Ref) Char(biblemulticonverter.schema.usx3.Char) Note(biblemulticonverter.schema.usx3.Note) Verse(biblemulticonverter.schema.usx3.Verse)

Aggregations

Char (biblemulticonverter.schema.usx3.Char)1 Figure (biblemulticonverter.schema.usx3.Figure)1 Note (biblemulticonverter.schema.usx3.Note)1 Optbreak (biblemulticonverter.schema.usx3.Optbreak)1 Ref (biblemulticonverter.schema.usx3.Ref)1 Verse (biblemulticonverter.schema.usx3.Verse)1 IOException (java.io.IOException)1