Search in sources :

Example 61 with Book

use of biblemulticonverter.data.Book in project BibleMultiConverter by schierlm.

the class MyBibleZoneCrossreferences method doExport.

@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
    String outfile = exportArgs[0];
    if (!outfile.endsWith(".crossreferences.SQLite3"))
        outfile += ".crossreferences.SQLite3";
    new File(outfile).delete();
    SqlJetDb db = SqlJetDb.open(new File(outfile), true);
    db.getOptions().setAutovacuum(true);
    db.beginTransaction(SqlJetTransactionMode.WRITE);
    db.getOptions().setUserVersion(0);
    db.createTable("CREATE TABLE info (name TEXT, value TEXT)");
    db.createTable("CREATE TABLE cross_references (book NUMERIC, chapter NUMERIC, verse NUMERIC, verse_end NUMERIC, book_to NUMERIC, chapter_to NUMERIC, verse_to_start NUMERIC, verse_to_end NUMERIC, votes NUMERIC)");
    db.createIndex("CREATE INDEX book_and_chapter ON cross_references(book, chapter)");
    Map<String, String> infoValues = new LinkedHashMap<>();
    MetadataBook mb = bible.getMetadataBook();
    if (mb == null)
        mb = new MetadataBook();
    infoValues.put("language", "xx");
    infoValues.put("description", bible.getName());
    infoValues.put("detailed_info", "");
    infoValues.put("russian_numbering", "false");
    infoValues.put("requires_reverse_processing", "false");
    for (String mbkey : mb.getKeys()) {
        if (mbkey.startsWith("MyBible.zone@")) {
            infoValues.put(mbkey.substring(13).replace('.', '_'), mb.getValue(mbkey));
        } else {
            infoValues.put("detailed_info", infoValues.get("detailed_info") + "\r\n<br><b>" + mbkey + ":</b>" + mb.getValue(mbkey));
        }
    }
    if (exportArgs.length > 1) {
        Properties props = new Properties();
        FileInputStream in = new FileInputStream(exportArgs[1]);
        props.load(in);
        in.close();
        for (Object key : props.keySet()) {
            String template = props.getProperty(key.toString());
            template = template.replace("${name}", bible.getName());
            for (String mbkey : mb.getKeys()) template = template.replace("${" + mbkey + "}", mb.getValue(mbkey));
            infoValues.put(key.toString(), template);
        }
    }
    ISqlJetTable infoTable = db.getTable("info");
    ISqlJetTable crossReferencesTable = db.getTable("cross_references");
    for (Map.Entry<String, String> entry : infoValues.entrySet()) {
        infoTable.insert(entry.getKey(), entry.getValue());
    }
    for (Book bk : bible.getBooks()) {
        if (!MyBibleZone.BOOK_NUMBERS.containsKey(bk.getId()))
            continue;
        int bn = MyBibleZone.BOOK_NUMBERS.get(bk.getId());
        for (int cn = 1; cn <= bk.getChapters().size(); cn++) {
            Chapter ch = bk.getChapters().get(cn - 1);
            for (Verse v : ch.getVerses()) {
                int vn = numericVerse(v.getNumber());
                v.accept(new XrefVerseVisitor(new int[] { bn, cn, vn, 0 }, bible, crossReferencesTable));
            }
        }
    }
    db.commit();
    db.close();
}
Also used : MetadataBook(biblemulticonverter.data.MetadataBook) SqlJetDb(org.tmatesoft.sqljet.core.table.SqlJetDb) Chapter(biblemulticonverter.data.Chapter) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) LinkedHashMap(java.util.LinkedHashMap) MetadataBook(biblemulticonverter.data.MetadataBook) Book(biblemulticonverter.data.Book) ISqlJetTable(org.tmatesoft.sqljet.core.table.ISqlJetTable) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Verse(biblemulticonverter.data.Verse)

Example 62 with Book

use of biblemulticonverter.data.Book in project BibleMultiConverter by schierlm.

the class MyBibleZoneDictionary method doExport.

