[jsword-svn] r1169 - in trunk/jsword/src/main/java/org/crosswire/jsword: book book/basic book/install book/readings book/sword examples index index/lucene passage util

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Thu Oct 19 14:49:11 MST 2006


Author: dmsmith
Date: 2006-10-19 14:48:21 -0700 (Thu, 19 Oct 2006)
New Revision: 1169

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
   trunk/jsword/src/main/java/org/crosswire/jsword/examples/BibleToOsis.java
   trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java
   trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java
   trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneQueryBuilder.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/KeyUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
   trunk/jsword/src/main/java/org/crosswire/jsword/util/ConverterFactory.java
Log:
cleanup of issues identified by pmd

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -184,7 +184,7 @@
      * 
      * @return the unlock key, if any, null otherwise.
      */
-    public String getUnlockKey();
+    String getUnlockKey();
 
     /**
      * Indicate whether this book is questionable. A book may
@@ -268,5 +268,4 @@
      * @param li the <code>IndexStatusListener</code> to be removed
      */
     void removeIndexStatusListener(IndexStatusListener li);
-
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -109,24 +109,6 @@
         return this.name.compareTo(that.name);
     }
 
-    /**
-     * Prevent subclasses from overriding canonical identity based Object methods
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals(Object o)
-    {
-        return super.equals(o);
-    }
-
-    /**
-     * Prevent subclasses from overriding canonical identity based Object methods
-     * @see java.lang.Object#hashCode()
-     */
-    public int hashCode()
-    {
-        return super.hashCode();
-    }
-
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -142,7 +142,7 @@
      * 
      * @return the unlock key, if any, null otherwise.
      */
-    public String getUnlockKey();
+    String getUnlockKey();
 
     /**
      * Indicate whether this book is questionable. A book may

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -110,7 +110,7 @@
     /* (non-Javadoc)
      * @see java.util.Collection#add(java.lang.Object)
      */
