[jsword-svn] jsword/java/jsword/org/crosswire/jsword/passage s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Mon Feb 14 19:09:08 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage
In directory www.crosswire.org:/tmp/cvs-serv5767/java/jsword/org/crosswire/jsword/passage

Modified Files:
	BibleInfo.java BibleInfo.properties 
Log Message:
Refactored the installer to a new package.
Fixed a bug in the indexer to use OSIS names.
Fixed a bug in the English names.
Did some optimizing.

Index: BibleInfo.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/BibleInfo.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** BibleInfo.java	21 Sep 2004 17:46:23 -0000	1.24
--- BibleInfo.java	15 Feb 2005 02:09:06 -0000	1.25
***************
*** 1,5 ****
--- 1,7 ----
  package org.crosswire.jsword.passage;
  
+ import java.util.HashMap;
  import java.util.Locale;
+ import java.util.Map;
  import java.util.ResourceBundle;
  
***************
*** 59,67 ****
  
          shortBooks = new String[BOOKS_IN_BIBLE];
          shortBooksLower = new String[BOOKS_IN_BIBLE];
          shortBooksUpper = new String[BOOKS_IN_BIBLE];
  
-         alt_books = new String[BOOKS_IN_BIBLE][];
          altBooksLower = new String[BOOKS_IN_BIBLE][];
  
          sections = new String[SECTIONS_IN_BIBLE];
--- 61,70 ----
  
          shortBooks = new String[BOOKS_IN_BIBLE];
+         shortBooksMap = new HashMap(BOOKS_IN_BIBLE);
          shortBooksLower = new String[BOOKS_IN_BIBLE];
          shortBooksUpper = new String[BOOKS_IN_BIBLE];
  
          altBooksLower = new String[BOOKS_IN_BIBLE][];
+         altBooksMap = new HashMap(BOOKS_IN_BIBLE);
  
          sections = new String[SECTIONS_IN_BIBLE];
***************
*** 70,73 ****
--- 73,77 ----
  
          osisBooks = new String[BOOKS_IN_BIBLE];
+         osisMap   = new HashMap(BOOKS_IN_BIBLE);
  
          ResourceBundle resources = ResourceBundle.getBundle(BibleInfo.class.getName(), Locale.getDefault(), new CWClassLoader(BibleInfo.class));
***************
*** 75,78 ****
--- 79,83 ----
          for (int i = 0; i < BibleInfo.BOOKS_IN_BIBLE; i++)
          {
+             Integer bookNum = new Integer(i+1);
              String fullBook = getString(resources, FULL_KEY + (i + 1));
              fullBooks[i] = fullBook;
***************
*** 82,91 ****
              String shortBook = getString(resources, SHORT_KEY + (i + 1));
              shortBooks[i] = shortBook;
!             shortBooksLower[i] = shortBook.toLowerCase();
              shortBooksUpper[i] = shortBook.toUpperCase();
  
              String altBook = getString(resources, ALT_KEY + (i + 1));
!             alt_books[i] = StringUtil.split(altBook, ',');
!             altBooksLower[i] = StringUtil.split(altBook.toLowerCase(), ',');
          }
  
--- 87,103 ----
              String shortBook = getString(resources, SHORT_KEY + (i + 1));
              shortBooks[i] = shortBook;
!             String lower = shortBook.toLowerCase();
!             shortBooksMap.put(lower, bookNum);
!             shortBooksLower[i] = lower;
              shortBooksUpper[i] = shortBook.toUpperCase();
  
              String altBook = getString(resources, ALT_KEY + (i + 1));
!             String altBooks[] = StringUtil.split(altBook.toLowerCase(), ',');
!             altBooksLower[i] = altBooks;
! 
!             for (int j = 0; j < altBooks.length; j++)
!             {
!                 altBooksMap.put(altBooks[j].toLowerCase(), bookNum);
!             }
          }
  
***************
*** 104,107 ****
--- 116,120 ----
          {
              osisBooks[i] = getString(resources, OSIS_KEY + (i + 1));
+             osisMap.put(osisBooks[i], new Integer(i+1));
          }
      }
***************
*** 272,280 ****
              return -1;
          }
  
          String match = find.toLowerCase();
  
          // Does it match a long version of the book or a short version
!         for (int i = 0; i < fullBooks.length; i++)
          {
              if (fullBooksLower[i].startsWith(match))
--- 285,312 ----
              return -1;
          }
+         
+         // Favor OSIS names.
+         Integer bookNum = (Integer) osisMap.get(find);
+         if (bookNum != null)
+         {
+             return bookNum.intValue();
+         }
  
          String match = find.toLowerCase();
  
+         bookNum = (Integer) shortBooksMap.get(match);
+         if (bookNum != null)
+         {
+             return bookNum.intValue();
+         }
+ 
+         bookNum = (Integer) altBooksMap.get(match);
+         if (bookNum != null)
+         {
+             return bookNum.intValue();
+         }
+ 
          // Does it match a long version of the book or a short version