@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
    String outfile = exportArgs[0];
    String dictionaryName = exportArgs[1];
    if (!outfile.endsWith(".dictionary.SQLite3"))
        outfile += ".dictionary.SQLite3";
    new File(outfile).delete();
    SqlJetDb db = SqlJetDb.open(new File(outfile), true);
    db.getOptions().setAutovacuum(true);
    db.beginTransaction(SqlJetTransactionMode.WRITE);
    db.getOptions().setUserVersion(0);
    db.createTable("CREATE TABLE info (name TEXT, value TEXT)");
    db.createTable("CREATE TABLE dictionary (topic TEXT, definition TEXT)");
    db.createIndex("CREATE UNIQUE INDEX dictionary_topic ON dictionary(topic ASC)");
    Map<String, String> infoValues = new LinkedHashMap<>();
    MetadataBook mb = bible.getMetadataBook();
    if (mb == null)
        mb = new MetadataBook();
    infoValues.put("language", "xx");
    infoValues.put("description", bible.getName());
    infoValues.put("detailed_info", "");
    infoValues.put("russian_numbering", "false");
    infoValues.put("is_strong", dictionaryName.equals("strong") ? "true" : "false");
    infoValues.put("is_word_forms", "false");
    infoValues.put("morphology_topic_reference", "");
    for (String mbkey : mb.getKeys()) {
        if (mbkey.startsWith("MyBible.zone@")) {
            infoValues.put(mbkey.substring(13).replace('.', '_'), mb.getValue(mbkey));
        } else {
            infoValues.put("detailed_info", infoValues.get("detailed_info") + "\r\n<br><b>" + mbkey + ":</b>" + mb.getValue(mbkey));
        }
    }
    if (exportArgs.length > 2) {
        Properties props = new Properties();
        FileInputStream in = new FileInputStream(exportArgs[2]);
        props.load(in);
        in.close();
        for (Object key : props.keySet()) {
            String template = props.getProperty(key.toString());
            template = template.replace("${name}", bible.getName());
            for (String mbkey : mb.getKeys()) template = template.replace("${" + mbkey + "}", mb.getValue(mbkey));
            infoValues.put(key.toString(), template);
        }
    }
    ISqlJetTable infoTable = db.getTable("info");
    ISqlJetTable dictionaryTable = db.getTable("dictionary");
    for (Map.Entry<String, String> entry : infoValues.entrySet()) {
        infoTable.insert(entry.getKey(), entry.getValue());
    }
    Set<String> usedTopics = new HashSet<>();
    final Set<String> unsupportedFeatures = new HashSet<>();
    for (Book bk : bible.getBooks()) {
        if (bk.getId() != BookID.DICTIONARY_ENTRY) {
            System.out.println("WARNING: Skipping book " + bk.getAbbr());
            continue;
        }
        String topicName = bk.getShortName();
        if (usedTopics.contains(topicName) && !dictionaryName.equals("strong")) {
            for (int i = 2; ; i++) {
                if (!usedTopics.contains(topicName + " (" + i + ")")) {
                    topicName += " (" + i + ")";
                    break;
                }
            }
        }
        if (usedTopics.contains(topicName)) {
            System.out.println("WARNING: Skipping duplicate topic " + topicName);
            continue;
        }
        if (dictionaryName.equals("strong")) {
            if (!topicName.matches("[GH][1-9][0-9]*")) {
                System.out.println("WARNING: Skipping invalid Strong number " + topicName);
                continue;
            }
        } else if (!dictionaryName.equals("-")) {
            dictionaryTable.insert("[" + dictionaryName + "]" + bk.getAbbr(), "\u2197 <a href=\"S:" + topicName + "\">" + bk.getShortName() + "</a>");
        }
        MyBibleHTMLVisitor v = new MyBibleHTMLVisitor(unsupportedFeatures, "in dictionary entry");
        bk.getChapters().get(0).getProlog().accept(v);
        dictionaryTable.insert(topicName, v.getResult());
    }
    if (!unsupportedFeatures.isEmpty()) {
        System.out.println("WARNING: Skipped unsupported features: " + unsupportedFeatures);
    }
    db.commit();
    db.close();
}
Also used : MetadataBook(biblemulticonverter.data.MetadataBook) SqlJetDb(org.tmatesoft.sqljet.core.table.SqlJetDb) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) LinkedHashMap(java.util.LinkedHashMap) MetadataBook(biblemulticonverter.data.MetadataBook) Book(biblemulticonverter.data.Book) MyBibleHTMLVisitor(biblemulticonverter.sqlite.format.MyBibleZone.MyBibleHTMLVisitor) ISqlJetTable(org.tmatesoft.sqljet.core.table.ISqlJetTable) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 63 with Book