-    public boolean add(Object book)
+    public final boolean add(Object book)
     {
         // Add the item only if it is not in the list.
         // Add it into the list so that it is in sorted order.
@@ -126,7 +126,7 @@
     /* (non-Javadoc)
      * @see java.util.Collection#addAll(java.util.Collection)
      */
-    public boolean addAll(Collection c)
+    public final boolean addAll(Collection c)
     {
         // Might be better to add the list to the end
         // and then sort the list.
@@ -147,7 +147,7 @@
     /* (non-Javadoc)
      * @see java.util.List#addAll(int, java.util.Collection)
      */
-    public boolean addAll(int index, Collection c)
+    public final boolean addAll(int index, Collection c)
     {
         // Ignore the index
         return addAll(c);

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -58,12 +58,12 @@
             }
 
             // So there is a "-", however first some exceptions
-            if (word.equalsIgnoreCase("maher-shalal-hash-baz")) //$NON-NLS-1$
+            if ("maher-shalal-hash-baz".equalsIgnoreCase(word)) //$NON-NLS-1$
             {
                 return "Maher-Shalal-Hash-Baz"; //$NON-NLS-1$
             }
 
-            if (word.equalsIgnoreCase("no-one")) //$NON-NLS-1$
+            if ("no-one".equalsIgnoreCase(word)) //$NON-NLS-1$
             {
                 return "No-one"; //$NON-NLS-1$
             }
@@ -116,7 +116,7 @@
     {
         assert word != null;
 
-        if (word.equals("")) //$NON-NLS-1$
+        if (word.length() == 0)
         {
             return ""; //$NON-NLS-1$
         }
@@ -142,7 +142,7 @@
         assert word != null;
 
         // Blank word
-        if (word.equals("")) //$NON-NLS-1$
+        if (word.length() == 0)
         {
             return LOWER;
         }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -97,24 +97,6 @@
         return VALUES[i];
     }
 
-    /**
-     * Prevent subclasses from overriding canonical identity based Object methods
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals(Object o)
-    {
-        return super.equals(o);
-    }
-
-    /**
-     * Prevent subclasses from overriding canonical identity based Object methods
-     * @see java.lang.Object#hashCode()
-     */
-    public int hashCode()
-    {
-        return super.hashCode();
-    }
-
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -676,7 +676,7 @@
         }
         // So we just walk up the tree trying to find a verse
         Parent parent = ele.getParent();
-        if (parent != null && parent instanceof Element)
+        if (parent instanceof Element)
         {
             return getVerse((Element) parent);
         }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -66,7 +66,7 @@
         while (alive)
         {
             // Find the next space and double dash
-            int nextSpace = sentence.indexOf(" ", pos); //$NON-NLS-1$
+            int nextSpace = sentence.indexOf(' ', pos);
             int nextDDash = sentence.indexOf("--", pos); //$NON-NLS-1$
 
             // If there is a space just after the ddash then ignore the ddash

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -106,7 +106,7 @@
 
         if (getDriver() != null)
         {
-            buf.append(" (").append(getDriverName()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
+            buf.append(" (").append(getDriverName()).append(')'); //$NON-NLS-1$
         }
 
         return buf.toString();
@@ -194,7 +194,7 @@
      */
     public void setLibrary(URL library)
     {
-        putProperty(KEY_LIBRARY_URL, library.toExternalForm());        
+        putProperty(KEY_LIBRARY_URL, library.toExternalForm());
     }
 
     /* (non-Javadoc)
@@ -202,7 +202,7 @@
      */
     public void setLocation(URL location)
     {
-        putProperty(KEY_LOCATION_URL, location.toExternalForm());        
+        putProperty(KEY_LOCATION_URL, location.toExternalForm());
     }
 
     /* (non-Javadoc)

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -101,8 +101,7 @@
                 }
             }
 
-            BookData bdata = new BookData(osis, this, key);
-            return bdata;
+            return new BookData(osis, this, key);
         }
         catch (FilterException ex)
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -47,7 +47,7 @@
  *      The copyright to this program is held by it's authors.
  * @author Joe Walker [joe at eireneh dot com]
  */
-public class DefaultBookMetaData extends AbstractBookMetaData
+public final class DefaultBookMetaData extends AbstractBookMetaData
 {
     /**
      * Ctor with a properties from which to get values.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -47,7 +47,7 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class InstallManager
+public final class InstallManager
 {
     /**
      * Simple ctor

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -69,6 +69,8 @@
     {
         super(null); // set the book metadata later
 
+        hash = new TreeMap();
+
         String setname = ReadingsBookDriver.getReadingsSet();
 
         Locale defaultLocale = Locale.getDefault();
@@ -176,8 +178,7 @@
                 div.addContent(Msg.DECODE_ERROR.toString(readings));
             }
 
-            BookData bdata = new BookData(osis, this, key);
-            return bdata;
+            return new BookData(osis, this, key);
         }
         catch (NoSuchKeyException ex)
         {
@@ -190,8 +191,7 @@
      */
     public String getRawData(Key key) throws BookException
     {
-        StringBuffer buffer = new StringBuffer();
-        return buffer.toString();
+        return ""; //$NON-NLS-1$
     }
 
     /* (non-Javadoc)
@@ -249,7 +249,7 @@
     /**
      * The store of keys and data
      */
-    private Map hash = new TreeMap();
+    private Map hash;
 
     /**
      * The log stream

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -57,7 +57,9 @@
      */
     public Book[] getBooks()
     {
-        return books;
+        Book[] copy = new Book[books.length];
+        System.arraycopy(books, 0, copy, 0, books.length);
+        return copy;
     }
 
     /* (non-Javadoc)

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -336,9 +336,7 @@
      */
     public Book createBook(SwordBookMetaData sbmd) throws BookException
     {
-        AbstractBackend backend = getBackend(sbmd);
-        Book book = getBook(sbmd, backend);
-        return book;
+        return getBook(sbmd, getBackend(sbmd));
     }
 
     /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -40,7 +40,7 @@
  * @see gnu.lgpl.License
  * @author DM Smith [ dmsmith555 at yahoo dot com]
  */
-public class ConfigEntry
+public final class ConfigEntry
 {
 
     /**
@@ -233,7 +233,7 @@
             }
             if (!isAllowed(aValue))
             {
-                log.info("Ignoring unknown config value for " + confEntryName + " in " + internal + ": " + aValue); //$NON-NLS-1$ //$NON-NLS-2$  //$NON-NLS-3$
+                log.info(report("Ignoring unknown config value for", confEntryName, aValue)); //$NON-NLS-1$
                 return;
             }
             values.add(aValue);
@@ -242,7 +242,7 @@
         {
             if (value != null)
             {
-                log.info("Ignoring unexpected additional entry for " + confEntryName + " in " + internal + ": " + aValue); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                log.info(report("Ignoring unexpected additional entry for", confEntryName, aValue)); //$NON-NLS-1$
             }
             else
             {
@@ -253,7 +253,7 @@
                 }
                 if (!isAllowed(aValue))
                 {
-                    log.info("Ignoring unknown config value for " + confEntryName + " in " + internal + ": " + aValue); //$NON-NLS-1$ //$NON-NLS-2$  //$NON-NLS-3$
+                    log.info(report("Ignoring unknown config value for", confEntryName, aValue)); //$NON-NLS-1$
                     return;
                 }
                 value = aValue;
@@ -473,7 +473,7 @@
         {
             if (!copy.equals(aValue))
             {
-                log.info("Ignoring unexpected RTF for " + getName() + " in " + internal + ": " + aValue); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                log.info(report("Ignoring unexpected RTF for", getName(), aValue)); //$NON-NLS-1$
             }
             return aValue;
         }
@@ -494,6 +494,20 @@
         return list;
     }
 
+    private String report(String issue, String confEntryName, String aValue)
+    {
+        StringBuffer buf = new StringBuffer(100);
+        buf.append(issue);
+        buf.append(' ');
+        buf.append(confEntryName);
+        buf.append(" in "); //$NON-NLS-1$
+        buf.append(internal);
+        buf.append(": "); //$NON-NLS-1$
+        buf.append(aValue);
+
+        return buf.toString();
+    }
+
     /**
      * The log stream
      */

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -62,7 +62,7 @@
  * @author Jacky Cheung
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class ConfigEntryTable
+public final class ConfigEntryTable
 {
     /**
      * Create an empty Sword config for the named book.
@@ -209,11 +209,12 @@
      */
     public boolean unlock(String unlockKey)
     {
-        if (unlockKey != null)
+        String tmpKey = unlockKey;
+        if (tmpKey != null)
         {
-            unlockKey = unlockKey.trim();
+            tmpKey = tmpKey.trim();
         }
-        add(ConfigEntryType.CIPHER_KEY, unlockKey);
+        add(ConfigEntryType.CIPHER_KEY, tmpKey);
         if (configFile != null)
         {
             try
@@ -310,8 +311,7 @@
         StringBuffer buf = new StringBuffer();
         buf.append('[');
         buf.append(getValue(ConfigEntryType.INITIALS));
-        buf.append(']');
-        buf.append('\n');
+        buf.append("]\n"); //$NON-NLS-1$
         toConf(buf, BASIC_INFO);
         toConf(buf, SYSTEM_INFO);
         toConf(buf, HIDDEN);
@@ -367,7 +367,7 @@
                 continue;
             }
 
-            int eqpos = line.indexOf("="); //$NON-NLS-1$
+            int eqpos = line.indexOf('=');
             if (eqpos == -1)
             {
                 log.warn("Expected to see '=' in " + internal + ": " + line); //$NON-NLS-1$ //$NON-NLS-2$
@@ -475,7 +475,7 @@
             {
                 if (continuation_expected)
                 {
-                    log.warn("Continuation followed by key for " + configEntry.getName() + " in " + internal + ": " + line); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    log.warn(report("Continuation followed by key for", configEntry.getName(), line)); //$NON-NLS-1$
                 }
 
                 backup(line);
@@ -483,12 +483,12 @@
             }
             else if (!continuation_expected)
             {
-                log.warn("Line without previous continuation for " + configEntry.getName()  + " in " + internal + ": " + line); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                log.warn(report("Line without previous continuation for", configEntry.getName(), line)); //$NON-NLS-1$
             }
 
             if (!configEntry.allowsContinuation())
             {
-                log.warn("Ignoring unexpected additional line for " + configEntry.getName()  + " in " + internal + ": " + line); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                log.warn(report("Ignoring unexpected additional line for", configEntry.getName(), line)); //$NON-NLS-1$
             }
             else
             {
@@ -609,7 +609,7 @@
 
             if (langFromEntry == null)
             {
-                log.warn("Missing data for " + internal + ". Assuming " + ConfigEntryType.GLOSSARY_FROM.getName() + "=" + AbstractBookMetaData.DEFAULT_LANG_CODE);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                log.warn("Missing data for " + internal + ". Assuming " + ConfigEntryType.GLOSSARY_FROM.getName() + '=' + AbstractBookMetaData.DEFAULT_LANG_CODE);  //$NON-NLS-1$ //$NON-NLS-2$
             }
             else
             {
@@ -618,7 +618,7 @@
 
             if (langToEntry == null)
             {
-                log.warn("Missing data for " + internal + ". Assuming " + ConfigEntryType.GLOSSARY_TO.getName() + "=" + AbstractBookMetaData.DEFAULT_LANG_CODE);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                log.warn("Missing data for " + internal + ". Assuming " + ConfigEntryType.GLOSSARY_TO.getName() + '=' + AbstractBookMetaData.DEFAULT_LANG_CODE);  //$NON-NLS-1$ //$NON-NLS-2$
             }
             else
             {
@@ -797,7 +797,21 @@
             }
         }
     }
+    private String report(String issue, String confEntryName, String line)
+    {
+        StringBuffer buf = new StringBuffer(100);
+        buf.append(issue);
+        buf.append(' ');
+        buf.append(confEntryName);
+        buf.append(" in "); //$NON-NLS-1$
+        buf.append(internal);
+        buf.append(": "); //$NON-NLS-1$
+        buf.append(line);
 
+        return buf.toString();
+    }
+
+
    /**
      * Sword only recognizes two encodings for its modules: UTF-8 and LATIN1
      * Sword uses MS Windows cp1252 for Latin 1 not the standard. Arrgh!

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -131,27 +131,41 @@
      */
     public final void activate(Lock lock)
     {
-        try
+        if (idxFile[SwordConstants.TESTAMENT_OLD].canRead())
         {
-            idxRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
-            textRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(textFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
-            compRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(compFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
+            try
+            {
+                idxRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
+                textRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(textFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
+                compRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(compFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
+            }
+            catch (FileNotFoundException ex)
+            {
+                assert false : ex;
+                log.error("Could not open OT", ex); //$NON-NLS-1$
+                idxRaf[SwordConstants.TESTAMENT_OLD] = null;
+                textRaf[SwordConstants.TESTAMENT_OLD] = null;
+                compRaf[SwordConstants.TESTAMENT_OLD] = null;
+            }
         }
-        catch (FileNotFoundException ex)
-        {
-            // Ignore this might be NT only
-        }
 
-        try
+        if (idxFile[SwordConstants.TESTAMENT_NEW].canRead())
         {
-            idxRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
-            textRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(textFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
-            compRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(compFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
+            try
+            {
+                idxRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
+                textRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(textFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
+                compRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(compFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
+            }
+            catch (FileNotFoundException ex)
+            {
+                assert false : ex;
+                log.error("Could not open NT", ex); //$NON-NLS-1$
+                idxRaf[SwordConstants.TESTAMENT_NEW] = null;
+                textRaf[SwordConstants.TESTAMENT_NEW] = null;
+                compRaf[SwordConstants.TESTAMENT_NEW] = null;
+            }
         }
-        catch (FileNotFoundException ex)
-        {
-            // Ignore this might be OT only
-        }
 
         active = true;
     }
@@ -161,48 +175,45 @@
      */
     public final void deactivate(Lock lock)
     {
-        try
+        if (idxRaf[SwordConstants.TESTAMENT_NEW] != null)
         {
-            idxRaf[SwordConstants.TESTAMENT_NEW].close();
-            textRaf[SwordConstants.TESTAMENT_NEW].close();
-            compRaf[SwordConstants.TESTAMENT_NEW].close();
+            try
+            {
+                idxRaf[SwordConstants.TESTAMENT_NEW].close();
+                textRaf[SwordConstants.TESTAMENT_NEW].close();
+                compRaf[SwordConstants.TESTAMENT_NEW].close();
+            }
+            catch (IOException ex)
+            {
+                log.error("failed to close nt files", ex); //$NON-NLS-1$
+            }
+            finally
+            {
+                idxRaf[SwordConstants.TESTAMENT_NEW] = null;
+                textRaf[SwordConstants.TESTAMENT_NEW] = null;
+                compRaf[SwordConstants.TESTAMENT_NEW] = null;
+            }
         }
-        catch (IOException ex)
-        {
-            log.error("failed to close nt files", ex); //$NON-NLS-1$
-        }
-        catch (NullPointerException ex)
-        {
-            // ignore this might be OT only
-        }
-        finally
-        {
-            idxRaf[SwordConstants.TESTAMENT_NEW] = null;
-            textRaf[SwordConstants.TESTAMENT_NEW] = null;
-            compRaf[SwordConstants.TESTAMENT_NEW] = null;
-        }
 
-        try
+        if (idxRaf[SwordConstants.TESTAMENT_OLD] != null)
         {
-            idxRaf[SwordConstants.TESTAMENT_OLD].close();
-            textRaf[SwordConstants.TESTAMENT_OLD].close();
-            compRaf[SwordConstants.TESTAMENT_OLD].close();
-
+            try
+            {
+                idxRaf[SwordConstants.TESTAMENT_OLD].close();
+                textRaf[SwordConstants.TESTAMENT_OLD].close();
+                compRaf[SwordConstants.TESTAMENT_OLD].close();
+            }
+            catch (IOException ex)
+            {
+                log.error("failed to close ot files", ex); //$NON-NLS-1$
+            }
+            finally
+            {
+                idxRaf[SwordConstants.TESTAMENT_OLD] = null;
+                textRaf[SwordConstants.TESTAMENT_OLD] = null;
+                compRaf[SwordConstants.TESTAMENT_OLD] = null;
+            }
         }
-        catch (IOException ex)
-        {
-            log.error("failed to close ot files", ex); //$NON-NLS-1$
-        }
-        catch (NullPointerException ex)
-        {
-            // ignore this might be NT only
-        }
-        finally
-        {
-            idxRaf[SwordConstants.TESTAMENT_OLD] = null;
-            textRaf[SwordConstants.TESTAMENT_OLD] = null;
-            compRaf[SwordConstants.TESTAMENT_OLD] = null;
-        }
 
         active = false;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -72,25 +72,37 @@
      */
     public final void activate(Lock lock)
     {
-        try
+        if (idxFile[SwordConstants.TESTAMENT_OLD].canRead())
         {
-            idxRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
-            txtRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(txtFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
+            try
+            {
+                idxRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
+                txtRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(txtFile[SwordConstants.TESTAMENT_OLD], FileUtil.MODE_READ);
+            }
+            catch (FileNotFoundException ex)
+            {
+                assert false : ex;
+                log.error("Could not open OT", ex); //$NON-NLS-1$
+                idxRaf[SwordConstants.TESTAMENT_OLD] = null;
+                txtRaf[SwordConstants.TESTAMENT_OLD] = null;
+            }
         }
-        catch (FileNotFoundException ex)
-        {
-            // Ignore this might be NT only
-        }
 
-        try
+        if (idxFile[SwordConstants.TESTAMENT_NEW].canRead())
         {
-            idxRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
-            txtRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(txtFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
+            try
+            {
+                idxRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
+                txtRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(txtFile[SwordConstants.TESTAMENT_NEW], FileUtil.MODE_READ);
+            }
+            catch (FileNotFoundException ex)
+            {
+                assert false : ex;
+                log.error("Could not open NT", ex); //$NON-NLS-1$
+                idxRaf[SwordConstants.TESTAMENT_NEW] = null;
+                txtRaf[SwordConstants.TESTAMENT_NEW] = null;
+            }
         }
-        catch (FileNotFoundException ex)
-        {
-            // Ignore this might be OT only
-        }
 
         active = true;
     }
@@ -110,15 +122,17 @@
         }
         catch (IOException ex)
         {
-            log.error("failed to close files", ex); //$NON-NLS-1$
+            log.error("Failed to close files", ex); //$NON-NLS-1$
         }
+        finally
+        {
+            idxRaf[SwordConstants.TESTAMENT_OLD] = null;
+            txtRaf[SwordConstants.TESTAMENT_OLD] = null;
 
-        idxRaf[SwordConstants.TESTAMENT_OLD] = null;
-        txtRaf[SwordConstants.TESTAMENT_OLD] = null;
+            idxRaf[SwordConstants.TESTAMENT_NEW] = null;
+            txtRaf[SwordConstants.TESTAMENT_NEW] = null;
+        }
 
-        idxRaf[SwordConstants.TESTAMENT_NEW] = null;
-        txtRaf[SwordConstants.TESTAMENT_NEW] = null;
-
         active = false;
     }
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -55,7 +55,7 @@
  * @author Jacky Cheung
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class SwordBookMetaData extends AbstractBookMetaData
+public final class SwordBookMetaData extends AbstractBookMetaData
 {
     /**
      * Loads a sword config from a given File.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -136,8 +136,7 @@
             List osisContent = sbmd.getFilter().toOSIS(key, txt);
             div.addContent(osisContent);
 
-            BookData bdata = new BookData(osis, this, key);
-            return bdata;
+            return new BookData(osis, this, key);
         }
         catch (FilterException ex)
         {
@@ -263,11 +262,11 @@
 
         Key key = null;
         String internalName = sbmd.getInitials();
-        if (internalName.equals("StrongsGreek")) //$NON-NLS-1$
+        if ("StrongsGreek".equals(internalName)) //$NON-NLS-1$
         {
             key = (Key) map.get(ZERO_PAD.format(strongsNumber));
         }
-        else if (internalName.equals("StrongsHebrew")) //$NON-NLS-1$
+        else if ("StrongsHebrew".equals(internalName)) //$NON-NLS-1$
         {
             key = (Key) map.get(ZERO_PAD.format(strongsNumber));
         }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -196,7 +196,7 @@
      */
     public static String decode(Key key, byte[] data, String charset)
     {
-        if (charset.equals("WINDOWS-1252")) //$NON-NLS-1$
+        if ("WINDOWS-1252".equals(charset)) //$NON-NLS-1$
         {
             clean1252(key, data);
         }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -162,19 +162,27 @@
     {
         try
         {
-            idxRaf.close();
-            datRaf.close();
-            zdxRaf.close();
-            zdtRaf.close();
+            if (idxRaf != null)
+            {
+                idxRaf.close();
+            }
+            if (datRaf != null)
+            {
+                datRaf.close();
+            }
+            if (zdxRaf != null)
+            {
+                zdxRaf.close();
+            }
+            if (zdtRaf != null)
+            {
+                zdtRaf.close();
+            }
         }
         catch (IOException ex)
         {
             log.error("failed to close nt files", ex); //$NON-NLS-1$
         }
-        catch (NullPointerException ex)
-        {
-            // ignore this might be OT only
-        }
         finally
         {
             idxRaf = null;
@@ -352,8 +360,7 @@
             byte[] entryBytes = new byte[entrySize];
             System.arraycopy(uncompressed, entryStart, entryBytes, 0, entrySize);
 
-            String ret = SwordUtil.decode(key, entryBytes, charset).trim();
-            return ret;
+            return SwordUtil.decode(key, entryBytes, charset).trim();
         }
         catch (IOException e)
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -277,39 +277,59 @@
         // the BookFilters class
 
         // If you are wanting to get really fancy you can implement your own
-        // Bookfilter easily
-        List test = Books.installed().getBooks(new BookFilter()
-        {
-            public boolean test(Book bk)
-            {
-                return bk.getName().equals("My Favorite Version"); //$NON-NLS-1$
-            }
-        });
+        // BookFilter easily
+        List test = Books.installed().getBooks(new MyBookFilter());
         book = (Book) test.get(0);
 
+        if (book != null)
+        {
+            System.out.println(book.getInitials());
+        }
+
+
         // If you want to know about new books as they arrive:
-        Books.installed().addBooksListener(new BooksListener()
+        Books.installed().addBooksListener(new MyBooksListener());
+    }
+
+    /**
+     * A simple BookFilter that looks for a Bible by name.
+     */
+    static class MyBookFilter implements BookFilter
+    {
+        public boolean test(Book bk)
         {
-            /* (non-Javadoc)
-             * @see org.crosswire.jsword.book.BooksListener#bookAdded(org.crosswire.jsword.book.BooksEvent)
-             */
-            public void bookAdded(BooksEvent ev)
-            {
-            }
+            return bk.getName().equals("My Favorite Version"); //$NON-NLS-1$
+        }
+    }
 
-            /* (non-Javadoc)
-             * @see org.crosswire.jsword.book.BooksListener#bookRemoved(org.crosswire.jsword.book.BooksEvent)
-             */
-            public void bookRemoved(BooksEvent ev)
-            {
-            }
-        });
+    /**
+     * A simple BooksListener that actually does nothing.
+     */
+    static class MyBooksListener implements BooksListener
+    {
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.BooksListener#bookAdded(org.crosswire.jsword.book.BooksEvent)
+         */
+        public void bookAdded(BooksEvent ev)
+        {
+        }
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.BooksListener#bookRemoved(org.crosswire.jsword.book.BooksEvent)
+         */
+        public void bookRemoved(BooksEvent ev)
+        {
+        }
     }
 
     /**
      * Quick Demo
+     * @throws NoSuchKeyException 
+     * @throws BookException 
+     * @throws SAXException 
+     * @throws TransformerException 
      */
-    public static void main(String[] args) throws Exception
+    public static void main(String[] args) throws BookException, NoSuchKeyException, TransformerException, SAXException
     {
         APIExamples examples = new APIExamples();
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/BibleToOsis.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/BibleToOsis.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/BibleToOsis.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -33,9 +33,11 @@
 
 import org.crosswire.common.xml.XMLProcess;
 import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookException;
 import org.crosswire.jsword.book.BookMetaData;
 import org.crosswire.jsword.book.Books;
 import org.crosswire.jsword.passage.Key;
+import org.crosswire.jsword.passage.NoSuchKeyException;
 import org.crosswire.jsword.passage.Verse;
 import org.crosswire.jsword.versification.BibleInfo;
 
@@ -58,12 +60,19 @@
     /**
      * @param args
      */
-    public static void main(String[] args) throws Exception
+    public static void main(String[] args)
     {
-        new BibleToOsis().dump(BIBLE_NAME, BIBLE_RANGE);
+        try
+        {
+            new BibleToOsis().dump(BIBLE_NAME, BIBLE_RANGE);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace(System.err);
+        }
     }
 
-    public void dump(String name, String range) throws Exception
+    public void dump(String name, String range) throws NoSuchKeyException, IOException, BookException
     {
         Books books = Books.installed();
         Book bible = books.getBook(name);
@@ -212,35 +221,7 @@
             return;
         }
 
-        StringBuffer docBuffer = new StringBuffer(400);
-        docBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); //$NON-NLS-1$
-        docBuffer.append("\n<osis"); //$NON-NLS-1$
-        docBuffer.append("\n  xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\""); //$NON-NLS-1$
-        docBuffer.append("\n  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");  //$NON-NLS-1$
-        docBuffer.append("\n  xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.2.1.1.xsd\">"); //$NON-NLS-1$
-        docBuffer.append("\n<osisText osisIDWork=\"{0}\" osisRefWork=\"defaultReferenceScheme\" xml:lang=\"en\">"); //$NON-NLS-1$
-        docBuffer.append("\n<header>"); //$NON-NLS-1$
-        docBuffer.append("\n  <work osisWork=\"{0}\">"); //$NON-NLS-1$
-        docBuffer.append("\n    <title>{1}</title>"); //$NON-NLS-1$
-        docBuffer.append("\n    <identifier type=\"OSIS\">Bible.{0}</identifier>"); //$NON-NLS-1$
-        docBuffer.append("\n    <scope>{2}</scope>"); //$NON-NLS-1$
-        docBuffer.append("\n    <refSystem>Bible.KJV</refSystem>"); //$NON-NLS-1$
-        docBuffer.append("\n  </work>"); //$NON-NLS-1$
-        docBuffer.append("\n  <work osisWork=\"defaultReferenceScheme\">"); //$NON-NLS-1$
-        docBuffer.append("\n    <refSystem>Bible.KJV</refSystem>"); //$NON-NLS-1$
-        docBuffer.append("\n  </work>"); //$NON-NLS-1$
-        docBuffer.append("\n  <work osisWork=\"strong\">"); //$NON-NLS-1$
-        docBuffer.append("\n    <refSystem>Dict.Strongs</refSystem>"); //$NON-NLS-1$
-        docBuffer.append("\n  </work>"); //$NON-NLS-1$
-        docBuffer.append("\n  <work osisWork=\"robinson\">"); //$NON-NLS-1$
-        docBuffer.append("\n    <refSystem>Dict.Robinsons</refSystem>"); //$NON-NLS-1$
-        docBuffer.append("\n  </work>"); //$NON-NLS-1$
-        docBuffer.append("\n  <work osisWork=\"strongMorph\">"); //$NON-NLS-1$
-        docBuffer.append("\n    <refSystem>Dict.strongMorph</refSystem>"); //$NON-NLS-1$
-        docBuffer.append("\n  </work>"); //$NON-NLS-1$
-        docBuffer.append("\n</header>"); //$NON-NLS-1$
-        docBuffer.append('\n');
-        MessageFormat msgFormat = new MessageFormat(docBuffer.toString());
+        MessageFormat msgFormat = new MessageFormat("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<osis\n  xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\"\n  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n  xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.2.1.1.xsd\">\n<osisText osisIDWork=\"{0}\" osisRefWork=\"defaultReferenceScheme\" xml:lang=\"en\">\n<header>\n  <work osisWork=\"{0}\">\n    <title>{1}</title>\n    <identifier type=\"OSIS\">Bible.{0}</identifier>\n    <scope>{2}</scope>\n    <refSystem>Bible.KJV</refSystem>\n  </work>\n  <work osisWork=\"defaultReferenceScheme\">\n    <refSystem>Bible.KJV</refSystem>\n  </work>\n  <work osisWork=\"strong\">\n    <refSystem>Dict.Strongs</refSystem>\n  </work>\n  <work osisWork=\"robinson\">\n    <refSystem>Dict.Robinsons</refSystem>\n  </work>\n  <work osisWork=\"strongMorph\">\n    <refSystem>Dict.strongMorph</refSystem>\n  </work>\n</header>\n"); //$NON-NLS-1$
         msgFormat.format(new Object[] { bmd.getInitials(), bmd.getName(), range }, buf, pos);
     }
 
@@ -272,17 +253,17 @@
     private void buildChapterOpen(StringBuffer buf, String bookName, int chapter)
     {
         MessageFormat msgFormat = new MessageFormat("<chapter osisID=\"{0}.{1}\" chapterTitle=\"{2} {1}.\">\n"); //$NON-NLS-1$
-        if (bookName.equals("Obad") || //$NON-NLS-1$
-            bookName.equals("Phlm") || //$NON-NLS-1$
-            bookName.equals("2John") || //$NON-NLS-1$
-            bookName.equals("3John") || //$NON-NLS-1$
-            bookName.equals("Jude")) //$NON-NLS-1$
+        if ("Obad".equals(bookName) || //$NON-NLS-1$
+            "Phlm".equals(bookName) || //$NON-NLS-1$
+            "2John".equals(bookName) || //$NON-NLS-1$
+            "3John".equals(bookName) || //$NON-NLS-1$
+            "Jude".equals(bookName)) //$NON-NLS-1$
         {
             return;
         }
 
         String chapterName = "CHAPTER"; //$NON-NLS-1$
-        if (bookName.equals("Ps")) //$NON-NLS-1$
+        if ("Ps".equals(bookName)) //$NON-NLS-1$
         {
             chapterName = "PSALM"; //$NON-NLS-1$
         }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -22,6 +22,7 @@
 package org.crosswire.jsword.examples;
 
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.text.FieldPosition;
@@ -33,6 +34,7 @@
 import org.crosswire.common.xml.XMLUtil;
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.BookData;
+import org.crosswire.jsword.book.BookException;
 import org.crosswire.jsword.book.BookMetaData;
 import org.crosswire.jsword.book.Books;
 import org.crosswire.jsword.passage.Key;
@@ -55,12 +57,12 @@
     /**
      * @param args
      */
-    public static void main(String[] args) throws Exception
+    public static void main(String[] args) throws BookException, IOException
     {
         new DictToOsis().dump(BOOK_NAME);
     }
 
-    public void dump(String name) throws Exception
+    public void dump(String name) throws BookException, IOException
     {
         Books books = Books.installed();
         Book book = books.getBook(name);
@@ -84,7 +86,7 @@
             }
             catch (SAXException e)
             {
-                e.printStackTrace();
+                e.printStackTrace(System.err);
             }
         }
 
@@ -110,26 +112,7 @@
 
     private void buildDocumentOpen(StringBuffer buf, BookMetaData bmd)
     {
-        StringBuffer docBuffer = new StringBuffer(200);
-        docBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); //$NON-NLS-1$
-        docBuffer.append("\n<osis"); //$NON-NLS-1$
-        docBuffer.append("\n  xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\""); //$NON-NLS-1$
-        docBuffer.append("\n  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");  //$NON-NLS-1$
-        docBuffer.append("\n  xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace osisCore.2.1.xsd\">"); //$NON-NLS-1$
-        docBuffer.append("\n<osisText osisIDWork=\"{0}\" osisRefWork=\"defaultReferenceScheme\" xml:lang=\"en\">"); //$NON-NLS-1$
-        docBuffer.append("\n  <header>"); //$NON-NLS-1$
-        docBuffer.append("\n    <work osisWork=\"{0}\">"); //$NON-NLS-1$
-        docBuffer.append("\n      <title>{1}</title>"); //$NON-NLS-1$
-        docBuffer.append("\n      <identifier type=\"OSIS\">Dict.{0}</identifier>"); //$NON-NLS-1$
-        docBuffer.append("\n      <refSystem>Dict.{0}</refSystem>"); //$NON-NLS-1$
-        docBuffer.append("\n    </work>"); //$NON-NLS-1$
-        docBuffer.append("\n    <work osisWork=\"defaultReferenceScheme\">"); //$NON-NLS-1$
-        docBuffer.append("\n      <refSystem>Dict.{0}</refSystem>"); //$NON-NLS-1$
-        docBuffer.append("\n    </work>"); //$NON-NLS-1$
-        docBuffer.append("\n  </header>"); //$NON-NLS-1$
-        docBuffer.append("\n<div>"); //$NON-NLS-1$
-        docBuffer.append('\n');
-        MessageFormat msgFormat = new MessageFormat(docBuffer.toString());
+        MessageFormat msgFormat = new MessageFormat("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<osis\n  xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\"\n  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n  xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace osisCore.2.1.xsd\">\n<osisText osisIDWork=\"{0}\" osisRefWork=\"defaultReferenceScheme\" xml:lang=\"en\">\n  <header>\n    <work osisWork=\"{0}\">\n      <title>{1}</title>\n      <identifier type=\"OSIS\">Dict.{0}</identifier>\n      <refSystem>Dict.{0}</refSystem>\n    </work>\n    <work osisWork=\"defaultReferenceScheme\">\n      <refSystem>Dict.{0}</refSystem>\n    </work>\n  </header>\n<div>\n"); //$NON-NLS-1$
         msgFormat.format(new Object[] { bmd.getInitials(), bmd.getName() }, buf, pos);
     }
 
@@ -140,12 +123,13 @@
 
     private void buildEntryOpen(StringBuffer buf, String entryName, String entryDef)
     {
-        if (entryName.indexOf(' ') != -1)
+        String tmp = entryName;
+        if (tmp.indexOf(' ') != -1)
         {
-            entryName = "x"; //$NON-NLS-1$
+            tmp = "x"; //$NON-NLS-1$
         }
         MessageFormat msgFormat = new MessageFormat("<div type=\"entry\" osisID=\"{0}\" canonical=\"true\"><seg type=\"x-form\"><seg type=\"x-orth\">{0}</seg></seg><seg type=\"x-def\">{1}</seg></div>\n"); //$NON-NLS-1$
-        msgFormat.format(new Object[] { entryName, entryDef }, buf, pos);
+        msgFormat.format(new Object[] { tmp, entryDef }, buf, pos);
     }
 
     private static FieldPosition pos = new FieldPosition(0);

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/IndexStatus.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -98,24 +98,6 @@
         return VALUES[i];
     }
 
-    /**
-     * Prevent subclasses from overriding canonical identity based Object methods
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals(Object o)
-    {
-        return super.equals(o);
-    }
-
-    /**
-     * Prevent subclasses from overriding canonical identity based Object methods
-     * @see java.lang.Object#hashCode()
-     */
-    public int hashCode()
-    {
-        return super.hashCode();
-    }
-
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneQueryBuilder.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneQueryBuilder.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneQueryBuilder.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -46,13 +46,6 @@
  */
 public final class LuceneQueryBuilder implements QueryBuilder
 {
-    /**
-     * Prevent Instansiation
-     */
-    public LuceneQueryBuilder()
-    {
-    }
-
     /* (non-Javadoc)
      * @see org.crosswire.jsword.index.query.QueryBuilder#parse(java.lang.String)
      */
@@ -88,7 +81,7 @@
             String blur = blurMatcher.group(1);
             if (blur.length() > 0)
             {
-                blurFactor = Integer.valueOf(blur).intValue();
+                blurFactor = Integer.parseInt(blur);
             }
             Query left = new BaseQuery(sought.substring(i, blurMatcher.start()));
             Query right = new BaseQuery(sought.substring(blurMatcher.end()));

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -1005,7 +1005,7 @@
      * synchronised, however this is safe, and I don't think there is
      * a cost associated with a double synchronize. (?)
      */
-    protected void normalize()
+    /*protected*/ void normalize()
     {
         // before doing any normalization we should be checking that
         // skip_normalization == 0, and just returning if so.
@@ -1027,7 +1027,7 @@
             // chance to fix the error
             //   throw new LogicError();
 
-            log.warn("skip_normalization=" + skipNormalization, new Exception()); //$NON-NLS-1$
+            log.warn("skip_normalization=" + skipNormalization); //$NON-NLS-1$
         }
     }
 
@@ -1065,7 +1065,7 @@
             // chance to fix the error
             //   throw new LogicError();
 
-            log.warn("suppress_events=" + suppressEvents, new Exception()); //$NON-NLS-1$
+            log.warn("suppress_events=" + suppressEvents); //$NON-NLS-1$
         }
     }
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -282,8 +282,7 @@
             // and it gets the end of the chapter
             int book = verseBasis.getBook();
             int chapter = getChapter(book, endParts[0]);
-            Verse end = new Verse(endVerseDesc, book, chapter, 1);
-            return end.getLastVerseInChapter();
+            return new Verse(endVerseDesc, book, chapter, 1).getLastVerseInChapter();
         }
 
         /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/KeyUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/KeyUtil.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/KeyUtil.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -82,8 +82,7 @@
 
         try
         {
-            Verse verse = VerseFactory.fromString(key.getName());
-            return verse;
+            return VerseFactory.fromString(key.getName());
         }
         catch (NoSuchVerseException ex)
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -985,14 +985,11 @@
          */
         public int lastRank() throws NoSuchElementException
         {
-            try
+            if (last != null)
             {
                 return last.tally;
             }
-            catch (NullPointerException ex)
-            {
-                throw new NoSuchElementException(Msg.TALLY_ERROR_ENUM.toString());
-            }
+            throw new NoSuchElementException(Msg.TALLY_ERROR_ENUM.toString());
         }
 
         /**
@@ -1119,14 +1116,11 @@
          */
         public int lastRank() throws NoSuchElementException
         {
-            try
+            if (last != null)
             {
                 return last.tally;
             }
-            catch (NullPointerException ex)
-            {
-                throw new NoSuchElementException(Msg.TALLY_ERROR_ENUM.toString());
-            }
+            throw new NoSuchElementException(Msg.TALLY_ERROR_ENUM.toString());
         }
 
         /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -148,7 +148,7 @@
      * @see org.crosswire.jsword.passage.Passage#rangeIterator(int)
      */
     /* @Override */
-    public Iterator rangeIterator(RestrictionType restrict)
+    public final Iterator rangeIterator(RestrictionType restrict)
     {
         if (restrict.equals(RestrictionType.NONE))
         {
@@ -332,7 +332,7 @@
      * a double synchronize. (?)
      */
     /* @Override */
-    protected void normalize()
+    /*protected*/ final void normalize()
     {
         if (skipNormalization != 0)
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -88,52 +88,11 @@
         private static final long serialVersionUID = 3905246714754643248L;
     };
 
-//    /**
-//     * Blurring is restricted to the book.
-//     */
-//    public static final RestrictionType BOOK = new RestrictionType("BOOK") //$NON-NLS-1$
-//    {
-//        /* (non-Javadoc)
-//         * @see org.crosswire.jsword.passage.RestrictionType#isSameScope(org.crosswire.jsword.passage.Verse, org.crosswire.jsword.passage.Verse)
-//         */
-//        public boolean isSameScope(Verse start, Verse end)
-//        {
-//            return start.isSameBook(end);
-//        }
-//
-//        /* (non-Javadoc)
-//         * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.VerseRange, int, int)
-//         */
-//        public VerseRange blur(VerseRange range, int blurDown, int blurUp)
-//        {
-//            throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
-//        }
-//
-//        /* (non-Javadoc)
-//         * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.Verse, int, int)
-//         */
-//        public VerseRange blur(Verse verse, int blurDown, int blurUp)
-//        {
-//            throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
-//        }
-//
-//        /* (non-Javadoc)
-//         * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.Verse, int, int)
-//         */
-//        public VerseRange toRange(Verse verse, int count)
-//        {
-//            throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
-//        }
-//
-//        /**
-//         * Serialization ID
-//         */
-//        private static final long serialVersionUID = 3978142166633820472L;
-//    };
-
     /**
      * Blurring is restricted to the chapter
      */
+    // Note: FindBugs wrongly reports an initialization circularity.
+    // Turns out that it is the exception handling that causes it.
     public static final RestrictionType CHAPTER = new RestrictionType("CHAPTER") //$NON-NLS-1$
     {
         /* (non-Javadoc)
@@ -393,6 +352,5 @@
     {
         NONE,
         CHAPTER,
-//      BOOK,
     };
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -194,7 +194,7 @@
      */
     public String getName(Key base)
     {
-        if (base == null || !(base instanceof Verse))
+        if (!(base instanceof Verse))
         {
             return getName();
         }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/util/ConverterFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/util/ConverterFactory.java	2006-10-19 21:47:42 UTC (rev 1168)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/util/ConverterFactory.java	2006-10-19 21:48:21 UTC (rev 1169)
@@ -52,8 +52,7 @@
         {
             Class clazz = (Class) ClassUtil.getImplementorsMap(Converter.class).get(name);
             assert clazz != null : Msg.NO_CONVERTER.toString(name);
-            Converter converter = (Converter) clazz.newInstance();
-            return converter;
+            return (Converter) clazz.newInstance();
         }
         catch (InstantiationException e)
         {




More information about the jsword-svn mailing list