use of biblemulticonverter.schema.roundtripxml.ObjectFactory 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;
}
Aggregations