use of biblemulticonverter.data.Book in project BibleMultiConverter by schierlm.

the class AbstractParatextFormat method doImport.

@Override
public Bible doImport(File inputFile) throws Exception {
    List<ParatextBook> books = doImportBooks(inputFile);
    String bibleName = null;
    for (ParatextBook book : books) {
        if (bibleName == null || book.getBibleName().isEmpty()) {
            bibleName = book.getBibleName();
        } else {
            String bookBibleName = book.getBibleName();
            // use common suffix
            if (bookBibleName.length() > bibleName.length()) {
                bookBibleName = bookBibleName.substring(bookBibleName.length() - bibleName.length());
            } else if (bibleName.length() > bookBibleName.length()) {
                bibleName = bibleName.substring(bibleName.length() - bookBibleName.length());
            }
            for (int i = bibleName.length() - 1; i >= 0; i--) {
                if (bibleName.charAt(i) != bookBibleName.charAt(i)) {
                    bibleName = bibleName.substring(i + 1);
                    break;
                }
            }
        }
    }
    Bible bible = new Bible((bibleName == null || bibleName.isEmpty()) ? "Imported Bible" : bibleName);
    for (ParatextBook book : books) {
        String longName = book.getAttributes().get("toc1");
        if (longName == null || longName.isEmpty())
            longName = book.getId().getEnglishName();
        String shortName = book.getAttributes().get("toc2");
        if (shortName == null || shortName.isEmpty())
            shortName = longName;
        String abbr = book.getAttributes().get("toc3"), fallbackAbbr = book.getId().getId().getOsisID().replace("x-", "").replace("-", "");
        if (abbr == null)
            abbr = fallbackAbbr;
        abbr = abbr.replace(" ", "");
        if (!Utils.compilePattern(Utils.BOOK_ABBR_REGEX).matcher(abbr).matches()) {
            System.out.println("WARNING: Unsupported book abbreviation " + abbr + ", using " + fallbackAbbr + " instead");
            abbr = fallbackAbbr;
        }
        final Book bk = new Book(abbr, book.getId().getId(), shortName, longName);
        bible.getBooks().add(bk);
        final boolean forceProlog = book.getId().getId().getZefID() < 0;
        final ParatextImportContext ctx = new ParatextImportContext();
        ctx.nt = book.getId().getId().isNT();
        book.accept(new ParatextBookContentVisitor<RuntimeException>() {

            @Override
            public void visitChapterStart(int newChapter) throws RuntimeException {
                if (ctx.cnum != -1 && !ctx.headlines.isEmpty()) {
                    System.out.println("WARNING: Ignoring unreferenced headlines");
                    ctx.headlines.clear();
                }
                if (ctx.cnum == 0 && newChapter == 1) {
                    // we are in prolog (chapter already exists)
                    ctx.cnum = newChapter;
                } else if (newChapter >= 1 && newChapter > ctx.cnum) {
                    if (ctx.cnum == -1)
                        ctx.cnum = 0;
                    while (ctx.cnum < newChapter - 1) {
                        bk.getChapters().add(new Chapter());
                        ctx.cnum++;
                    }
                    ctx.currentChapter = new Chapter();
                    bk.getChapters().add(ctx.currentChapter);
                    ctx.cnum = newChapter;
                } else {
                    System.out.println("WARNING: Ignoring chapter number " + newChapter + ", current chapter is " + ctx.cnum);
                }
                ctx.currentVisitor = null;
                ctx.currentVerse = null;
                ctx.currentParagraph = ParatextImportContext.CurrentParagraph.NONE;
            }

            @Override
            public void visitParagraphStart(ParagraphKind kind) throws RuntimeException {
                if (ctx.currentParagraph != ParatextImportContext.CurrentParagraph.NONE) {
                    if (ctx.currentParagraph == ParatextImportContext.CurrentParagraph.PROLOG || (ctx.currentParagraph == ParatextImportContext.CurrentParagraph.NORMAL && ctx.currentVisitor != null)) {
                        ctx.currentVisitor.visitLineBreak(LineBreakKind.PARAGRAPH);
                    }
                    ctx.currentParagraph = ParatextImportContext.CurrentParagraph.NONE;
                }
                if (kind.getCategory() == ParagraphKindCategory.SKIP) {
                // do nothing
                } else if (kind.getCategory() == ParagraphKindCategory.HEADLINE) {
                    Headline hl = null;
                    if (kind.isJoinHeadlines() && !ctx.headlines.isEmpty()) {
                        hl = ctx.headlines.get(ctx.headlines.size() - 1);
                        if (hl.getDepth() == kind.getHeadlineDepth() || kind.getHeadlineDepth() == 0) {
                            hl.getAppendVisitor().visitText(" ");
                        } else {
                            hl = null;
                        }
                    }
                    if (hl == null) {
                        hl = new Headline(kind.getHeadlineDepth());
                        ctx.headlines.add(hl);
                    }
                    ctx.currentParagraph = ParatextImportContext.CurrentParagraph.HEADLINE;
                    ctx.currentVisitor = hl.getAppendVisitor();
                    if (kind.getExtraFormatting() != null) {
                        ctx.currentVisitor = ctx.currentVisitor.visitFormattingInstruction(kind.getExtraFormatting());
                    }
                } else {
                    // BLANK_LINE, TABLE_ROW, TEXT
                    if (kind.isProlog() || forceProlog) {
                        if (ctx.cnum == -1) {
                            ctx.cnum = 0;
                            ctx.currentChapter = new Chapter();
                            bk.getChapters().add(ctx.currentChapter);
                        }
                        if (ctx.currentChapter.getProlog() == null) {
                            ctx.currentChapter.setProlog(new FormattedText());
                        }
                        if (!ctx.currentChapter.getVerses().isEmpty()) {
                            System.out.println("WARNING: Adding to prolog after verses have been added!");
                        }
                        ctx.currentVisitor = ctx.currentChapter.getProlog().getAppendVisitor();
                        ctx.currentParagraph = ParatextImportContext.CurrentParagraph.PROLOG;
                        ctx.flushHeadlines();
                    } else {
                        ctx.currentParagraph = ParatextImportContext.CurrentParagraph.NORMAL;
                    }
                }
            }

            @Override
            public void visitTableCellStart(String tag) throws RuntimeException {
                ctx.ensureParagraph();
                if (!tag.matches("t[hc]r?1") && ctx.currentParagraph != ParatextImportContext.CurrentParagraph.HEADLINE && ctx.currentVisitor != null) {
                    ctx.currentVisitor.visitLineBreak(LineBreakKind.NEWLINE_WITH_INDENT);
                }
            }

            @Override
            public void visitParatextCharacterContent(ParatextCharacterContent content) throws RuntimeException {
                ctx.ensureParagraph();
                content.accept(new ParatextImportVisitor(ctx));
            }
        });
        if (!ctx.headlines.isEmpty()) {
            System.out.println("WARNING: Ignoring unreferenced headlines");
            ctx.headlines.clear();
        }
        for (Chapter ch : bk.getChapters()) {
            if (ch.getProlog() != null)
                ch.getProlog().finished();
            for (Verse v : ch.getVerses()) v.finished();
        }
    }
    return bible;
}
Also used : Bible(biblemulticonverter.data.Bible) Chapter(biblemulticonverter.data.Chapter) FormattedText(biblemulticonverter.data.FormattedText) Book(biblemulticonverter.data.Book) ParagraphKind(biblemulticonverter.format.paratext.ParatextBook.ParagraphKind) Headline(biblemulticonverter.data.FormattedText.Headline) Verse(biblemulticonverter.data.Verse)

