[jsword-svn] r2230 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/book bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/java/org/crosswire/bibledesktop/passage common-swing/src/main/java/org/crosswire/common/config/swing common-swing/src/main/java/org/crosswire/common/progress/swing common-swing/src/main/java/org/crosswire/common/swing common-swing/src/main/java/org/crosswire/common/swing/desktop jsword jsword/src/main/java/org/crosswire/common/util jsword/src/main/java/org/crosswire/jsword/book/basic jsword/src/main/java/org/crosswire/jsword/book/sword jsword/src/main/java/org/crosswire/jsword/versification/system

dmsmith at crosswire.org dmsmith at crosswire.org
Tue Feb 7 17:00:10 MST 2012


Author: dmsmith
Date: 2012-02-07 17:00:10 -0700 (Tue, 07 Feb 2012)
New Revision: 2230

Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java
   trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java
   trunk/jsword/JSwordDictionary.txt
   trunk/jsword/src/main/java/org/crosswire/common/util/ClassUtil.java
   trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java
   trunk/jsword/src/main/java/org/crosswire/common/util/NetUtil.java
   trunk/jsword/src/main/java/org/crosswire/common/util/Translations.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemDefault.java
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemLeningrad.java
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemMT.java
Log:
Cleaned up problems reported by FindBugs. Still a few more to do.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -205,6 +205,7 @@
         // and read them in here.
         // But at this time we don't serialize views.
         bookList = Books.installed();
+        books = new ArrayList<Book>();
 
         is.defaultReadObject();
     }
@@ -229,7 +230,7 @@
      * marked synchronized to ensure that one thread can't update the list of
      * books while another is trying to create a JList based on this class.
      */
-    protected List<Book> books;
+    protected transient List<Book> books;
 
     /**
      * The sort algorithm to use.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -1301,7 +1301,7 @@
     /**
      * Whether to show differences between versions of the Bible
      */
-    private static boolean compareShowing;
+    private boolean compareShowing;
 
     /**
      * Whether to current BibleView should be used for links
@@ -1316,7 +1316,7 @@
     /**
      * The factory for actions that this class works with
      */
-    private volatile ActionFactory actions;
+    private transient volatile ActionFactory actions;
     /**
      * The DesktopActions is the holder for the actions, merely to keep the size of this file smaller.
      */

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -22,7 +22,6 @@
 package org.crosswire.bibledesktop.desktop;
 
 import java.io.File;
-import java.io.Serializable;
 import java.net.MalformedURLException;
 
 import org.crosswire.common.util.NetUtil;
@@ -36,84 +35,84 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [ dmsmith555 at yahoo dot com]
  */
