コード例 #1
0
ファイル: BibleNames.java プロジェクト: crosswire/jsword
    private void store(
        ResourceBundle resources, BibleBook book, Map fullMap, Map shortMap, Map altMap) {
      String osisName = book.getOSIS();

      String fullBook = getString(resources, osisName + FULL_KEY);

      String shortBook = getString(resources, osisName + SHORT_KEY);
      if (shortBook.length() == 0) {
        shortBook = fullBook;
      }

      String altBook = getString(resources, osisName + ALT_KEY);

      BookName bookName =
          new BookName(locale, BibleBook.fromOSIS(osisName), fullBook, shortBook, altBook);
      books.put(book, bookName);

      fullMap.put(bookName.getNormalizedLongName(), bookName);

      shortMap.put(bookName.getNormalizedShortName(), bookName);

      String[] alternates = StringUtil.split(BookName.normalize(altBook, locale), ',');

      for (int j = 0; j < alternates.length; j++) {
        altMap.put(alternates[j], bookName);
      }
    }
コード例 #2
0
ファイル: BibleNames.java プロジェクト: crosswire/jsword
    /**
     * Get a book from its name.
     *
     * @param find The string to identify
     * @param fuzzy Whether to also find bible books where only a substring matches
     * @return The BibleBook, On error null
     */
    BibleBook getBook(String find, boolean fuzzy) {
      String match = BookName.normalize(find, locale);

      BookName bookName = fullNT.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = shortNT.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = altNT.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = fullOT.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = shortOT.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = altOT.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = fullNC.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = shortNC.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      bookName = altNC.get(match);
      if (bookName != null) {
        return bookName.getBook();
      }

      if (!fuzzy) {
        return null;
      }

      for (BookName aBook : books.values()) {
        if (aBook.match(match)) {
          return aBook.getBook();
        }
      }

      return null;
    }