Example 64 with Book

use of biblemulticonverter.data.Book in project BibleMultiConverter by schierlm.

the class AbstractVersificationDetector method doExport.

@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
    VersificationScheme[] schemes = loadSchemes();
    Set<String> totalVerses = new HashSet<String>();
    boolean includeXref = exportArgs.length > 0 && exportArgs[0].equals("-xref");
    XrefCountVisitor xcv = includeXref ? new XrefCountVisitor(schemes, totalVerses) : null;
    // fill missing verses
    for (Book book : bible.getBooks()) {
        for (int cc = 0; cc < book.getChapters().size(); cc++) {
            Chapter chapter = book.getChapters().get(cc);
            if (includeXref && chapter.getProlog() != null) {
                chapter.getProlog().accept(xcv);
            }
            if (useVerseRanges()) {
                for (VerseRange vr : chapter.createVerseRanges()) {
                    int cnumber = vr.getChapter() == 0 ? cc + 1 : vr.getChapter();
                    countVerse(schemes, totalVerses, book.getAbbr(), book.getId(), cnumber, vr.getMinVerse());
                    countVerse(schemes, totalVerses, book.getAbbr(), book.getId(), cnumber, vr.getMaxVerse());
                }
            } else {
                for (VirtualVerse v : chapter.createVirtualVerses()) {
                    countVerse(schemes, totalVerses, book.getAbbr(), book.getId(), cc + 1, v.getNumber());
                }
            }
            if (includeXref) {
                for (Verse vv : chapter.getVerses()) {
                    vv.accept(xcv);
                }
            }
        }
    }
    // sort them
    Arrays.sort(schemes);
    // print them
    System.out.print("Best match:  ");
    int totalVerseCount = totalVerses.size();
    printScheme(schemes[0], totalVerseCount);
    System.out.println();
    System.out.println("Other options:");
    for (int i = 1; i < Math.min(11, schemes.length); i++) {
        printScheme(schemes[i], totalVerseCount);
        if (schemes[i].missingChapters.size() > schemes[0].missingChapters.size() + 2 || schemes[i].missingVerses.size() > schemes[0].missingVerses.size() + 5)
            break;
    }
    // print selected schemes
    if (exportArgs.length > (includeXref ? 1 : 0)) {
        System.out.println();
        System.out.println("Selected schemes:");
        for (int i = includeXref ? 1 : 0; i < exportArgs.length; i++) {
            boolean found = false;
            for (VersificationScheme scheme : schemes) {
                if (scheme.getName().equals(exportArgs[i])) {
                    printScheme(scheme, totalVerseCount);
                    found = true;
                    break;
                }
            }
            if (!found)
                System.out.println(exportArgs[i] + " (Unknown scheme)");
        }
    }
}
Also used : VerseRange(biblemulticonverter.data.VerseRange) VirtualVerse(biblemulticonverter.data.VirtualVerse) Chapter(biblemulticonverter.data.Chapter) Book(biblemulticonverter.data.Book) VirtualVerse(biblemulticonverter.data.VirtualVerse) Verse(biblemulticonverter.data.Verse) HashSet(java.util.HashSet)