-public final class XSLTProperty implements Serializable {
+public enum XSLTProperty {
     /**
      * Determines whether Strong's Numbers should show
      */
-    public static final XSLTProperty STRONGS_NUMBERS = new XSLTProperty("Strongs", false);
+    STRONGS_NUMBERS("Strongs", false),
 
     /**
      * Determines whether Word Morphology (e.g. Robinson) should show
      */
-    public static final XSLTProperty MORPH = new XSLTProperty("Morph", false);
+   MORPH("Morph", false),
 
     /**
      * Determines whether verses should start on a new line.
      */
-    public static final XSLTProperty START_VERSE_ON_NEWLINE = new XSLTProperty("VLine", false);
+    START_VERSE_ON_NEWLINE("VLine", false),
 
     /**
      * Show verse numbers
      */
-    public static final XSLTProperty VERSE_NUMBERS = new XSLTProperty("VNum", true);
+    VERSE_NUMBERS("VNum", true),
 
     /**
      * Show chapter and verse numbers.
      */
-    public static final XSLTProperty CV = new XSLTProperty("CVNum", false);
+    CV("CVNum", false),
 
     /**
      * Show book, chapter and verse numbers.
      */
-    public static final XSLTProperty BCV = new XSLTProperty("BCVNum", false);
+    BCV("BCVNum", false),
 
     /**
      * Show no verse numbers
      */
-    public static final XSLTProperty NO_VERSE_NUMBERS = new XSLTProperty("NoVNum", false);
+    NO_VERSE_NUMBERS("NoVNum", false),
 
     /**
      * Show verse numbers as a superscript.
      */
-    public static final XSLTProperty TINY_VERSE_NUMBERS = new XSLTProperty("TinyVNum", true);
+    TINY_VERSE_NUMBERS("TinyVNum", true),
 
     /**
      * Should headings be shown
      */
-    public static final XSLTProperty HEADINGS = new XSLTProperty("Headings", true);
+    HEADINGS("Headings", true),
 
     /**
      * Should notes be shown
      */
-    public static final XSLTProperty NOTES = new XSLTProperty("Notes", true);
+    NOTES("Notes", true),
 
     /**
      * Should cross references be shown
      */
-    public static final XSLTProperty XREF = new XSLTProperty("XRef", true);
+    XREF("XRef", true),
 
     /**
      * What is the base of the current document. Note this needs to be set each
      * time the document is shown.
      */
-    public static final XSLTProperty BASE_URL = new XSLTProperty("baseURL", "", true);
+    BASE_URL("baseURL", "", true),
 
     /**
      * What is the base of the current document. Note this needs to be set each
      * time the document is shown.
      */
-    public static final XSLTProperty DIRECTION = new XSLTProperty("direction", "");
+    DIRECTION("direction", ""),
 
     /**
      * What is the base of the current document. Note this needs to be set each
      * time the font changes.
      */
-    public static final XSLTProperty FONT = new XSLTProperty("font", "Serif-PLAIN-14");
+    FONT("font", "Serif-PLAIN-14"),
 
     /**
      * What is the base of the current document.
      */
-    public static final XSLTProperty CSS = new XSLTProperty("css", "", true);
+    CSS("css", "", true);
 
     /**
      * @param name
@@ -194,8 +193,8 @@
     }
 
     public static void setProperties(TransformingSAXEventProvider provider) {
-        for (int i = 0; i < VALUES.length; i++) {
-            VALUES[i].setProperty(provider);
+        for (XSLTProperty v : values()) {
+            v.setProperty(provider);
         }
     }
 
@@ -203,12 +202,13 @@
      * Lookup method to convert from a String
      */
     public static XSLTProperty fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            XSLTProperty o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (XSLTProperty v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
+        // cannot get here
         assert false;
         return null;
     }
@@ -217,7 +217,15 @@
      * Lookup method to convert from an integer
      */
     public static XSLTProperty fromInteger(int i) {
-        return VALUES[i];
+        for (XSLTProperty v : values()) {
+            if (v.ordinal() == i) {
+                return v;
+            }
+        }
+
+        // cannot get here
+        assert false;
+        return null;
     }
 
     /* (non-Javadoc)
@@ -248,22 +256,4 @@
      * property.
      */
     private boolean asURL;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final XSLTProperty[] VALUES = {
-            STRONGS_NUMBERS, MORPH, START_VERSE_ON_NEWLINE, VERSE_NUMBERS, CV, BCV, NO_VERSE_NUMBERS, TINY_VERSE_NUMBERS, HEADINGS, NOTES, XREF, BASE_URL,
-            DIRECTION, FONT, CSS,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3257567325749326905L;
 }

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -61,7 +61,7 @@
         Level thislevel = Level.BOOK;
 
         if (b == null) {
-            assert false : b;
+            assert false : "BibleBook is null";
         } else if (c == -1) {
             thislevel = Level.BOOK;
             int ec = v11n.getLastChapter(b);

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -52,7 +52,7 @@
     /**
      * WARNING: this code is not called from anywhere and is probably broken
      */
-    protected void jbInit() {
+    protected AdvancedConfigEditor() {
         ctm = new AdvancedConfigureTreeModel();
         tree = new JTree();
         JScrollPane scroll = new CWScrollPane(tree);

Modified: trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -248,12 +248,12 @@
     /**
      * Where we store the currently displayed jobs
      */
-    protected Map<Progress, JobData> jobs;
+    protected transient Map<Progress, JobData> jobs;
 
     /**
      * Array telling us what y position the jobs have in the window
      */
-    private List<JobData> positions;
+    private transient List<JobData> positions;
 
     /**
      * The font for the progress-bars

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -21,6 +21,9 @@
  */
 package org.crosswire.common.swing;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -66,7 +69,7 @@
      * @param map
      *            The map we are getting our data from
      */
-    public final void setMap(Map map) {
+    public final void setMap(Map<Object, Object> map) {
         this.map = map;
         list.clear();
         if (map != null) {
@@ -229,15 +232,27 @@
     }
 
     /**
+     * Serialization support.
+     * 
+     * @param is
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
+        list = new ArrayList<StringPair>();
+        is.defaultReadObject();
+    }
+
+    /**
      * The List that is a copy of the list. A list is used for direct access
      * performance.
      */
-    private List<StringPair> list;
+    private transient List<StringPair> list;
 
     /**
      * The backing map
      */
-    private Map map;
+    private Map<Object, Object> map;
 
     /**
      * The default column names
@@ -254,7 +269,7 @@
     /**
      * A simple holder of a key/value pair of Strings.
      */
-    private static final class StringPair {
+    private static final class StringPair implements Serializable {
         /**
          * @param k
          *            The non-null key.
@@ -289,5 +304,11 @@
          * <code>value</code> is the string representation of a Map entry value
          */
         private String value;
+
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = 1730905297956834949L;
+
     }
 }

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -70,6 +70,7 @@
      */
     public ViewManager(ViewGenerator generator) {
         this.generator = generator;
+        contextActions = null;
     }
 
     /**
@@ -349,7 +350,7 @@
      */
     public void setLayoutType(LayoutType next) {
         // Check if this is a change
-        if (getViewLayoutType().equals(next)) {
+        if (panel == null || getViewLayoutType().equals(next)) {
             return;
         }
 
@@ -436,6 +437,9 @@
      * @return the action requested or null if it does not exist
      */
     public Action getContextAction(String key) {
+        if (contextActions == null) {
+            return null;
+        }
         return contextActions.findAction(key);
     }
 

Modified: trunk/jsword/JSwordDictionary.txt
===================================================================
--- trunk/jsword/JSwordDictionary.txt	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/JSwordDictionary.txt	2012-02-08 00:00:10 UTC (rev 2230)
@@ -196,3 +196,7 @@
 nehemiah
 charset
 luther
+enum
+rev
+prequel
+zip

Modified: trunk/jsword/src/main/java/org/crosswire/common/util/ClassUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/util/ClassUtil.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/common/util/ClassUtil.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -64,9 +64,10 @@
         for (int i = 0; i < paths.length; i++) {
             // Search the jar
             if (paths[i].endsWith(EXTENSION_ZIP) || paths[i].endsWith(EXTENSION_JAR)) {
+                ZipFile zip = null;
                 try {
                     String fileName = classname.replace(',', '/') + EXTENSION_CLASS;
-                    ZipFile zip = new ZipFile(paths[i]);
+                    zip = new ZipFile(paths[i]);
                     ZipEntry entry = zip.getEntry(fileName);
 
                     if (entry != null && !entry.isDirectory()) {
@@ -79,6 +80,8 @@
                 } catch (IOException ex) {
                     // If that zip file failed, then ignore it and move on.
                     log.warn("Missing zip file for " + classname + " and " + paths[i]);
+                } finally {
+                    IOUtil.close(zip);
                 }
             } else {
                 StringBuilder path = new StringBuilder(256);

Modified: trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -63,36 +63,57 @@
     public static void unpackZip(File file, File destdir) throws IOException {
         // unpack the zip.
         byte[] dbuf = new byte[4096];
-        ZipFile zf = new ZipFile(file);
-        Enumeration<? extends ZipEntry> entries = zf.entries();
-        while (entries.hasMoreElements()) {
-            ZipEntry entry = entries.nextElement();
-            String entrypath = entry.getName();
-            File entryFile = new File(destdir, entrypath);
-            File parentDir = entryFile.getParentFile();
-            // Is it already a directory ?
-            if (!parentDir.isDirectory()) {
-                // Create the directory and make sure it worked.
-                if (!parentDir.mkdirs()) {
-                    // TRANSLATOR: Error condition: A directory could not be created. {0} is a placeholder for the directory
-                    throw new MalformedURLException(JSMsg.gettext("The URL {0} could not be created as a directory.", parentDir.toString()));
+        ZipFile zf = null;
+        try {
+            zf = new ZipFile(file);
+            Enumeration<? extends ZipEntry> entries = zf.entries();
+            while (entries.hasMoreElements()) {
+                ZipEntry entry = entries.nextElement();
+                String entrypath = entry.getName();
+                File entryFile = new File(destdir, entrypath);
+                File parentDir = entryFile.getParentFile();
+                // Is it already a directory ?
+                if (!parentDir.isDirectory()) {
+                    // Create the directory and make sure it worked.
+                    if (!parentDir.mkdirs()) {
+                        // TRANSLATOR: Error condition: A directory could not be created. {0} is a placeholder for the directory
+                        throw new MalformedURLException(JSMsg.gettext("The URL {0} could not be created as a directory.", parentDir.toString()));
+                    }
                 }
-            }
 
-            URI child = NetUtil.getURI(entryFile);
+                URI child = NetUtil.getURI(entryFile);
 
-            OutputStream dataOut = NetUtil.getOutputStream(child);
-            InputStream dataIn = zf.getInputStream(entry);
+                OutputStream dataOut = NetUtil.getOutputStream(child);
+                InputStream dataIn = zf.getInputStream(entry);
 
-            while (true) {
-                int count = dataIn.read(dbuf);
-                if (count == -1) {
-                    break;
+                while (true) {
+                    int count = dataIn.read(dbuf);
+                    if (count == -1) {
+                        break;
+                    }
+                    dataOut.write(dbuf, 0, count);
                 }
-                dataOut.write(dbuf, 0, count);
+
+                dataOut.close();
             }
+        } finally {
+            IOUtil.close(zf);
+        }
+    }
 
-            dataOut.close();
+    /**
+     * Close the zip file without complaining
+     * 
+     * @param zip
+     *            The zip file to close
+     */
+    public static void close(ZipFile zip) {
+        if (null != zip) {
+            try {
+                zip.close();
+            } catch (IOException ex) {
+                log.error("close", ex);
+            }
         }
     }
 

Modified: trunk/jsword/src/main/java/org/crosswire/common/util/NetUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/util/NetUtil.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/common/util/NetUtil.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -396,7 +396,7 @@
 
             return new URI(orig.getScheme(), orig.getUserInfo(), orig.getHost(), orig.getPort(), path.toString(), orig.getQuery(), orig.getFragment());
         } catch (URISyntaxException ex) {
-            assert false : ex;
+//            assert false : ex;
             return null;
         }
     }

Modified: trunk/jsword/src/main/java/org/crosswire/common/util/Translations.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/util/Translations.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/common/util/Translations.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -155,7 +155,7 @@
         try {
             translation = found;
             PropertyMap props = new PropertyMap();
-            if (translation != DEFAULT_TRANSLATION) {
+            if (!DEFAULT_TRANSLATION.equals(translation)) {
                 props.put(TRANSLATION_KEY, translation);
             }
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookmark.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -111,7 +111,7 @@
     /**
      * The list of books.
      */
-    private List<Book> books;
+    private transient List<Book> books;
 
     /**
      * The lookup request.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -260,7 +260,7 @@
         BufferedOutputStream bos = null;
         try {
             bos = new BufferedOutputStream(new FileOutputStream(txtFile, true));
-            bos.write(fileName.getBytes());
+            bos.write(fileName.getBytes(getBookMetaData().getBookCharset()));
         } finally {
             if (bos != null) {
                 bos.close();

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -25,6 +25,7 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.RandomAccessFile;
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.text.DecimalFormat;
 import java.text.MessageFormat;
@@ -111,7 +112,11 @@
 
     protected String getRawText(DataEntry entry) {
         String cipherKeyString = (String) getBookMetaData().getProperty(ConfigEntryType.CIPHER_KEY);
-        return entry.getRawText((cipherKeyString != null) ? cipherKeyString.getBytes() : null);
+        try {
+            return entry.getRawText((cipherKeyString != null) ? cipherKeyString.getBytes(getBookMetaData().getBookCharset()) : null);
+        } catch (UnsupportedEncodingException e) {
+            return entry.getRawText(cipherKeyString.getBytes());
+        }
     }
 
     /*

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -238,7 +238,7 @@
             }
 
             // 10 because the index is 10 bytes long for each verse
-            byte[] temp = SwordUtil.readRAF(compRaf, index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
+            byte[] temp = SwordUtil.readRAF(compRaf, 1L * index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
 
             // If the Bible does not contain the desired verse, return nothing.
             // Some Bibles have different versification, so the requested verse may not exist.
@@ -290,7 +290,7 @@
             }
 
             // 10 because the index is 10 bytes long for each verse
-            byte[] temp = SwordUtil.readRAF(compRaf, index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
+            byte[] temp = SwordUtil.readRAF(compRaf, 1L * index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
 
             // If the Bible does not contain the desired verse, return nothing.
             // Some Bibles have different versification, so the requested verse may not exist.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemDefault.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemDefault.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemDefault.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -35,11 +35,16 @@
 public class SystemDefault extends Versification {
     public static final String V11N_NAME = "";
 
-    // Default for other Testament in single Testament Bibles
+    // Default Books for other Testament in single Testament Bibles
     /* protected */ static final BibleBook[] BOOKS_NONE =
     {
     };
 
+    // Default offsets for other Testament in single Testament Bibles
+    /* protected */ static final int[][] LAST_VERSE_NONE =
+    {
+    };
+
     // Default NT list is the most common
     /* protected */ static final BibleBook[] BOOKS_NT =
     {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemLeningrad.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemLeningrad.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemLeningrad.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -40,12 +40,13 @@
      * Build the "Leningrad" Versification.
      */
     /* protected */ SystemLeningrad() {
-        super(V11N_NAME, BOOKS_OT, BOOKS_NT, LAST_VERSE_OT, null);
+        super(V11N_NAME, BOOKS_OT, BOOKS_NT, LAST_VERSE_OT, LAST_VERSE_NT);
     }
 
     public static final String V11N_NAME = "Leningrad";
 
     /* protected */ static final BibleBook[] BOOKS_NT = SystemDefault.BOOKS_NONE;
+    /* protected */ static final int[][] LAST_VERSE_NT = SystemDefault.LAST_VERSE_NONE;
 
     /* protected */ static final BibleBook[] BOOKS_OT =
     {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemMT.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemMT.java	2012-02-06 23:12:42 UTC (rev 2229)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/system/SystemMT.java	2012-02-08 00:00:10 UTC (rev 2230)
@@ -40,12 +40,13 @@
      * Build the "MT" Versification.
      */
     /* protected */ SystemMT() {
-        super(V11N_NAME, BOOKS_OT, BOOKS_NT, LAST_VERSE_NT, null);
+        super(V11N_NAME, BOOKS_OT, BOOKS_NT, LAST_VERSE_OT, LAST_VERSE_NT);
     }
 
     public static final String V11N_NAME = "MT";
 
     /* protected */ static final BibleBook[] BOOKS_NT = SystemDefault.BOOKS_NONE;
+    /* protected */ static final int[][] LAST_VERSE_NT = SystemDefault.LAST_VERSE_NONE;
 
     // Different ordering of SystemDefault.booksOT
     /* protected */ static final BibleBook[] BOOKS_OT =
@@ -91,7 +92,7 @@
         BibleBook.CHR2,
     };
 
-    /* protected */ static final int[][] LAST_VERSE_NT =
+    /* protected */ static final int[][] LAST_VERSE_OT =
     {
         // Genesis
         {




More information about the jsword-svn mailing list