Search in sources :

Example 1 with BibleType

use of biblemulticonverter.schema.roundtripxml.BibleType in project BibleMultiConverter by schierlm.

the class RoundtripXML method createBible.

protected JAXBElement<BibleType> createBible(Bible sBible) throws Exception {
    ObjectFactory of = new ObjectFactory();
    JAXBElement<BibleType> dBible = of.createBible(of.createBibleType());
    dBible.getValue().setName(sBible.getName());
    int dictCounter = 0;
    for (Book sBook : sBible.getBooks()) {
        BibleType.Book dBook = of.createBibleTypeBook();
        dBook.setAbbr(sBook.getAbbr());
        if (sBook.getId().equals(BookID.DICTIONARY_ENTRY)) {
            dBook.setId(sBook.getId().getOsisID() + "-" + (++dictCounter));
        } else {
            dBook.setId(sBook.getId().getOsisID());
        }
        dBook.setShortName(sBook.getShortName());
        dBook.setLongName(sBook.getLongName());
        dBible.getValue().getBook().add(dBook);
        for (Chapter sChapter : sBook.getChapters()) {
            BibleType.Book.Chapter dChapter = of.createBibleTypeBookChapter();
            dBook.getChapter().add(dChapter);
            if (sChapter.getProlog() != null) {
                dChapter.setProlog(of.createBibleTypeBookChapterProlog());
                sChapter.getProlog().accept(new CreateContentVisitor(of, dChapter.getProlog().getContent()));
            }
            for (Verse sVerse : sChapter.getVerses()) {
                BibleType.Book.Chapter.Verse dVerse = of.createBibleTypeBookChapterVerse();
                dChapter.getVerse().add(dVerse);
                dVerse.setNumber(sVerse.getNumber());
                sVerse.accept(new CreateContentVisitor(of, dVerse.getContent()));
            }
        }
    }
    return dBible;
}
Also used : ObjectFactory(biblemulticonverter.schema.roundtripxml.ObjectFactory) Book(biblemulticonverter.data.Book) Chapter(biblemulticonverter.data.Chapter) BibleType(biblemulticonverter.schema.roundtripxml.BibleType) Verse(biblemulticonverter.data.Verse)

Example 2 with BibleType

use of biblemulticonverter.schema.roundtripxml.BibleType in project BibleMultiConverter by schierlm.

the class RoundtripXML method parseBible.

protected Bible parseBible(JAXBElement<BibleType> sBible) throws Exception {
    Bible dBible = new Bible(sBible.getValue().getName());
    for (BibleType.Book sBook : sBible.getValue().getBook()) {
        Book dBook = new Book(sBook.getAbbr(), BookID.fromOsisId(sBook.getId().replaceAll("-[0-9]+$", "")), sBook.getShortName(), sBook.getLongName());
        dBible.getBooks().add(dBook);
        for (BibleType.Book.Chapter sChapter : sBook.getChapter()) {
            Chapter dChapter = new Chapter();
            dBook.getChapters().add(dChapter);
            if (sChapter.getProlog() != null) {
                dChapter.setProlog(new FormattedText());
                parseContent(dChapter.getProlog().getAppendVisitor(), sChapter.getProlog().getContent());
                dChapter.getProlog().finished();
            }
            for (BibleType.Book.Chapter.Verse sVerse : sChapter.getVerse()) {
                Verse dVerse = new Verse(sVerse.getNumber());
                dChapter.getVerses().add(dVerse);
                parseContent(dVerse.getAppendVisitor(), sVerse.getContent());
                dVerse.finished();
            }
        }
    }
    return dBible;
}
Also used : Book(biblemulticonverter.data.Book) Bible(biblemulticonverter.data.Bible) Chapter(biblemulticonverter.data.Chapter) BibleType(biblemulticonverter.schema.roundtripxml.BibleType) FormattedText(biblemulticonverter.data.FormattedText) Verse(biblemulticonverter.data.Verse)

Example 3 with BibleType

use of biblemulticonverter.schema.roundtripxml.BibleType in project BibleMultiConverter by schierlm.

the class RoundtripXML method doExport.

@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
    File file = new File(exportArgs[0]);
    JAXBElement<BibleType> result = createBible(bible);
    JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
    Marshaller m = ctx.createMarshaller();
    m.setSchema(getSchema());
    m.marshal(result, file);
}
Also used : Marshaller(javax.xml.bind.Marshaller) JAXBContext(javax.xml.bind.JAXBContext) BibleType(biblemulticonverter.schema.roundtripxml.BibleType) File(java.io.File)

Aggregations

BibleType (biblemulticonverter.schema.roundtripxml.BibleType)3 Book (biblemulticonverter.data.Book)2 Chapter (biblemulticonverter.data.Chapter)2 Verse (biblemulticonverter.data.Verse)2 Bible (biblemulticonverter.data.Bible)1 FormattedText (biblemulticonverter.data.FormattedText)1 ObjectFactory (biblemulticonverter.schema.roundtripxml.ObjectFactory)1 File (java.io.File)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1