Example #1
0
    /**
     * Load up the resources for Bible book and section names, and cache the upper and lower
     * versions of them.
     */
    private void initialize() {
      int ntCount = 0;
      int otCount = 0;
      int ncCount = 0;
      BibleBook[] bibleBooks = BibleBook.values();
      for (BibleBook book : bibleBooks) {
        int ordinal = book.ordinal();
        if (ordinal > BibleBook.INTRO_OT.ordinal() && ordinal < BibleBook.INTRO_NT.ordinal()) {
          ++ntCount;
        } else if (ordinal > BibleBook.INTRO_NT.ordinal() && ordinal <= BibleBook.REV.ordinal()) {
          ++otCount;
        } else {
          ++ncCount;
        }
      }

      // Create the book name maps
      books = new LinkedHashMap<BibleBook, BookName>(ntCount + otCount + ncCount);

      String className = BibleNames.class.getName();
      String shortClassName = ClassUtil.getShortClassName(className);
      ResourceBundle resources =
          ResourceBundle.getBundle(
              shortClassName, locale, CWClassLoader.instance(BibleNames.class));

      fullNT = new HashMap<String, BookName>(ntCount);
      shortNT = new HashMap<String, BookName>(ntCount);
      altNT = new HashMap<String, BookName>(ntCount);
      for (int i = BibleBook.MATT.ordinal(); i <= BibleBook.REV.ordinal(); ++i) {
        BibleBook book = bibleBooks[i];
        store(resources, book, fullNT, shortNT, altNT);
      }

      fullOT = new HashMap<String, BookName>(otCount);
      shortOT = new HashMap<String, BookName>(otCount);
      altOT = new HashMap<String, BookName>(otCount);
      for (int i = BibleBook.GEN.ordinal(); i <= BibleBook.MAL.ordinal(); ++i) {
        BibleBook book = bibleBooks[i];
        store(resources, book, fullOT, shortOT, altOT);
      }

      fullNC = new HashMap<String, BookName>(ncCount);
      shortNC = new HashMap<String, BookName>(ncCount);
      altNC = new HashMap<String, BookName>(ncCount);
      store(resources, BibleBook.INTRO_BIBLE, fullNC, shortNC, altNC);
      store(resources, BibleBook.INTRO_OT, fullNC, shortNC, altNC);
      store(resources, BibleBook.INTRO_NT, fullNC, shortNC, altNC);
      for (int i = BibleBook.REV.ordinal() + 1; i < bibleBooks.length; ++i) {
        BibleBook book = bibleBooks[i];
        store(resources, book, fullNC, shortNC, altNC);
      }
    }