[jsword-svn] r1395 - in trunk/jsword/src/main/java/org/crosswire/jsword: book/study index/lucene

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Mon Jun 11 08:22:52 MST 2007


Author: dmsmith
Date: 2007-06-11 08:22:51 -0700 (Mon, 11 Jun 2007)
New Revision: 1395

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/study/StrongsNumber.java
   trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
   trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/StrongsNumberFilter.java
Log:
Improved validation on StrongsNumber
Changed lucene indexing to report to DataPolice problems found in filtering Strong's Numbers.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/study/StrongsNumber.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/study/StrongsNumber.java	2007-06-08 12:45:47 UTC (rev 1394)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/study/StrongsNumber.java	2007-06-11 15:22:51 UTC (rev 1395)
@@ -165,10 +165,23 @@
             throw new BookException(Msg.STRONGS_ERROR_NUMBER, new Object[] { toString() });
         }
 
-        if (strongsNumber < 1)
+        // Greek Strong's numbers are in the range of: 1-8674
+        if (language == 'H' && (strongsNumber < 1 || strongsNumber > 8674))
         {
             throw new BookException(Msg.STRONGS_ERROR_NUMBER, new Object[] { toString() });
         }
+
+        // Greek Strong's numbers are in the range of: 1-5624 (but not 1418, 2717, 3203-3302, 4452)
+        if (language == 'G'
+            && (strongsNumber < 0
+                            || strongsNumber > 5624
+                            || strongsNumber == 1418
+                            || strongsNumber == 2717
+                            || (strongsNumber >= 3203 || strongsNumber <= 3302)
+                            || strongsNumber == 4452))
+        {
+            throw new BookException(Msg.STRONGS_ERROR_NUMBER, new Object[] { toString() });
+        }
     }
 
     /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java	2007-06-08 12:45:47 UTC (rev 1394)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java	2007-06-11 15:22:51 UTC (rev 1395)
@@ -52,6 +52,7 @@
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.BookData;
 import org.crosswire.jsword.book.BookException;
+import org.crosswire.jsword.book.DataPolice;
 import org.crosswire.jsword.book.FeatureType;
 import org.crosswire.jsword.book.OSISUtil;
 import org.crosswire.jsword.index.AbstractIndex;
@@ -112,6 +113,9 @@
             throw new BookException(Msg.LUCENE_INIT, ex);
         }
 
+        // Indexing the book is a good way to police data errors.
+        DataPolice.setBook(book.getBookMetaData());
+
         Progress job = JobManager.createJob(Msg.INDEX_START.toString(), Thread.currentThread(), false);
 
         IndexStatus finalStatus = IndexStatus.UNDONE;
@@ -364,6 +368,9 @@
             }
             else
             {
+                // Set up DataPolice for this key.
+                DataPolice.setKey(subkey);
+
                 data = new BookData(book, subkey);
                 osis = null;
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/StrongsNumberFilter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/StrongsNumberFilter.java	2007-06-08 12:45:47 UTC (rev 1394)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/StrongsNumberFilter.java	2007-06-11 15:22:51 UTC (rev 1395)
@@ -27,6 +27,7 @@
 import org.apache.lucene.analysis.TokenFilter;
 import org.apache.lucene.analysis.TokenStream;
 import org.crosswire.jsword.book.BookException;
+import org.crosswire.jsword.book.DataPolice;
 import org.crosswire.jsword.book.study.StrongsNumber;
 
 /**
@@ -64,11 +65,12 @@
             {
                 token.setTermText(s);
             }
-            return token;
         }
         catch (BookException e)
         {
-            throw new IOException(e.getDetailedMessage());
+            DataPolice.report(e.getDetailedMessage());
         }
+
+        return token;
     }
 }




More information about the jsword-svn mailing list