!         for (int i = 0; i < fullBooksLower.length; i++)
          {
              if (fullBooksLower[i].startsWith(match))
***************
*** 289,295 ****
  
          // Or does it match one of the alternative versions
!         for (int i = 0; i < alt_books.length; i++)
          {
!             for (int j = 0; j < alt_books[i].length; j++)
              {
                  if (match.startsWith(altBooksLower[i][j]))
--- 321,327 ----
  
          // Or does it match one of the alternative versions
!         for (int i = 0; i < altBooksLower.length; i++)
          {
!             for (int j = 0; j < altBooksLower[i].length; j++)
              {
                  if (match.startsWith(altBooksLower[i][j]))
***************
*** 311,343 ****
      public static final boolean isBookName(String find)
      {
!         String match = find.toLowerCase();
! 
!         if (!containsLetter(find))
!         {
!             return false;
!         }
! 
!         // This could be sped up with less of the toLowerCase()
!         for (int i = 0; i < fullBooks.length; i++)
!         {
!             if (fullBooksLower[i].startsWith(match))
!             {
!                 return true;
!             }
!             if (match.startsWith(shortBooksLower[i]))
!             {
!                 return true;
!             }
! 
!             for (int j = 0; j < alt_books[i].length; j++)
!             {
!                 if (match.startsWith(altBooksLower[i][j]))
!                 {
!                     return true;
!                 }
!             }
!         }
! 
!         return false;
      }
  
--- 343,347 ----
      public static final boolean isBookName(String find)
      {
!         return (getBookNumber(find) != -1);
      }
  
***************
*** 530,534 ****
              {
                  new Integer(chaptersInBook(book)),
!                 fullBooks[book - 1], new Integer(chapter),
              };
              throw new NoSuchVerseException(Msg.BOOKS_CHAPTER, params);
--- 534,538 ----
              {
                  new Integer(chaptersInBook(book)),
!                 getShortBookName(book - 1), new Integer(chapter),
              };
              throw new NoSuchVerseException(Msg.BOOKS_CHAPTER, params);
***************
*** 541,545 ****
              {
                  new Integer(versesInChapter(book, chapter)),
!                 fullBooks[book - 1],
                  new Integer(chapter),
                  new Integer(verse),
--- 545,549 ----
              {
                  new Integer(versesInChapter(book, chapter)),
!                 getShortBookName(book - 1),
                  new Integer(chapter),
                  new Integer(verse),
***************
*** 1007,1027 ****
      /** Standard shortened names for the book of the Bible, in lower case, generated at run time */
      private static String[] shortBooksLower;
  
      /** Standard shortened names for the book of the Bible, in upper case, generated at run time */
      private static String[] shortBooksUpper;
  
!     /** Alternative shortened names for the book of the Bible, in mixed case */
!     private static String[][] alt_books;
! 
!     /** Alternative shortened names for the book of the Bible, in lower case, generated at run time */
      private static String[][] altBooksLower;
  
!     /* Alternative shortened names for the book of the Bible, in upper case, generated at run time */
!     // Not needed as the lower version was only there to speed up searching.
!     // private static String[][] altBooksUpper;
  
      /** Standard OSIS names for the book of the Bible, in mixed case */
      private static String[] osisBooks;
  
      /** Standard names for the sections */
      private static String[] sections;
--- 1011,1033 ----
      /** Standard shortened names for the book of the Bible, in lower case, generated at run time */
      private static String[] shortBooksLower;
+     
+     /** Standard shortened names for the book of the Bible, in lower case, generated at runtime. */
+     private static Map shortBooksMap;
  
      /** Standard shortened names for the book of the Bible, in upper case, generated at run time */
      private static String[] shortBooksUpper;
  
!     /** Alternative shortened names for the book of the Bible, in lower case */
      private static String[][] altBooksLower;
  
!     /** Alternative shortened names for the book of the Bible, in lower case, generated at run time */
!     private static Map altBooksMap;
  
      /** Standard OSIS names for the book of the Bible, in mixed case */
      private static String[] osisBooks;
  
+     /** Standard OSIS names for the book of the Bible, in mixed case */
+     private static Map osisMap;
+ 
      /** Standard names for the sections */
      private static String[] sections;

Index: BibleInfo.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/BibleInfo.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BibleInfo.properties	14 Jun 2004 05:27:21 -0000	1.1
--- BibleInfo.properties	15 Feb 2005 02:09:06 -0000	1.2
***************
*** 89,93 ****
  BibleInfo.Short.30=Amo
  BibleInfo.Alt.30=
! BibleInfo.Full.31=Obdiah
  BibleInfo.Short.31=Obd
  BibleInfo.Alt.31=
--- 89,93 ----
  BibleInfo.Short.30=Amo
  BibleInfo.Alt.30=
! BibleInfo.Full.31=Obadiah
  BibleInfo.Short.31=Obd
  BibleInfo.Alt.31=



More information about the jsword-svn mailing list