Example 65 with Book

use of biblemulticonverter.data.Book in project BibleMultiConverter by schierlm.

the class LogosHTML method doExport.

@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
    String versemap = exportArgs.length == 1 ? "Bible" : exportArgs[1];
    Properties bookDatatypeMap = null;
    VersificationScheme scheme;
    if (versemap.startsWith("author:")) {
        bookDatatypeMap = new Properties();
        try (InputStream in = new FileInputStream(versemap.substring(7))) {
            bookDatatypeMap.load(in);
        }
        versemap = null;
        scheme = new LogosVersificationDetector().loadScheme("Bible");
    } else {
        if (!versemap.matches("Bible[A-Z0-9]*")) {
            System.out.println("Invalid versification: " + versemap);
            return;
        }
        scheme = new LogosVersificationDetector().loadScheme(versemap);
        if (scheme == null) {
            System.out.println("Invalid versification: " + versemap);
            return;
        }
    }
    footnoteCounter = 0;
    grammarCounter = 0;
    String title = bible.getName();
    String verseSeparator = "<br />";
    lineSeparator = "<br />";
    boolean noChapterHeadings = false;
    if (exportArgs.length > 3 && exportArgs[3].equals("-inline")) {
        verseSeparator = " ";
        lineSeparator = "<br />&nbsp;&nbsp;&nbsp;&nbsp; ";
    } else if (exportArgs.length > 3 && exportArgs[3].equals("-nochapter")) {
        verseSeparator = " ";
        lineSeparator = "<br />&nbsp;&nbsp;&nbsp;&nbsp; ";
        noChapterHeadings = true;
    }
    try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(exportArgs[0])), StandardCharsets.UTF_8))) {
        bw.write("<html><head>\n" + "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n" + "<style>" + "body, h1, h2, h3, h4, h5, h6 { font-family: \"Times New Roman\";}\n" + "a { color: black; text-decoration: none;}\n" + "a.sdfootnotesym, a.sdendnotesym { font-style: italic;}\n" + "h1 {font-size: 24pt;}\n" + "h2 {font-size: 22pt;}\n" + "h3 {font-size: 20pt;}\n" + "h4 {font-size: 18pt;}\n" + "h5 {font-size: 16pt;}\n" + "h6 {font-size: 14pt;}\n" + "</style>\n" + "</head><body lang=\"de-DE\">\n");
        if (exportArgs.length > 2 && !exportArgs[2].equals("-")) {
            StringWriter sw = new StringWriter();
            try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(exportArgs[2]), StandardCharsets.UTF_8))) {
                char[] buffer = new char[4096];
                int len;
                while ((len = br.read(buffer)) != -1) sw.write(buffer, 0, len);
            }
            String template = sw.toString();
            template = template.replace("${name}", bible.getName());
            MetadataBook mb = bible.getMetadataBook();
            if (mb != null) {
                bible.getBooks().remove(0);
                for (String key : mb.getKeys()) template = template.replace("${" + key + "}", mb.getValue(key));
            }
            bw.write(template);
        } else {
            bw.write("<h1>" + title.replace("&", "&amp").replace("<", "&lt;").replace(">", "&gt;") + "</h1>\n");
        }
        StringWriter footnotes = new StringWriter();
        for (Book book : bible.getBooks()) {
            BitSet[] chapterVerses;
            String milestone;
            if (bookDatatypeMap != null) {
                milestone = bookDatatypeMap.getProperty(book.getId().getOsisID());
                chapterVerses = milestone == null ? null : ALL_CHAPTER_VERSES;
            } else {
                chapterVerses = scheme.getCoveredBooks().get(book.getId());
                String babbr = LOGOS_BOOKS.get(book.getId());
                milestone = babbr == null ? null : (versemap + ":" + babbr + " %c:%v");
            }
            if (milestone == null && book.getId().getZefID() < 0 && book.getChapters().size() == 1) {
                Chapter chapter = book.getChapters().get(0);
                if (chapter.getVerses().size() == 0 && chapter.getProlog() != null) {
                    // prolog only book
                    bw.write("<h2>");
                    if (book.getId() == BookID.DICTIONARY_ENTRY) {
                        if (bible.getName().toUpperCase().contains("STRONG") && book.getShortName().matches("[GH][1-9][0-9]*")) {
                            bw.write("[[@" + (book.getShortName().startsWith("G") ? "Greek" : "Hebrew") + "Strongs:" + book.getShortName() + "]]");
                        } else {
                            bw.write("[[@Headword:" + book.getAbbr() + "]]");
                            if (!book.getAbbr().equals(book.getShortName())) {
                                bw.write("[[@Headword:" + book.getShortName() + "]]");
                            }
                            if (!book.getLongName().equals(book.getShortName())) {
                                bw.write("[[@Headword:" + book.getLongName() + "]]");
                            }
                        }
                    }
                    bw.write(book.getLongName() + "</h2>\n");
                    footnoteNumber = 0;
                    chapter.getProlog().accept(new LogosVisitor(bw, "", footnotes, false, versemap, scheme, null, null, null, 2));
                    bw.write("\n<br/>\n");
                    continue;
                }
            }
            if (milestone == null) {
                System.out.println("WARNING: Skipping book " + book.getId());
                continue;
            }
            bw.write("<h2>[[@" + formatMilestone(milestone, "", "") + "]]" + book.getLongName() + " (" + book.getAbbr() + ")</h2>\n");
            int cnumber = 0;
            for (Chapter chapter : book.getChapters()) {
                cnumber++;
                if (!chapter.getVerses().isEmpty() && chapter.getVerses().get(0).getNumber().endsWith(".p")) {
                    Chapter prologue = new Chapter();
                    BitSet prologueVerses = new BitSet(100);
                    prologueVerses.set(1, 100);
                    while (!chapter.getVerses().isEmpty() && chapter.getVerses().get(0).getNumber().endsWith(".p")) {
                        Verse v = chapter.getVerses().remove(0);
                        Verse vv = new Verse(v.getNumber().replace(".p", ""));
                        v.accept(vv.getAppendVisitor());
                        vv.finished();
                        prologue.getVerses().add(vv);
                    }
                    exportChapter(milestone, "Prologue", prologue, versemap, scheme, verseSeparator, noChapterHeadings, bw, footnotes, book, chapterVerses, prologueVerses);
                }
                BitSet thisChapterVerses = chapterVerses != null && cnumber <= chapterVerses.length ? chapterVerses[cnumber - 1] : null;
                exportChapter(milestone, "" + cnumber, chapter, versemap, scheme, verseSeparator, noChapterHeadings, bw, footnotes, book, chapterVerses, thisChapterVerses);
            }
        }
        bw.write(footnotes.toString());
        bw.write("</body></html>");
    }
}
Also used : MetadataBook(biblemulticonverter.data.MetadataBook) InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BitSet(java.util.BitSet) Chapter(biblemulticonverter.data.Chapter) VersificationScheme(biblemulticonverter.tools.AbstractVersificationDetector.VersificationScheme) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) LogosVersificationDetector(biblemulticonverter.logos.tools.LogosVersificationDetector) BufferedWriter(java.io.BufferedWriter) StringWriter(java.io.StringWriter) MetadataBook(biblemulticonverter.data.MetadataBook) Book(biblemulticonverter.data.Book) FileOutputStream(java.io.FileOutputStream) BufferedReader(java.io.BufferedReader) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) Verse(biblemulticonverter.data.Verse)

Aggregations

Book (biblemulticonverter.data.Book)67 Chapter (biblemulticonverter.data.Chapter)60 Verse (biblemulticonverter.data.Verse)57 FormattedText (biblemulticonverter.data.FormattedText)27 MetadataBook (biblemulticonverter.data.MetadataBook)25 VirtualVerse (biblemulticonverter.data.VirtualVerse)24 BookID (biblemulticonverter.data.BookID)22 ArrayList (java.util.ArrayList)22 File (java.io.File)20 Bible (biblemulticonverter.data.Bible)19 Headline (biblemulticonverter.data.FormattedText.Headline)18 BufferedWriter (java.io.BufferedWriter)16 FileOutputStream (java.io.FileOutputStream)15 IOException (java.io.IOException)14 OutputStreamWriter (java.io.OutputStreamWriter)13 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)10 Visitor (biblemulticonverter.data.FormattedText.Visitor)9 FileInputStream (java.io.FileInputStream)9 EnumMap (java.util.EnumMap)9