[jsword-svn] r2197 - in trunk/jsword/src: main/java/org/crosswire/jsword/book/sword main/java/org/crosswire/jsword/passage main/java/org/crosswire/jsword/versification test/java/org/crosswire/jsword/passage

dmsmith at crosswire.org dmsmith at crosswire.org
Wed Jan 4 14:53:06 MST 2012


Author: dmsmith
Date: 2012-01-04 14:53:06 -0700 (Wed, 04 Jan 2012)
New Revision: 2197

Added:
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/Testament.java
Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordConstants.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.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/passage/VerseRange.java
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/BibleInfoTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java
Log:
More work on v11n.

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	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -40,6 +40,8 @@
 import org.crosswire.jsword.passage.Key;
 import org.crosswire.jsword.passage.KeyUtil;
 import org.crosswire.jsword.passage.Verse;
+import org.crosswire.jsword.versification.BibleInfo;
+import org.crosswire.jsword.versification.Testament;
 
 /**
  * Both Books and Commentaries seem to use the same format so this class
@@ -61,12 +63,8 @@
         assert datasize == 2 || datasize == 4;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage
-     * .Key)
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.AbstractBackend#contains(org.crosswire.jsword.passage.Key)
      */
     @Override
     public boolean contains(Key key) {
@@ -77,15 +75,20 @@
         Verse verse = KeyUtil.getVerse(key);
 
         try {
-            int testament = SwordConstants.getTestament(verse);
-            long index = SwordConstants.getIndex(verse);
+            int index = BibleInfo.getOrdinal(verse);
+            Testament testament = BibleInfo.getTestament(index);
+            index = BibleInfo.getTestamentOrdinal(index);
+            RandomAccessFile idxRaf = otIdxRaf;
+            if (testament == Testament.OLD) {
+                idxRaf = ntIdxRaf;
+            }
 
             // If this is a single testament Bible, return nothing.
-            if (idxRaf[testament] == null) {
+            if (idxRaf == null) {
                 return false;
             }
 
-            DataIndex dataIndex = getIndex(idxRaf[testament], index);
+            DataIndex dataIndex = getIndex(idxRaf, index);
 
             return dataIndex.getSize() > 0;
         } catch (IOException ex) {
@@ -96,12 +99,8 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire
-     * .jsword.passage.Key, java.lang.String)
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire.jsword.passage.Key)
      */
     @Override
     public String getRawText(Key key) throws BookException {
@@ -111,11 +110,16 @@
             DataPolice.setKey(key);
             Verse verse = KeyUtil.getVerse(key);
             try {
-                int testament = SwordConstants.getTestament(verse);
-                long index = SwordConstants.getIndex(verse);
+                int index = BibleInfo.getOrdinal(verse);
+                Testament testament = BibleInfo.getTestament(index);
+                index = BibleInfo.getTestamentOrdinal(index);
+                RandomAccessFile idxRaf = otIdxRaf;
+                if (testament == Testament.OLD) {
+                    idxRaf = ntIdxRaf;
+                }
 
                 // If this is a single testament Bible, return nothing.
-                if (idxRaf[testament] == null) {
+                if (idxRaf == null) {
                     return "";
                 }
 
@@ -130,20 +134,14 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.jsword.book.sword.AbstractBackend#setRawText(org.crosswire
-     * .jsword.passage.Key, java.lang.String)
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.AbstractBackend#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
      */
     @Override
     public void setRawText(Key key, String text) throws BookException, IOException {
     }
 
-    /*
-     * (non-Javadoc)
-     * 
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.sword.AbstractBackend#isWritable()
      */
     @Override
@@ -152,17 +150,13 @@
         // testament needs to be present
         // (i.e. readable) and both the index and the data files need to be
         // writable
-        if (idxFile[SwordConstants.TESTAMENT_OLD].canRead()
-                && (idxFile[SwordConstants.TESTAMENT_OLD].canWrite() || !txtFile[SwordConstants.TESTAMENT_OLD].canWrite()))
-        {
+        if (otIdxFile.canRead() && (otIdxFile.canWrite() || !otTxtFile.canWrite())) {
             return false;
         }
-        if (idxFile[SwordConstants.TESTAMENT_NEW].canRead()
-                && (idxFile[SwordConstants.TESTAMENT_NEW].canWrite() || !txtFile[SwordConstants.TESTAMENT_NEW].canWrite()))
-        {
+        if (ntIdxFile.canRead() && (ntIdxFile.canWrite() || !ntTxtFile.canWrite())) {
             return false;
         }
-        return idxFile[SwordConstants.TESTAMENT_OLD].canRead() || idxFile[SwordConstants.TESTAMENT_NEW].canRead();
+        return otIdxFile.canRead() || ntIdxFile.canRead();
     }
 
     /* (non-Javadoc)
@@ -173,12 +167,8 @@
         throw new UnsupportedOperationException();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.common.activate.Activatable#activate(org.crosswire.common
-     * .activate.Lock)
+    /* (non-Javadoc)
+     * @see org.crosswire.common.activate.Activatable#activate(org.crosswire.common.activate.Lock)
      */
     public final void activate(Lock lock) {
         URI path = null;
@@ -190,70 +180,66 @@
         }
 
         URI otPath = NetUtil.lengthenURI(path, File.separator + SwordConstants.FILE_OT);
-        txtFile[SwordConstants.TESTAMENT_OLD] = new File(otPath.getPath());
-        idxFile[SwordConstants.TESTAMENT_OLD] = new File(otPath.getPath() + SwordConstants.EXTENSION_VSS);
+        otTxtFile = new File(otPath.getPath());
+        otIdxFile = new File(otPath.getPath() + SwordConstants.EXTENSION_VSS);
 
         URI ntPath = NetUtil.lengthenURI(path, File.separator + SwordConstants.FILE_NT);
-        txtFile[SwordConstants.TESTAMENT_NEW] = new File(ntPath.getPath());
-        idxFile[SwordConstants.TESTAMENT_NEW] = new File(ntPath.getPath() + SwordConstants.EXTENSION_VSS);
+        ntTxtFile = new File(ntPath.getPath());
+        ntIdxFile = new File(ntPath.getPath() + SwordConstants.EXTENSION_VSS);
 
         // It is an error to be neither OT nor NT
-        if (!txtFile[SwordConstants.TESTAMENT_OLD].canRead() && !txtFile[SwordConstants.TESTAMENT_NEW].canRead()) {
+        if (!otTxtFile.canRead() && !ntTxtFile.canRead()) {
             Reporter.informUser(this, new BookException(JSOtherMsg.lookupText("Missing data files for old and new testaments in {0}.", path)));
             return;
         }
 
         String fileMode = isWritable() ? FileUtil.MODE_WRITE : FileUtil.MODE_READ;
 
-        if (idxFile[SwordConstants.TESTAMENT_OLD].canRead()) {
+        if (otIdxFile.canRead()) {
             try {
-                idxRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_OLD], fileMode);
-                txtRaf[SwordConstants.TESTAMENT_OLD] = new RandomAccessFile(txtFile[SwordConstants.TESTAMENT_OLD], fileMode);
+                otIdxRaf = new RandomAccessFile(otIdxFile, fileMode);
+                otTxtRaf = new RandomAccessFile(otTxtFile, fileMode);
             } catch (FileNotFoundException ex) {
                 assert false : ex;
                 log.error("Could not open OT", ex);
-                idxRaf[SwordConstants.TESTAMENT_OLD] = null;
-                txtRaf[SwordConstants.TESTAMENT_OLD] = null;
+                ntIdxRaf = null;
+                ntTxtRaf = null;
             }
         }
 
-        if (idxFile[SwordConstants.TESTAMENT_NEW].canRead()) {
+        if (ntIdxFile.canRead()) {
             try {
-                idxRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(idxFile[SwordConstants.TESTAMENT_NEW], fileMode);
-                txtRaf[SwordConstants.TESTAMENT_NEW] = new RandomAccessFile(txtFile[SwordConstants.TESTAMENT_NEW], fileMode);
+                ntIdxRaf = new RandomAccessFile(ntIdxFile, fileMode);
+                ntTxtRaf = new RandomAccessFile(ntTxtFile, fileMode);
             } catch (FileNotFoundException ex) {
                 assert false : ex;
                 log.error("Could not open NT", ex);
-                idxRaf[SwordConstants.TESTAMENT_NEW] = null;
-                txtRaf[SwordConstants.TESTAMENT_NEW] = null;
+                ntIdxRaf = null;
+                ntTxtRaf = null;
             }
         }
 
         active = true;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.common.activate.Activatable#deactivate(org.crosswire.common
-     * .activate.Lock)
+    /* (non-Javadoc)
+     * @see org.crosswire.common.activate.Activatable#deactivate(org.crosswire.common.activate.Lock)
      */
     public final void deactivate(Lock lock) {
         try {
-            idxRaf[SwordConstants.TESTAMENT_OLD].close();
-            txtRaf[SwordConstants.TESTAMENT_OLD].close();
+            otIdxRaf.close();
+            otTxtRaf.close();
 
-            idxRaf[SwordConstants.TESTAMENT_NEW].close();
-            txtRaf[SwordConstants.TESTAMENT_NEW].close();
+            ntIdxRaf.close();
+            ntTxtRaf.close();
         } catch (IOException ex) {
             log.error("Failed to close files", ex);
         } finally {
-            idxRaf[SwordConstants.TESTAMENT_OLD] = null;
-            txtRaf[SwordConstants.TESTAMENT_OLD] = null;
+            otIdxRaf = null;
+            otTxtRaf = null;
 
-            idxRaf[SwordConstants.TESTAMENT_NEW] = null;
-            txtRaf[SwordConstants.TESTAMENT_NEW] = null;
+            ntIdxRaf = null;
+            ntTxtRaf = null;
         }
 
         active = false;
@@ -305,14 +291,21 @@
      * @param name
      *            name of the entry
      * @param testament
-     *            testament number 0, 1 or 2
+     *            the testament for the entry
      * @return the text for the entry.
      * @throws IOException
      *             on a IO problem
      */
-    protected String getEntry(String name, int testament, long index) throws IOException {
-        DataIndex dataIndex = getIndex(idxRaf[testament], index);
+    protected String getEntry(String name, Testament testament, long index) throws IOException {
+        RandomAccessFile idxRaf = otIdxRaf;
+        RandomAccessFile txtRaf = otTxtRaf;
+        if (testament == Testament.OLD) {
+            idxRaf = ntIdxRaf;
+            txtRaf = ntTxtRaf;
+        }
 
+        DataIndex dataIndex = getIndex(idxRaf, index);
+
         int size = dataIndex.getSize();
         if (size == 0) {
             return "";
@@ -323,7 +316,7 @@
             return "";
         }
 
-        byte[] data = SwordUtil.readRAF(txtRaf[testament], dataIndex.getOffset(), size);
+        byte[] data = SwordUtil.readRAF(txtRaf, dataIndex.getOffset(), size);
 
         decipher(data);
 
@@ -345,18 +338,23 @@
      */
     protected int entrysize;
 
-    /**
-     * The log stream
-     */
-    private static final Logger log = Logger.getLogger(RawBackend.class);
+    protected RandomAccessFile otIdxRaf;
+    protected RandomAccessFile otTxtRaf;
+    protected File otIdxFile;
+    protected File otTxtFile;
 
-    protected RandomAccessFile[] idxRaf = new RandomAccessFile[3];
-    protected RandomAccessFile[] txtRaf = new RandomAccessFile[3];
-    protected File[] idxFile = new File[3];
-    protected File[] txtFile = new File[3];
+    protected RandomAccessFile ntIdxRaf;
+    protected RandomAccessFile ntTxtRaf;
+    protected File ntIdxFile;
+    protected File ntTxtFile;
 
     /**
      * How many bytes in the offset pointers in the index
      */
     protected static final int OFFSETSIZE = 4;
+
+    /**
+     * The log stream
+     */
+    private static final Logger log = Logger.getLogger(RawBackend.class);
 }

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-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -28,6 +28,7 @@
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.RandomAccessFile;
 
 import org.crosswire.common.util.Logger;
 import org.crosswire.jsword.book.BookException;
@@ -35,6 +36,7 @@
 import org.crosswire.jsword.passage.KeyUtil;
 import org.crosswire.jsword.passage.Verse;
 import org.crosswire.jsword.versification.BibleInfo;
+import org.crosswire.jsword.versification.Testament;
 
 /**
  * A Raw File format that allows for each verse to have it's own storage.
@@ -56,35 +58,27 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.jsword.book.sword.RawBackend#getRawText(org.crosswire.jsword
-     * .passage.Key)
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.RawBackend#getRawText(org.crosswire.jsword.passage.Key)
      */
     @Override
     public String getRawText(Key key) throws BookException {
         return super.getRawText(key);
     }
 
-    /**
-     * Get the text for an indexed entry in the book.
-     * 
-     * @param name
-     *            name of the entry
-     * @param testament
-     *            testament number 1 or 2
-     * @param index
-     *            the entry to get
-     * @return the text for the entry.
-     * @throws java.io.IOException
-     *             on file error
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.RawBackend#getEntry(java.lang.String, org.crosswire.jsword.versification.Testament, long)
      */
     @Override
-    protected String getEntry(String name, int testament, long index) throws IOException {
+    protected String getEntry(String name, Testament testament, long index) throws IOException {
+        RandomAccessFile idxRaf = otIdxRaf;
+        RandomAccessFile txtRaf = otTxtRaf;
+        if (testament == Testament.OLD) {
+            idxRaf = ntIdxRaf;
+            txtRaf = ntTxtRaf;
+        }
 
-        DataIndex dataIndex = getIndex(idxRaf[testament], index);
+        DataIndex dataIndex = getIndex(idxRaf, index);
         int size = dataIndex.getSize();
         if (size == 0) {
             return "";
@@ -96,7 +90,7 @@
         }
 
         try {
-            File dataFile = getDataTextFile(testament, dataIndex);
+            File dataFile = getDataTextFile(txtRaf, dataIndex);
             byte[] textBytes = readTextDataFile(dataFile);
             decipher(textBytes);
             return SwordUtil.decode(name, textBytes, getBookMetaData().getBookCharset());
@@ -105,23 +99,36 @@
         }
     }
 
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.RawBackend#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
+     */
     @Override
     public void setRawText(Key key, String text) throws BookException, IOException {
         checkActive();
 
         Verse verse = KeyUtil.getVerse(key);
-        int testament = SwordConstants.getTestament(verse);
-        long index = SwordConstants.getIndex(verse);
+        int index = BibleInfo.getOrdinal(verse);
+        Testament testament = BibleInfo.getTestament(index);
+        index = BibleInfo.getTestamentOrdinal(index);
+        RandomAccessFile idxRaf = otIdxRaf;
+        RandomAccessFile txtRaf = otTxtRaf;
+        File txtFile = otTxtFile;
+        if (testament == Testament.NEW) {
+            idxRaf = ntIdxRaf;
+            txtRaf = ntTxtRaf;
+            txtFile = ntTxtFile;
+        }
+
         int oIndex = verse.getOrdinal() - 1;
 
-        DataIndex dataIndex = getIndex(idxRaf[testament], index);
+        DataIndex dataIndex = getIndex(idxRaf, index);
         File dataFile;
         if (dataIndex.getSize() == 0) {
             dataFile = createDataTextFile(oIndex);
-            updateIndexFile(testament, index);
-            updateDataFile(testament, oIndex);
+            updateIndexFile(idxRaf, index, txtRaf.length());
+            updateDataFile(oIndex, txtFile);
         } else {
-            dataFile = getDataTextFile(testament, dataIndex);
+            dataFile = getDataTextFile(txtRaf, dataIndex);
         }
 
         byte[] textData = text.getBytes("UTF-8");
@@ -135,14 +142,23 @@
     public void setAliasKey(Key alias, Key source) throws IOException {
         Verse aliasVerse = KeyUtil.getVerse(alias);
         Verse sourceVerse = KeyUtil.getVerse(source);
-        int testament = SwordConstants.getTestament(aliasVerse);
-        long aliasIndex = SwordConstants.getIndex(aliasVerse);
-        //long sourceIndex = SwordConstants.getIndex(sourceVerse);
+        int aliasIndex = BibleInfo.getOrdinal(aliasVerse);
+        Testament testament = BibleInfo.getTestament(aliasIndex);
+        aliasIndex = BibleInfo.getTestamentOrdinal(aliasIndex);
+        RandomAccessFile idxRaf = otIdxRaf;
+        RandomAccessFile txtRaf = otTxtRaf;
+        File txtFile = otTxtFile;
+        if (testament == Testament.NEW) {
+            idxRaf = ntIdxRaf;
+            txtRaf = ntTxtRaf;
+            txtFile = ntTxtFile;
+        }
+
         int aliasOIndex = aliasVerse.getOrdinal() - 1;
         int sourceOIndex = sourceVerse.getOrdinal() - 1;
 
-        updateIndexFile(testament, aliasIndex);
-        updateDataFile(testament, sourceOIndex);
+        updateIndexFile(idxRaf, aliasIndex, txtRaf.length());
+        updateDataFile(sourceOIndex, txtFile);
 
         checkAndIncrementIncfile(aliasOIndex);
     }
@@ -168,12 +184,11 @@
         return dataFile;
     }
 
-    private File getDataTextFile(int testament, DataIndex dataIndex) throws IOException, BookException {
+    private File getDataTextFile(RandomAccessFile txtRaf, DataIndex dataIndex) throws IOException, BookException {
         File dataFile;
-
         // data size to be read from the data file (ot or nt) should be 9 bytes
         // this will be the filename of the actual text file "\r\n"
-        byte[] data = SwordUtil.readRAF(txtRaf[testament], dataIndex.getOffset(), dataIndex.getSize());
+        byte[] data = SwordUtil.readRAF(txtRaf, dataIndex.getOffset(), dataIndex.getSize());
         decipher(data);
         if (data.length == 7) {
             String dataFilename = new String(data, 0, 7);
@@ -186,9 +201,8 @@
         return dataFile;
     }
 
-    protected void updateIndexFile(int testament, long index) throws IOException {
+    protected void updateIndexFile(RandomAccessFile idxRaf, long index, long dataFileStartPosition) throws IOException {
         long indexFileWriteOffset = index * entrysize;
-        long dataFileStartPosition = txtRaf[testament].length();
         int dataFileLengthValue = 7; // filename is 7 bytes + 2 bytes for "\r\n"
         byte[] startPositionData = littleEndian32BitByteArrayFromInt((int) dataFileStartPosition);
         byte[] lengthValueData = littleEndian16BitByteArrayFromShort((short) dataFileLengthValue);
@@ -201,14 +215,14 @@
         indexFileWriteData[4] = lengthValueData[0];
         indexFileWriteData[5] = lengthValueData[1];
 
-        SwordUtil.writeRAF(idxRaf[testament], indexFileWriteOffset, indexFileWriteData);
+        SwordUtil.writeRAF(idxRaf, indexFileWriteOffset, indexFileWriteData);
     }
 
-    protected void updateDataFile(int testament, long ordinal) throws IOException {
+    protected void updateDataFile(long ordinal, File txtFile) throws IOException {
         String fileName = String.format("%07d\r\n", Long.valueOf(ordinal));
         BufferedOutputStream bos = null;
         try {
-            bos = new BufferedOutputStream(new FileOutputStream(txtFile[testament], true));
+            bos = new BufferedOutputStream(new FileOutputStream(txtFile, true));
             bos.write(fileName.getBytes());
         } finally {
             if (bos != null) {
@@ -242,22 +256,16 @@
         prepopulateIncfile();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.sword.RawBackend#isWritable()
      */
     @Override
     public boolean isWritable() {
-        File otTextFile = txtFile[1];
-        File ntTextFile = txtFile[2];
-        File otIndexFile = idxFile[1];
-        File ntIndexFile = idxFile[2];
         File incFile = this.incfile;
 
-        if (otTextFile.exists() && otTextFile.canRead() && otTextFile.canWrite() && ntTextFile.exists() && ntTextFile.canRead() && ntTextFile.canWrite()
-                && otIndexFile.exists() && otIndexFile.canRead() && otIndexFile.canWrite() && ntIndexFile.exists() && ntIndexFile.canRead()
-                && ntIndexFile.canWrite() && incFile.exists() && incFile.canRead() && incFile.canWrite())
+        if (otTxtFile.exists() && otTxtFile.canRead() && otTxtFile.canWrite() && ntTxtFile.exists() && ntTxtFile.canRead() && ntTxtFile.canWrite()
+                && otIdxFile.exists() && otIdxFile.canRead() && otIdxFile.canWrite() && ntIdxFile.exists() && ntIdxFile.canRead()
+                && ntIdxFile.canWrite() && incFile.exists() && incFile.canRead() && incFile.canWrite())
         {
             return true;
         }
@@ -292,22 +300,20 @@
     }
 
     private void prepopulateIndexFiles() throws IOException {
-        File otIndexFile = idxFile[SwordConstants.TESTAMENT_OLD];
-        BufferedOutputStream otIdxBos = new BufferedOutputStream(new FileOutputStream(otIndexFile, false));
-
+        int otCount = BibleInfo.getCount(Testament.OLD);
+        int ntCount = BibleInfo.getCount(Testament.NEW) + 1;
+        BufferedOutputStream otIdxBos = new BufferedOutputStream(new FileOutputStream(otIdxFile, false));
         try {
-            for (int i = 0; i < SwordConstants.ORDINAL_NT; i++) {
+            for (int i = 0; i < otCount; i++) {
                 writeInitialIndex(otIdxBos);
             }
         } finally {
             otIdxBos.close();
         }
 
-        File ntIndexFile = idxFile[SwordConstants.TESTAMENT_NEW];
-        BufferedOutputStream ntIdxBos = new BufferedOutputStream(new FileOutputStream(ntIndexFile, false));
+        BufferedOutputStream ntIdxBos = new BufferedOutputStream(new FileOutputStream(ntIdxFile, false));
         try {
-            int totVerses = BibleInfo.maximumOrdinal();
-            for (int i = SwordConstants.ORDINAL_NT; i < totVerses; i++) {
+            for (int i = 0; i < ntCount; i++) {
                 writeInitialIndex(ntIdxBos);
             }
         } finally {
@@ -417,9 +423,10 @@
         return buffer;
     }
 
-    private static final Logger log = Logger.getLogger(RawFileBackend.class);
     private static final String INCFILE = "incfile";
 
     private File incfile;
     private int incfileValue;
+
+    private static final Logger log = Logger.getLogger(RawFileBackend.class);
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordConstants.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordConstants.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordConstants.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -21,11 +21,6 @@
  */
 package org.crosswire.jsword.book.sword;
 
-import org.crosswire.jsword.passage.NoSuchVerseException;
-import org.crosswire.jsword.passage.Verse;
-import org.crosswire.jsword.versification.BibleBook;
-import org.crosswire.jsword.versification.BibleInfo;
-
 /**
  * A Constants to help the SwordBookDriver to read Sword format data.
  * 
@@ -82,190 +77,4 @@
      * The configuration directory
      */
     public static final String DIR_CONF = "mods.d";
-
-    /**
-     * constant for the introduction
-     */
-    public static final int TESTAMENT_INTRO = 0;
-
-    /**
-     * constant for the old testament
-     */
-    public static final int TESTAMENT_OLD = 1;
-
-    /**
-     * constant for the new testament
-     */
-    public static final int TESTAMENT_NEW = 2;
-
-    /**
-     * Get the testament of a given verse
-     */
-    public static int getTestament(Verse v) {
-        int ord = v.getOrdinal();
-        if (ord >= SwordConstants.ORDINAL_NT) {
-            // This is an NT verse
-            return SwordConstants.TESTAMENT_NEW;
-        }
-        // This is an OT verse
-        return SwordConstants.TESTAMENT_OLD;
-    }
-
-    /**
-     * Get the sword index of the given verse
-     */
-    static int getIndex(Verse v) {
-        try {
-            return BibleInfo.getTestamentOrdinal(v);
-        } catch (NoSuchVerseException e) {
-            return 0;
-        }
-/*
-        int ord = v.getOrdinal();
-        int book = v.getBook().ordinal();
-        int chapter = v.getChapter();
-        int verse = v.getVerse();
-        int testament = -1;
-
-        if (ord >= SwordConstants.ORDINAL_NT) {
-            // This is an NT verse
-            testament = SwordConstants.TESTAMENT_NEW;
-            book = book - BibleBook.MAL.ordinal();
-        } else {
-            // This is an OT verse
-            testament = SwordConstants.TESTAMENT_OLD;
-            book++;
-        }
-
-        short bookOffset = SwordConstants.bks[testament][book];
-        short chapOffset = SwordConstants.cps[testament][bookOffset + chapter];
-
-        return verse + chapOffset;
-*/
-    }
-
-    /**
-     * The start of the new testament
-     */
-    static int ORDINAL_NT;
-    static {
-        try {
-            ORDINAL_NT = new Verse(BibleBook.INTRO_NT, 0, 0).getOrdinal();
-        } catch (NoSuchVerseException e) {
-            // This must work
-        }
-    }
-
-    /**
-     * array containing LUT of offsets in the chapter table.
-     */
-    private static short[][] bks;
-
-    /**
-     * array containing LUT of positions of initial verses per chapter. This and
-     * all the cps* below were longs and then ints This was an artifact of a
-     * port from C/C++ where int/long vary in size depending on architecture.
-     */
-    private static short[][] cps;
-
-    /**
-     * Initialize our LUTs with data shamelessly stolen from our sister project
-     * (Sword) taken from canon.h.
-     * 
-     * The basic feature of an index is that starting at 4 for Gen 1.1 and Mat
-     * 1.1, increment 1 for each subsequent verse. At a chapter boundary, skip
-     * 1. At a book boundary skip 1 for the book and 1 for the chapter.
-     * 
-     * Book 0.0 gives the index for the book's info. ( == index of Book 1.1 - 2)
-     * Book ch.0 gives the index for the chapter's info in the book. ( == index
-     * of Book 1.1 - 1)
-     * 
-     * There are arrays of data like this in BibleInfo. I guess we could merge
-     * them at some stage.
-     * 
-     * @see org.crosswire.jsword.passage.BibleInfo
-     */
-    static {
-        bks = new short[3][];
-        cps = new short[3][];
-
-        short[] bksot = {
-                0, 1, 52, 93, 121, 158, 193, 218, 240, 245, 277, 302, 325, 351, 381, 418, 429, 443, 454, 497, 648, 680, 693, 702, 769, 822, 828, 877, 890, 905,
-                909, 919, 921, 926, 934, 938, 942, 946, 949, 964,
-        };
-
-        short[] bksnt = {
-                0, 1, 30, 47, 72, 94, 123, 140, 157, 171, 178, 185, 190, 195, 201, 205, 212, 217, 221, 223, 237, 243, 249, 253, 259, 261, 263, 265,
-        };
-
-        bks[SwordConstants.TESTAMENT_OLD] = bksot;
-        bks[SwordConstants.TESTAMENT_NEW] = bksnt;
-
-        short[] cpsot = {
-                0, 2, 3, 35, 61, 86, 113, 146, 169, 194, 217, 247, 280, 313, 334, 353, 378, 400, 417, 445, 479, 518, 537, 572, 597, 618, 686, 721, 757, 804,
-                827, 863, 907, 963, 996, 1017, 1049, 1079, 1123, 1160, 1191, 1215, 1239, 1297, 1336, 1371, 1406, 1435, 1470, 1502, 1525, 1559, 1586, 1587,
-                1610, 1636, 1659, 1691, 1715, 1746, 1772, 1805, 1841, 1871, 1882, 1934, 1957, 1989, 2017, 2054, 2071, 2099, 2125, 2152, 2189, 2221, 2255, 2274,
-                2315, 2353, 2375, 2419, 2466, 2505, 2524, 2560, 2584, 2620, 2656, 2695, 2725, 2757, 2801, 2840, 2841, 2859, 2876, 2894, 2930, 2950, 2981, 3020,
-                3057, 3082, 3103, 3151, 3160, 3220, 3278, 3312, 3347, 3364, 3395, 3433, 3461, 3486, 3520, 3565, 3589, 3645, 3692, 3727, 3728, 3783, 3818, 3870,
-                3920, 3952, 3980, 4070, 4097, 4121, 4158, 4194, 4211, 4245, 4291, 4333, 4384, 4398, 4431, 4454, 4484, 4520, 4562, 4593, 4619, 4638, 4704, 4728,
-                4760, 4801, 4818, 4873, 4916, 4973, 5003, 5038, 5052, 5053, 5100, 5138, 5168, 5218, 5252, 5278, 5305, 5326, 5356, 5379, 5412, 5445, 5464, 5494,
-                5518, 5541, 5562, 5585, 5607, 5628, 5652, 5683, 5709, 5732, 5752, 5772, 5799, 5868, 5898, 5919, 5950, 6003, 6033, 6046, 6047, 6066, 6091, 6109,
-                6134, 6150, 6178, 6205, 6241, 6269, 6313, 6337, 6362, 6396, 6412, 6476, 6487, 6506, 6535, 6587, 6597, 6643, 6678, 6695, 6729, 6730, 6767, 6791,
-                6823, 6848, 6880, 6921, 6947, 6983, 7041, 7060, 7101, 7117, 7143, 7164, 7185, 7217, 7231, 7263, 7294, 7343, 7369, 7370, 7393, 7417, 7436, 7459,
-                7460, 7489, 7526, 7548, 7571, 7584, 7606, 7624, 7647, 7675, 7703, 7719, 7745, 7769, 7822, 7858, 7882, 7941, 7972, 7997, 8040, 8056, 8080, 8110,
-                8133, 8178, 8204, 8217, 8243, 8255, 8287, 8301, 8302, 8330, 8363, 8403, 8416, 8442, 8466, 8496, 8515, 8529, 8549, 8577, 8609, 8649, 8683, 8721,
-                8745, 8775, 8809, 8853, 8880, 8903, 8955, 8995, 9021, 9022, 9076, 9123, 9152, 9187, 9206, 9245, 9297, 9364, 9393, 9423, 9467, 9501, 9536, 9568,
-                9603, 9638, 9663, 9710, 9732, 9776, 9806, 9860, 9861, 9880, 9906, 9934, 9979, 10007, 10041, 10062, 10092, 10130, 10167, 10189, 10211, 10237,
-                10267, 10306, 10327, 10369, 10407, 10445, 10467, 10494, 10515, 10553, 10574, 10605, 10606, 10661, 10717, 10742, 10786, 10813, 10895, 10936,
-                10977, 11022, 11037, 11085, 11126, 11141, 11159, 11189, 11233, 11261, 11279, 11299, 11308, 11339, 11359, 11392, 11424, 11456, 11489, 11524,
-                11546, 11577, 11578, 11596, 11615, 11633, 11656, 11671, 11714, 11737, 11756, 11788, 11808, 11832, 11849, 11872, 11888, 11908, 11923, 11943,
-                11978, 11990, 12028, 12049, 12062, 12084, 12112, 12141, 12165, 12175, 12203, 12240, 12268, 12290, 12324, 12350, 12384, 12412, 12436, 12437,
-                12449, 12520, 12534, 12559, 12577, 12600, 12629, 12666, 12682, 12727, 12728, 12740, 12761, 12794, 12818, 12838, 12858, 12932, 12951, 12990,
-                13030, 13067, 13115, 13147, 13148, 13171, 13195, 13211, 13229, 13244, 13259, 13270, 13288, 13321, 13325, 13326, 13349, 13363, 13390, 13412,
-                13440, 13471, 13493, 13516, 13552, 13575, 13596, 13622, 13651, 13674, 13710, 13733, 13750, 13772, 13802, 13832, 13867, 13898, 13916, 13942,
-                13949, 13964, 13988, 14017, 14043, 14075, 14116, 14139, 14173, 14211, 14228, 14262, 14287, 14329, 14360, 14385, 14420, 14438, 14439, 14446,
-                14459, 14468, 14477, 14490, 14501, 14519, 14529, 14550, 14569, 14577, 14586, 14593, 14601, 14607, 14619, 14635, 14686, 14701, 14711, 14725,
-                14757, 14764, 14775, 14798, 14811, 14826, 14836, 14848, 14861, 14886, 14898, 14921, 14944, 14973, 14986, 15027, 15050, 15064, 15082, 15096,
-                15108, 15114, 15141, 15159, 15171, 15181, 15196, 15217, 15241, 15261, 15271, 15278, 15286, 15310, 15324, 15336, 15348, 15366, 15379, 15388,
-                15401, 15413, 15424, 15438, 15459, 15467, 15503, 15540, 15546, 15571, 15592, 15621, 15645, 15656, 15669, 15690, 15763, 15777, 15797, 15814,
-                15823, 15842, 15855, 15869, 15887, 15895, 15914, 15967, 15985, 16002, 16018, 16024, 16048, 16060, 16074, 16087, 16097, 16107, 16113, 16122,
-                16151, 16174, 16210, 16256, 16305, 16349, 16363, 16395, 16403, 16414, 16425, 16435, 16444, 16463, 16483, 16486, 16516, 16693, 16701, 16710,
-                16720, 16725, 16734, 16740, 16747, 16753, 16760, 16769, 16778, 16782, 16801, 16805, 16809, 16831, 16858, 16868, 16877, 16902, 16916, 16927,
-                16935, 16948, 16964, 16986, 16997, 17018, 17033, 17043, 17050, 17051, 17085, 17108, 17144, 17172, 17196, 17232, 17260, 17297, 17316, 17349,
-                17381, 17410, 17436, 17472, 17506, 17540, 17569, 17594, 17624, 17655, 17687, 17717, 17753, 17788, 17817, 17846, 17874, 17903, 17931, 17965,
-                17997, 17998, 18017, 18044, 18067, 18084, 18105, 18118, 18148, 18166, 18185, 18206, 18217, 18232, 18233, 18251, 18269, 18281, 18298, 18315,
-                18329, 18343, 18358, 18359, 18391, 18414, 18441, 18448, 18479, 18493, 18519, 18542, 18564, 18599, 18616, 18623, 18646, 18679, 18689, 18704,
-                18719, 18727, 18753, 18760, 18778, 18804, 18823, 18847, 18860, 18882, 18896, 18926, 18951, 18985, 18995, 19016, 19041, 19059, 19070, 19093,
-                19132, 19155, 19164, 19196, 19226, 19252, 19281, 19310, 19336, 19350, 19366, 19389, 19416, 19428, 19452, 19468, 19481, 19499, 19513, 19526,
-                19548, 19563, 19585, 19608, 19620, 19633, 19653, 19666, 19692, 19717, 19718, 19738, 19776, 19802, 19834, 19866, 19897, 19932, 19955, 19982,
-                20008, 20032, 20050, 20078, 20101, 20123, 20145, 20173, 20197, 20213, 20232, 20247, 20278, 20319, 20330, 20369, 20394, 20417, 20435, 20468,
-                20493, 20534, 20579, 20606, 20629, 20649, 20682, 20704, 20733, 20752, 20769, 20788, 20811, 20825, 20856, 20862, 20891, 20899, 20947, 20987,
-                21034, 21099, 21134, 21135, 21158, 21181, 21248, 21271, 21294, 21295, 21324, 21335, 21363, 21381, 21399, 21414, 21442, 21461, 21473, 21496,
-                21522, 21551, 21575, 21599, 21608, 21672, 21697, 21730, 21745, 21795, 21828, 21860, 21910, 21938, 21956, 21978, 22015, 22042, 22064, 22091,
-                22110, 22143, 22177, 22209, 22225, 22264, 22293, 22317, 22347, 22397, 22424, 22445, 22473, 22505, 22531, 22556, 22580, 22616, 22617, 22639,
-                22689, 22720, 22758, 22790, 22819, 22848, 22876, 22904, 22926, 22972, 22986, 22987, 22999, 23023, 23029, 23049, 23065, 23077, 23094, 23109,
-                23127, 23143, 23156, 23171, 23188, 23198, 23199, 23220, 23253, 23275, 23276, 23292, 23309, 23325, 23339, 23367, 23382, 23400, 23415, 23431,
-                23432, 23454, 23455, 23473, 23484, 23495, 23507, 23508, 23525, 23539, 23552, 23566, 23582, 23599, 23620, 23621, 23637, 23651, 23671, 23672,
-                23690, 23711, 23731, 23732, 23751, 23767, 23788, 23789, 23805, 23829, 23830, 23852, 23866, 23877, 23892, 23904, 23920, 23935, 23959, 23977,
-                23990, 24008, 24023, 24033, 24055, 24056, 24071, 24089, 24108,
-        };
-
-        short[] cpsnt = {
-                0, 2, 3, 29, 53, 71, 97, 146, 181, 211, 246, 285, 328, 359, 410, 469, 506, 546, 575, 603, 639, 670, 705, 752, 799, 839, 891, 938, 1014, 1081,
-                1102, 1103, 1149, 1178, 1214, 1256, 1300, 1357, 1395, 1434, 1485, 1538, 1572, 1617, 1655, 1728, 1776, 1797, 1798, 1879, 1932, 1971, 2016, 2056,
-                2106, 2157, 2214, 2277, 2320, 2375, 2435, 2471, 2507, 2540, 2572, 2610, 2654, 2703, 2751, 2790, 2862, 2919, 2973, 2974, 3026, 3052, 3089, 3144,
-                3192, 3264, 3318, 3378, 3420, 3463, 3521, 3572, 3611, 3643, 3671, 3705, 3732, 3773, 3816, 3848, 3874, 3875, 3902, 3950, 3977, 4015, 4058, 4074,
-                4135, 4176, 4220, 4269, 4300, 4326, 4379, 4408, 4450, 4491, 4526, 4555, 4597, 4636, 4677, 4708, 4744, 4772, 4800, 4833, 4878, 4910, 4911, 4944,
-                4974, 5006, 5032, 5054, 5078, 5104, 5144, 5178, 5200, 5237, 5259, 5274, 5298, 5332, 5360, 5361, 5393, 5410, 5434, 5456, 5470, 5491, 5532, 5546,
-                5574, 5608, 5643, 5675, 5689, 5730, 5789, 5814, 5815, 5840, 5858, 5877, 5896, 5918, 5937, 5954, 5979, 5995, 6014, 6048, 6070, 6085, 6086, 6111,
-                6133, 6163, 6195, 6222, 6241, 6242, 6266, 6289, 6311, 6344, 6378, 6403, 6404, 6435, 6466, 6488, 6512, 6513, 6543, 6567, 6593, 6612, 6613, 6624,
-                6645, 6659, 6678, 6707, 6708, 6721, 6739, 6758, 6759, 6780, 6796, 6813, 6830, 6856, 6878, 6879, 6898, 6925, 6943, 6966, 6967, 6984, 7000, 7016,
-                7017, 7043, 7044, 7059, 7078, 7098, 7115, 7130, 7151, 7180, 7194, 7223, 7263, 7304, 7334, 7360, 7361, 7389, 7416, 7435, 7453, 7474, 7475, 7501,
-                7527, 7550, 7570, 7585, 7586, 7608, 7631, 7650, 7651, 7662, 7692, 7717, 7739, 7761, 7762, 7776, 7777, 7792, 7793, 7819, 7820, 7841, 7871, 7894,
-                7906, 7921, 7939, 7957, 7971, 7993, 8005, 8025, 8043, 8062, 8083, 8092, 8114, 8133, 8158, 8180, 8196, 8224,
-        };
-
-        cps[SwordConstants.TESTAMENT_OLD] = cpsot;
-        cps[SwordConstants.TESTAMENT_NEW] = cpsnt;
-    }
 }

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-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -39,6 +39,8 @@
 import org.crosswire.jsword.passage.Key;
 import org.crosswire.jsword.passage.KeyUtil;
 import org.crosswire.jsword.passage.Verse;
+import org.crosswire.jsword.versification.BibleInfo;
+import org.crosswire.jsword.versification.Testament;
 
 /**
  * A backend to read compressed data verse based files. While the text file
@@ -95,12 +97,9 @@
  * in the text file seek to the text-block-index
  * read data-size bytes
  * decipher them if they are encrypted
- * unGZIP them into a byte array of uncompressed-size
+ * unGZIP them into a byte uncompressed-size
  * </pre>
  * 
- * TODO(DM): Testament 0 is used to index an README file for the bible. At this
- * time it is ignored.
- * 
  * @see gnu.lgpl.License for license details.<br>
  *      The copyright to this program is held by it's authors.
  * @author Joe Walker [joe at eireneh dot com]
@@ -119,117 +118,103 @@
         this.blockType = blockType;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.common.activate.Activatable#activate(org.crosswire.common
-     * .activate.Lock)
+    /* (non-Javadoc)
+     * @see org.crosswire.common.activate.Activatable#activate(org.crosswire.common.activate.Lock)
      */
     public final void activate(Lock lock) {
         try {
-            if (idxFile[SwordConstants.TESTAMENT_OLD] == null) {
+            if (otIdxFile == null) {
                 URI path = getExpandedDataPath();
-                String otAllButLast = NetUtil.lengthenURI(path, File.separator + SwordConstants.FILE_OT + '.' + blockType.getIndicator() + SUFFIX_PART1)
-                        .getPath();
-                idxFile[SwordConstants.TESTAMENT_OLD] = new File(otAllButLast + SUFFIX_INDEX);
-                textFile[SwordConstants.TESTAMENT_OLD] = new File(otAllButLast + SUFFIX_TEXT);
-                compFile[SwordConstants.TESTAMENT_OLD] = new File(otAllButLast + SUFFIX_COMP);
+                String otAllButLast = NetUtil.lengthenURI(path, File.separator + SwordConstants.FILE_OT + '.' + blockType.getIndicator() + SUFFIX_PART1).getPath();
+                otIdxFile = new File(otAllButLast + SUFFIX_INDEX);
+                otTextFile = new File(otAllButLast + SUFFIX_TEXT);
+                otCompFile = new File(otAllButLast + SUFFIX_COMP);
 
-                String ntAllButLast = NetUtil.lengthenURI(path, File.separator + SwordConstants.FILE_NT + '.' + blockType.getIndicator() + SUFFIX_PART1)
-                        .getPath();
-                idxFile[SwordConstants.TESTAMENT_NEW] = new File(ntAllButLast + SUFFIX_INDEX);
-                textFile[SwordConstants.TESTAMENT_NEW] = new File(ntAllButLast + SUFFIX_TEXT);
-                compFile[SwordConstants.TESTAMENT_NEW] = new File(ntAllButLast + SUFFIX_COMP);
+                String ntAllButLast = NetUtil.lengthenURI(path, File.separator + SwordConstants.FILE_NT + '.' + blockType.getIndicator() + SUFFIX_PART1).getPath();
+                ntIdxFile = new File(ntAllButLast + SUFFIX_INDEX);
+                ntTextFile = new File(ntAllButLast + SUFFIX_TEXT);
+                ntCompFile = new File(ntAllButLast + SUFFIX_COMP);
             }
         } catch (BookException e) {
-            idxFile[SwordConstants.TESTAMENT_OLD] = null;
-            textFile[SwordConstants.TESTAMENT_OLD] = null;
-            compFile[SwordConstants.TESTAMENT_OLD] = null;
+            otIdxFile = null;
+            otTextFile = null;
+            otCompFile = null;
 
-            idxFile[SwordConstants.TESTAMENT_NEW] = null;
-            textFile[SwordConstants.TESTAMENT_NEW] = null;
-            compFile[SwordConstants.TESTAMENT_NEW] = null;
+            ntIdxFile = null;
+            ntTextFile = null;
+            ntCompFile = null;
 
             return;
         }
 
-        if (idxFile[SwordConstants.TESTAMENT_OLD].canRead()) {
+        if (otIdxFile.canRead()) {
             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);
+                otIdxRaf = new RandomAccessFile(otIdxFile, FileUtil.MODE_READ);
+                otTextRaf = new RandomAccessFile(otTextFile, FileUtil.MODE_READ);
+                otCompRaf = new RandomAccessFile(otCompFile, FileUtil.MODE_READ);
             } catch (FileNotFoundException ex) {
                 assert false : ex;
                 log.error("Could not open OT", ex);
-                idxRaf[SwordConstants.TESTAMENT_OLD] = null;
-                textRaf[SwordConstants.TESTAMENT_OLD] = null;
-                compRaf[SwordConstants.TESTAMENT_OLD] = null;
+                otIdxRaf = null;
+                otTextRaf = null;
+                otCompRaf = null;
             }
         }
 
-        if (idxFile[SwordConstants.TESTAMENT_NEW].canRead()) {
+        if (ntIdxFile.canRead()) {
             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);
+                ntIdxRaf = new RandomAccessFile(ntIdxFile, FileUtil.MODE_READ);
+                ntTextRaf = new RandomAccessFile(ntTextFile, FileUtil.MODE_READ);
+                ntCompRaf = new RandomAccessFile(ntCompFile, FileUtil.MODE_READ);
             } catch (FileNotFoundException ex) {
                 assert false : ex;
                 log.error("Could not open NT", ex);
-                idxRaf[SwordConstants.TESTAMENT_NEW] = null;
-                textRaf[SwordConstants.TESTAMENT_NEW] = null;
-                compRaf[SwordConstants.TESTAMENT_NEW] = null;
+                ntIdxRaf = null;
+                ntTextRaf = null;
+                ntCompRaf = null;
             }
         }
 
         active = true;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.common.activate.Activatable#deactivate(org.crosswire.common
-     * .activate.Lock)
+    /* (non-Javadoc)
+     * @see org.crosswire.common.activate.Activatable#deactivate(org.crosswire.common.activate.Lock)
      */
     public final void deactivate(Lock lock) {
-        if (idxRaf[SwordConstants.TESTAMENT_NEW] != null) {
+        if (ntIdxRaf != null) {
             try {
-                idxRaf[SwordConstants.TESTAMENT_NEW].close();
-                textRaf[SwordConstants.TESTAMENT_NEW].close();
-                compRaf[SwordConstants.TESTAMENT_NEW].close();
+                ntIdxRaf.close();
+                ntTextRaf.close();
+                ntCompRaf.close();
             } catch (IOException ex) {
                 log.error("failed to close nt files", ex);
             } finally {
-                idxRaf[SwordConstants.TESTAMENT_NEW] = null;
-                textRaf[SwordConstants.TESTAMENT_NEW] = null;
-                compRaf[SwordConstants.TESTAMENT_NEW] = null;
+                ntIdxRaf = null;
+                ntTextRaf = null;
+                ntCompRaf = null;
             }
         }
 
-        if (idxRaf[SwordConstants.TESTAMENT_OLD] != null) {
+        if (otIdxRaf != null) {
             try {
-                idxRaf[SwordConstants.TESTAMENT_OLD].close();
-                textRaf[SwordConstants.TESTAMENT_OLD].close();
-                compRaf[SwordConstants.TESTAMENT_OLD].close();
+                otIdxRaf.close();
+                otTextRaf.close();
+                otCompRaf.close();
             } catch (IOException ex) {
                 log.error("failed to close ot files", ex);
             } finally {
-                idxRaf[SwordConstants.TESTAMENT_OLD] = null;
-                textRaf[SwordConstants.TESTAMENT_OLD] = null;
-                compRaf[SwordConstants.TESTAMENT_OLD] = null;
+                otIdxRaf = null;
+                otTextRaf = null;
+                otCompRaf = null;
             }
         }
 
         active = false;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage
-     * .Key)
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.AbstractBackend#contains(org.crosswire.jsword.passage.Key)
      */
     @Override
     public boolean contains(Key key) {
@@ -239,16 +224,21 @@
             Verse verse = KeyUtil.getVerse(key);
 
             try {
-                int testament = SwordConstants.getTestament(verse);
-                long index = SwordConstants.getIndex(verse);
+                int index = BibleInfo.getOrdinal(verse);
+                Testament testament = BibleInfo.getTestament(index);
+                index = BibleInfo.getTestamentOrdinal(index);
+                RandomAccessFile compRaf = otCompRaf;
+                if (testament == Testament.NEW) {
+                    compRaf = ntCompRaf;
+                }
 
                 // If Bible does not contain the desired testament, then false
-                if (compRaf[testament] == null) {
+                if (compRaf == null) {
                     return false;
                 }
 
                 // 10 because the index is 10 bytes long for each verse
-                byte[] temp = SwordUtil.readRAF(compRaf[testament], index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
+                byte[] temp = SwordUtil.readRAF(compRaf, index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
 
                 // If the Bible does not contain the desired verse, return
                 // nothing.
@@ -274,12 +264,8 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire
-     * .jsword.passage.Key, java.lang.String)
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire.jsword.passage.Key)
      */
     @Override
     public String getRawText(Key key) throws BookException {
@@ -294,17 +280,26 @@
             Verse verse = KeyUtil.getVerse(key);
 
             try {
-                int testament = SwordConstants.getTestament(verse);
-                long index = SwordConstants.getIndex(verse);
+                int index = BibleInfo.getOrdinal(verse);
+                Testament testament = BibleInfo.getTestament(index);
+                index = BibleInfo.getTestamentOrdinal(index);
+                RandomAccessFile compRaf = otCompRaf;
+                RandomAccessFile idxRaf = otIdxRaf;
+                RandomAccessFile textRaf = otTextRaf;
+                if (testament == Testament.NEW) {
+                    compRaf = ntCompRaf;
+                    idxRaf = ntIdxRaf;
+                    textRaf = ntTextRaf;
+                }
 
                 // If Bible does not contain the desired testament, return
                 // nothing.
-                if (compRaf[testament] == null) {
+                if (compRaf == null) {
                     return "";
                 }
 
                 // 10 because the index is 10 bytes long for each verse
-                byte[] temp = SwordUtil.readRAF(compRaf[testament], index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
+                byte[] temp = SwordUtil.readRAF(compRaf, index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
 
                 // If the Bible does not contain the desired verse, return
                 // nothing.
@@ -328,7 +323,7 @@
                     uncompressed = lastUncompressed;
                 } else {
                     // Then seek using this index into the idx file
-                    temp = SwordUtil.readRAF(idxRaf[testament], blockNum * IDX_ENTRY_SIZE, IDX_ENTRY_SIZE);
+                    temp = SwordUtil.readRAF(idxRaf, blockNum * IDX_ENTRY_SIZE, IDX_ENTRY_SIZE);
                     if (temp == null || temp.length == 0) {
                         return "";
                     }
@@ -338,7 +333,7 @@
                     int uncompressedSize = SwordUtil.decodeLittleEndian32(temp, 8);
 
                     // Read from the data file.
-                    byte[] data = SwordUtil.readRAF(textRaf[testament], blockStart, blockSize);
+                    byte[] data = SwordUtil.readRAF(textRaf, blockStart, blockSize);
 
                     decipher(data);
 
@@ -398,7 +393,7 @@
     /**
      *
      */
-    private int lastTestament = -1;
+    private Testament lastTestament;
 
     /**
      *
@@ -416,41 +411,42 @@
     private boolean active;
 
     /**
-     * The log stream
+     * The index random access files
      */
-    private static final Logger log = Logger.getLogger(ZVerseBackend.class);
+    private RandomAccessFile otIdxRaf;
+    private RandomAccessFile ntIdxRaf;
 
     /**
-     * The array of index random access files
+     * The data random access files
      */
-    private RandomAccessFile[] idxRaf = new RandomAccessFile[3];
+    private RandomAccessFile otTextRaf;
+    private RandomAccessFile ntTextRaf;
 
     /**
-     * The array of data random access files
+     * The compressed random access files
      */
-    private RandomAccessFile[] textRaf = new RandomAccessFile[3];
+    private RandomAccessFile otCompRaf;
+    private RandomAccessFile ntCompRaf;
 
     /**
-     * The array of compressed random access files
+     * The index random access files
      */
-    private RandomAccessFile[] compRaf = new RandomAccessFile[3];
+    private File otIdxFile;
+    private File ntIdxFile;
 
     /**
-     * The array of index random access files
+     * The data random access files
      */
-    private File[] idxFile = new File[3];
+    private File otTextFile;
+    private File ntTextFile;
 
     /**
-     * The array of data random access files
+     * The compressed random access files
      */
-    private File[] textFile = new File[3];
+    private File otCompFile;
+    private File ntCompFile;
 
     /**
-     * The array of compressed random access files
-     */
-    private File[] compFile = new File[3];
-
-    /**
      * How many bytes in the comp index?
      */
     private static final int COMP_ENTRY_SIZE = 10;
@@ -459,4 +455,9 @@
      * How many bytes in the idx index?
      */
     private static final int IDX_ENTRY_SIZE = 12;
+
+    /**
+     * The log stream
+     */
+    private static final Logger log = Logger.getLogger(ZVerseBackend.class);
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -102,29 +102,24 @@
 
         @Override
         public VerseRange blur(Verse verse, int blurDown, int blurUp) {
-            try {
-                int verseNumber = verse.getVerse();
+            int verseNumber = verse.getVerse();
 
-                int down = verseNumber - Math.max(verseNumber - blurDown, 1);
+            int down = verseNumber - Math.max(verseNumber - blurDown, 1);
 
-                Verse start = verse;
-                if (down > 0) {
-                    start = verse.subtract(down);
-                }
+            Verse start = verse;
+            if (down > 0) {
+                start = verse.subtract(down);
+            }
 
-                BibleBook book = verse.getBook();
-                int chapterNumber = verse.getChapter();
-                int up = Math.min(verseNumber + blurUp, BibleInfo.versesInChapter(book, chapterNumber)) - verseNumber;
-                Verse end = verse;
-                if (up > 0) {
-                    end = verse.add(up);
-                }
-
-                return new VerseRange(start, end);
-            } catch (NoSuchVerseException ex) {
-                assert false : ex;
-                return null;
+            BibleBook book = verse.getBook();
+            int chapterNumber = verse.getChapter();
+            int up = Math.min(verseNumber + blurUp, BibleInfo.versesInChapter(book, chapterNumber)) - verseNumber;
+            Verse end = verse;
+            if (up > 0) {
+                end = verse.add(up);
             }
+
+            return new VerseRange(start, end);
         }
 
         @Override

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -28,7 +28,6 @@
 
 import org.crosswire.common.icu.NumberShaper;
 import org.crosswire.common.util.ItemIterator;
-import org.crosswire.common.util.Logger;
 import org.crosswire.jsword.JSMsg;
 import org.crosswire.jsword.JSOtherMsg;
 import org.crosswire.jsword.versification.BibleBook;
@@ -388,12 +387,7 @@
      * @return true or false ...
      */
     public boolean isEndOfChapter() {
-        try {
-            return verse == BibleInfo.versesInChapter(book, chapter);
-        } catch (NoSuchVerseException ex) {
-            assert false : ex;
-            return true;
-        }
+        return verse == BibleInfo.versesInChapter(book, chapter);
     }
 
     /**
@@ -411,12 +405,7 @@
      * @return true or false ...
      */
     public boolean isEndOfBook() {
-        try {
-            return verse == BibleInfo.versesInChapter(book, chapter) && chapter == BibleInfo.chaptersInBook(book);
-        } catch (NoSuchVerseException ex) {
-            assert false : ex;
-            return true;
-        }
+        return verse == BibleInfo.versesInChapter(book, chapter) && chapter == BibleInfo.chaptersInBook(book);
     }
 
     /**
@@ -448,14 +437,7 @@
      * @return The verse number
      */
     public int getOrdinal() {
-        try {
-            return BibleInfo.getOrdinal(this);
-        } catch (NoSuchVerseException ex) {
-            // A verse should never be illegal so
-            log.error("ref=" + book + ", " + chapter + ", " + verse);
-            assert false : ex;
-            return 1;
-        }
+        return BibleInfo.getOrdinal(this);
     }
 
     /**
@@ -892,8 +874,4 @@
      */
     private transient String originalName;
 
-    /**
-     * The log stream
-     */
-    private static final Logger log = Logger.getLogger(Verse.class);
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -344,19 +344,14 @@
             return endChap - startChap + 1;
         }
 
-        try {
-            // So we are going to have to count up chapters from start to end
-            int total = BibleInfo.chaptersInBook(startBook) - startChap;
-            for (BibleBook b : EnumSet.range(BibleInfo.getNextBook(startBook), BibleInfo.getPreviousBook(endBook))) {
-                total += BibleInfo.chaptersInBook(b);
-            }
-            total += endChap;
-
-            return total;
-        } catch (NoSuchVerseException ex) {
-            assert false : ex;
-            return 1;
+        // So we are going to have to count up chapters from start to end
+        int total = BibleInfo.chaptersInBook(startBook) - startChap;
+        for (BibleBook b : EnumSet.range(BibleInfo.getNextBook(startBook), BibleInfo.getPreviousBook(endBook))) {
+            total += BibleInfo.chaptersInBook(b);
         }
+        total += endChap;
+
+        return total;
     }
 
     /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleBook.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleBook.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -1,3 +1,24 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005 - 2012
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id$
+ */
 package org.crosswire.jsword.versification;
 
 import java.util.HashMap;

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -14,7 +14,7 @@
  *      59 Temple Place - Suite 330
  *      Boston, MA 02111-1307, USA
  *
- * Copyright: 2005
+ * Copyright: 2005 - 2012
  *     The copyright to this program is held by it's authors.
  *
  * ID: $Id$
@@ -44,6 +44,16 @@
  */
 public final class BibleInfo {
     /**
+     * constant for the old testament
+     */
+    public static final int TESTAMENT_OLD = 0;
+
+    /**
+     * constant for the new testament
+     */
+    public static final int TESTAMENT_NEW = 1;
+
+    /**
      * Ensure that we can not be instantiated
      */
     private BibleInfo() {
@@ -83,10 +93,8 @@
      * @param book
      *            The book part of the reference.
      * @return The last valid chapter number for a book.
-     * @exception NoSuchVerseException
-     *                If the book is not valid
      */
-    public static int chaptersInBook(BibleBook book) throws NoSuchVerseException {
+    public static int chaptersInBook(BibleBook book) {
         // This is faster than doing the check explicitly, unless
         // The exception is actually thrown, then it is a lot slower
         // I'd like to think that the norm is to get it right
@@ -107,10 +115,9 @@
      * @param chapter
      *            The current chapter
      * @return The last valid verse number for a chapter
-     * @exception NoSuchVerseException
      *                If the book or chapter number is not valid
      */
-    public static int versesInChapter(BibleBook book, int chapter) throws NoSuchVerseException {
+    public static int versesInChapter(BibleBook book, int chapter) {
         // This is faster than doing the check explicitly, unless
         // The exception is actually thrown, then it is a lot slower
         // I'd like to think that the norm is to get it right
@@ -159,15 +166,9 @@
      * @param verse
      *            The verse to convert
      * @return The ordinal number of verses
-     * @exception NoSuchVerseException
-     *                If the reference is illegal
      */
-    public static int getOrdinal(Verse verse) throws NoSuchVerseException {
-        BibleBook b = verse.getBook();
-        int c = verse.getChapter();
-        int v = verse.getVerse();
-        validate(b, c, v);
-        return ORDINAL_AT_START_OF_CHAPTER[b.ordinal()][c] + v;
+    public static int getOrdinal(Verse verse) {
+        return ORDINAL_AT_START_OF_CHAPTER[verse.getBook().ordinal()][verse.getChapter()] + verse.getVerse();
     }
 
     /**
@@ -195,22 +196,47 @@
      * @param verse
      *            The verse to convert
      * @return The ordinal number of verses
-     * @exception NoSuchVerseException
-     *                If the reference is illegal
      */
-    public static int getTestamentOrdinal(Verse verse) throws NoSuchVerseException {
-        BibleBook b = verse.getBook();
-        int c = verse.getChapter();
-        int v = verse.getVerse();
-        validate(b, c, v);
-        int ordinal = ORDINAL_AT_START_OF_CHAPTER[b.ordinal()][c] + v;
-        if (ordinal >= NT_ORDINAL_START) {
-            return ordinal - NT_ORDINAL_START + 1;
+    public static int getTestamentOrdinal(int ordinal) {
+        int nt_ordinal = ORDINAL_AT_START_OF_CHAPTER[BibleBook.INTRO_NT.ordinal()][0];
+        if (ordinal >= nt_ordinal) {
+            return ordinal - nt_ordinal + 1;
         }
         return ordinal;
     }
 
     /**
+     * Get the testament of a given verse
+     */
+    public static Testament getTestament(int ordinal) {
+        if (ordinal >= ORDINAL_AT_START_OF_CHAPTER[BibleBook.INTRO_NT.ordinal()][0]) {
+            // This is an NT verse
+            return Testament.NEW;
+        }
+        // This is an OT verse
+        return Testament.OLD;
+    }
+
+    /**
+     * Give the count of verses in the testament or the whole Bible.
+     * 
+     * @param testament The testament to count. If null, then all testaments.
+     * @return the number of verses in the testament
+     */
+    public static int getCount(Testament testament) {
+        // The sentinel give the total verses in the Bible
+        int total = ORDINAL_AT_START_OF_CHAPTER[ORDINAL_AT_START_OF_CHAPTER.length - 1][0];
+        if (testament == null) {
+            return total;
+        }
+        // The ordinal for the NT Intro is the count of the OT verses
+        int otCount = ORDINAL_AT_START_OF_CHAPTER[BibleBook.INTRO_NT.ordinal()][0];
+        if (testament == Testament.OLD) {
+            return otCount;
+        }
+        return total - otCount;
+    }
+    /**
      * Where does this verse come in the Bible. This will unwind the value returned by getOrdinal(Verse).
      * 
      * @param ordinal
@@ -259,7 +285,7 @@
 
         // There is a gap for the New Testament introduction.
         // This occurs when ordinal is one less than the book introduction of the next book.
-        if (bookIndex == OT_LAST_BOOK && ordinal == ORDINAL_AT_START_OF_CHAPTER[bookIndex + 1][0] - 1) {
+        if (bookIndex == BibleBook.INTRO_NT.ordinal() - 1 && ordinal == ORDINAL_AT_START_OF_CHAPTER[bookIndex + 1][0] - 1) {
             bookIndex++;
         }
 
@@ -872,9 +898,7 @@
         },
     };
 
-    private static final int OT_LAST_BOOK = 38;
     private static final int NT_ORDINAL_START = 24115;
-    private static final int NT_BOOK_START = 39;
 
     /**
      * A singleton used to do initialization. Could be used to change static

Added: trunk/jsword/src/main/java/org/crosswire/jsword/versification/Testament.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/Testament.java	                        (rev 0)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/Testament.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -0,0 +1,34 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005 - 2012
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id$
+ */
+package org.crosswire.jsword.versification;
+
+/**
+ * Testament is either OLD or NEW. All BibleBooks belong to one or the other, even if deuterocanonical.
+ * 
+ * @see gnu.lgpl.License for license details.<br>
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public enum Testament {
+    OLD,
+    NEW;
+}


Property changes on: trunk/jsword/src/main/java/org/crosswire/jsword/versification/Testament.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/BibleInfoTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/BibleInfoTest.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/BibleInfoTest.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -176,7 +176,7 @@
     }
 
     public void testOrdinal() throws Exception {
-        int first_verse_ord = 2;
+        int first_verse_ord = 1;
         int last_verse_ord = 1;
         // for (BibleBook b : BibleBook.values()) {
         for (BibleBook b: EnumSet.range(BibleBook.GEN, BibleBook.MAL)) {
@@ -199,7 +199,7 @@
 
                     Verse bclast = new Verse(b, c, BibleInfo.versesInChapter(b, c));
                     assertEquals(bclast.getName(), last_verse_ord, BibleInfo.getOrdinal(bclast));
-                    assertEquals(bclast.getName(), bclast, BibleInfo.decodeOrdinal(last_verse_ord));
+//                    assertEquals(bclast.getName(), bclast, BibleInfo.decodeOrdinal(last_verse_ord));
                 }
                 first_verse_ord += BibleInfo.versesInChapter(b, c);
             }
@@ -219,7 +219,7 @@
                 assertEquals(new Verse(b, c, 0), BibleInfo.decodeOrdinal(first_verse_ord));
                 assertEquals(new Verse(b, c, 1), BibleInfo.decodeOrdinal(first_verse_ord + 1));
                 assertEquals(new Verse(b, c, 2), BibleInfo.decodeOrdinal(first_verse_ord + 2));
-//                assertEquals(new Verse(b, c, BibleInfo.versesInChapter(b, c)), BibleInfo.decodeOrdinal(last_verse_ord));
+                assertEquals(new Verse(b, c, BibleInfo.versesInChapter(b, c)), BibleInfo.decodeOrdinal(last_verse_ord));
 
                 first_verse_ord += BibleInfo.versesInChapter(b, c);
             }
@@ -227,11 +227,6 @@
     }
 
     public void testValidate() throws Exception {
-        try {
-            BibleInfo.validate(null, 1, 1);
-            fail();
-        } catch (NoSuchVerseException ex) {
-        }
         // for (BibleBook b : BibleBook.values()) {
         for (BibleBook b: EnumSet.range(BibleBook.GEN, BibleBook.REV)) {
             try {
@@ -255,17 +250,6 @@
                 } catch (NoSuchVerseException ex) {
                 }
             }
-
-            try {
-                BibleInfo.validate(null, BibleInfo.chaptersInBook(b) + 1, 1);
-                fail();
-            } catch (NoSuchVerseException ex) {
-            }
-            try {
-                BibleInfo.validate(null, 1, 9999);
-                fail();
-            } catch (NoSuchVerseException ex) {
-            }
         }
     }
 
@@ -279,9 +263,9 @@
                 for (int v = 1; v <= vic; v++) {
                     Verse pv = BibleInfo.patch(BibleBook.GEN, 1, all);
 
-                    assertEquals(b, pv.getBook());
-                    assertEquals(c, pv.getChapter());
-                    assertEquals(v, pv.getVerse());
+                    assertEquals(pv.getName(), b, pv.getBook());
+                    assertEquals(pv.getName(), c, pv.getChapter());
+                    assertEquals(pv.getName(), v, pv.getVerse());
                     all++;
                 }
             }
@@ -302,7 +286,6 @@
         int count_down = BibleInfo.maximumOrdinal();
         Verse gen00 = new Verse(BibleBook.GEN, 0, 0);
         Verse gen110 = new Verse(BibleBook.GEN, 1, 10);
-        Verse exo11 = new Verse(BibleBook.EXOD, 1, 1);
         Verse rev99 = new Verse(BibleBook.REV, 22, 21);
         assertEquals(rev99.getOrdinal(), count_down);
         // for (BibleBook b : BibleBook.values()) {
@@ -311,7 +294,7 @@
                 for (int v = 0; v <= BibleInfo.versesInChapter(b, c); v++) {
                     Verse curVerse = new Verse(b, c, v);
                     int up = curVerse.subtract(gen00) + 1;
-                    int down = rev99.subtract(curVerse) + 1;
+//                    int down = rev99.subtract(curVerse) + 1;
 
                     assertEquals(++count_up, up);
 //                    assertEquals(count_down--, down);

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java	2012-01-03 13:53:37 UTC (rev 2196)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java	2012-01-04 21:53:06 UTC (rev 2197)
@@ -80,7 +80,7 @@
         assertEquals(VerseFactory.fromString("Genesis 1:1").toString(), "Gen 1:1");
         assertEquals(VerseFactory.fromString("Gen 1 1").toString(), "Gen 1:1");
         assertEquals(VerseFactory.fromString("g 1 1").toString(), "Gen 1:1");
-        assertEquals(VerseFactory.fromString("g").toString(), "Gen 1:1");
+        assertEquals(VerseFactory.fromString("g").toString(), "Gen 0:0");
         assertEquals(VerseFactory.fromString("G:1:1").toString(), "Gen 1:1");
         PassageUtil.setPersistentNaming(true);
         assertTrue(PassageUtil.isPersistentNaming());




More information about the jsword-svn mailing list