Search in sources :

Example 1 with BibleBook

use of org.crosswire.jsword.versification.BibleBook in project BibleMultiConverter by schierlm.

the class SWORDVersification method doImport.

@Override
public void doImport(VersificationSet versifications, String... importArgs) throws Exception {
    org.crosswire.jsword.versification.Versification v11n_kjv = Versifications.instance().getVersification(SystemKJV.V11N_NAME);
    Map<BookID, BibleBook> reverseBookMapping = new EnumMap<>(BookID.class);
    for (Map.Entry<BibleBook, BookID> entry : BookMapping.MAPPING.entrySet()) {
        reverseBookMapping.put(entry.getValue(), entry.getKey());
    }
    for (String versificationName : SWORDVersificationDetector.ALL_V11N_NAMES) {
        System.out.println("--- " + versificationName + " ---");
        org.crosswire.jsword.versification.Versification v11n = Versifications.instance().getVersification(versificationName);
        LinkedHashMap<BookID, int[]> verseCounts = new LinkedHashMap<>();
        for (Iterator<BibleBook> it = v11n.getBookIterator(); it.hasNext(); ) {
            BibleBook bb = (BibleBook) it.next();
            int[] chapters = new int[v11n.getLastChapter(bb)];
            if (chapters.length == 0)
                continue;
            verseCounts.put(BookMapping.MAPPING.get(bb), chapters);
            for (int j = 1; j <= v11n.getLastChapter(bb); j++) {
                chapters[j - 1] = v11n.getLastVerse(bb, j);
            }
        }
        versifications.getVersifications().add(Versification.fromVerseCounts("SWORD_" + versificationName, null, null, verseCounts));
        if (!versificationName.equals(SystemKJV.V11N_NAME) && !missingMappings.contains(versificationName)) {
            buildMapping(versifications, SystemKJV.V11N_NAME, v11n_kjv, versificationName, v11n, reverseBookMapping);
            buildMapping(versifications, versificationName, v11n, SystemKJV.V11N_NAME, v11n_kjv, reverseBookMapping);
        }
    }
}
Also used : BibleBook(org.crosswire.jsword.versification.BibleBook) LinkedHashMap(java.util.LinkedHashMap) BookID(biblemulticonverter.data.BookID) EnumMap(java.util.EnumMap) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 2 with BibleBook

use of org.crosswire.jsword.versification.BibleBook in project BibleMultiConverter by schierlm.

the class SWORDVersificationDetector method loadSchemes.

@Override
protected VersificationScheme[] loadSchemes() throws IOException {
    // parse header
    VersificationScheme[] result = new VersificationScheme[ALL_V11N_NAMES.length];
    for (int i = 0; i < result.length; i++) {
        EnumMap<BookID, BitSet[]> coveredBooks = new EnumMap<BookID, BitSet[]>(BookID.class);
        Versification v11n = Versifications.instance().getVersification(ALL_V11N_NAMES[i]);
        for (Iterator<BibleBook> it = v11n.getBookIterator(); it.hasNext(); ) {
            BibleBook bb = (BibleBook) it.next();
            BitSet[] chapters = new BitSet[v11n.getLastChapter(bb)];
            coveredBooks.put(BookMapping.MAPPING.get(bb), chapters);
            for (int j = 1; j <= v11n.getLastChapter(bb); j++) {
                chapters[j - 1] = new BitSet();
                chapters[j - 1].set(1, v11n.getLastVerse(bb, j) + 1);
            }
        }
        result[i] = new VersificationScheme(ALL_V11N_NAMES[i], coveredBooks);
    }
    return result;
}
Also used : BibleBook(org.crosswire.jsword.versification.BibleBook) BookID(biblemulticonverter.data.BookID) BitSet(java.util.BitSet) Versification(org.crosswire.jsword.versification.Versification) EnumMap(java.util.EnumMap)

Aggregations

BookID (biblemulticonverter.data.BookID)2 EnumMap (java.util.EnumMap)2 BibleBook (org.crosswire.jsword.versification.BibleBook)2 BitSet (java.util.BitSet)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Versification (org.crosswire.jsword.versification.Versification)1