/** * 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); } }
/** * Get and load a properties file from the writable area or if that fails from the classpath * (where a default ought to be stored) * * @param clazz The name of the desired resource * @return The found and loaded properties file * @throws IOException if the resource can not be loaded * @throws MissingResourceException if the resource can not be found */ public static Properties getProperties(Class clazz) throws IOException { return getProperties(clazz, ClassUtil.getShortClassName(clazz)); }