[jsword-svn] r2226 - in trunk: bibledesktop/src/main/resources/xsl/cswing jsword/src/main/java/org/crosswire/jsword/book/sword jsword/src/main/java/org/crosswire/jsword/passage jsword/src/main/java/org/crosswire/jsword/versification jsword/src/test/java/org/crosswire/jsword/passage jsword/src/test/java/org/crosswire/jsword/versification

dmsmith at crosswire.org dmsmith at crosswire.org
Thu Feb 2 12:25:21 MST 2012


Author: dmsmith
Date: 2012-02-02 12:25:21 -0700 (Thu, 02 Feb 2012)
New Revision: 2226

Modified:
   trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl
   trunk/bibledesktop/src/main/resources/xsl/cswing/simple2.xsl
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageEvent.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.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/passage/VerseRangeFactory.java
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/DivisionName.java
   trunk/jsword/src/main/java/org/crosswire/jsword/versification/Versification.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/versification/VersificationTest.java
Log:
Fixed a bug in the display of notes, especially visible for long notes in an RtoL language.
More v11n changes. Lots of deprecations. decodeOrdinal is now very fast. All v11n tests now pass.

Modified: trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl
===================================================================
--- trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl	2012-02-02 19:25:21 UTC (rev 2226)
@@ -95,6 +95,9 @@
   <xsl:param name="css"/>
   
   <!-- The order of display. Hebrew is rtl (right to left) -->
+  <xsl:param name="v11n" select="'KJV'"/>
+
+  <!-- The order of display. Hebrew is rtl (right to left) -->
   <xsl:param name="direction" select="'ltr'"/>
 
   <!-- The font that is passed in is in one of two forms:
@@ -112,6 +115,8 @@
       </xsl:call-template>
   </xsl:variable>
 
+  <!-- Create a versification from which verse numbers are understood -->
+  <xsl:variable name="v11nf" select="jsword:org.crosswire.jsword.versification.system.Versifications.instance()"/>
   <!-- Create a global key factory from which OSIS ids will be generated -->
   <xsl:variable name="keyf" select="jsword:org.crosswire.jsword.passage.PassageKeyFactory.instance()"/>
   <!-- Create a global number shaper that can transform 0-9 into other number systems. -->
@@ -150,6 +155,7 @@
           .canonical { color: #666699; }
           .gen { color: #996666; }
           div.margin { font-size:90%; }
+          TABLE { width:100% }
           TD.notes { width:20%; background:#f4f4e8; }
           TD.text { width:80%; }
           <!-- the following are for dictionary entries -->
@@ -186,13 +192,13 @@
                 <table cols="2" cellpadding="5" cellspacing="5">
                   <!-- In a right to left, the alignment should be reversed too -->
                   <tr align="right">
+                    <td valign="top" class="text">
+                      <xsl:apply-templates/>
+                    </td>
                     <td valign="top" class="notes">
                       <p> </p>
                       <xsl:apply-templates select="//note" mode="print-notes"/>
                     </td>
-                    <td valign="top" class="text">
-                      <xsl:apply-templates/>
-                    </td>
                   </tr>
                 </table>
               </xsl:otherwise>
@@ -366,7 +372,8 @@
 
   <xsl:template match="verse" mode="print-notes">
     <xsl:if test=".//note[not(@type) or not(@type = 'x-strongsMarkup')]">
-      <xsl:variable name="passage" select="jsword:getValidKey($keyf, @osisID)"/>
+      <xsl:variable name="versification" select="jsword:getVersification($v11nf, $v11n)"/>
+      <xsl:variable name="passage" select="jsword:getValidKey($keyf, $versification, @osisID)"/>
       <a href="#{substring-before(concat(@osisID, ' '), ' ')}">
         <xsl:value-of select="jsword:getName($passage)"/>
       </a>
@@ -396,7 +403,8 @@
       <xsl:variable name="versenum">
         <xsl:choose>
           <xsl:when test="$BCVNum = 'true'">
-            <xsl:variable name="passage" select="jsword:getValidKey($keyf, @osisID)"/>
+            <xsl:variable name="versification" select="jsword:getVersification($v11nf, $v11n)"/>
+            <xsl:variable name="passage" select="jsword:getValidKey($keyf, $versification, @osisID)"/>
             <xsl:value-of select="jsword:getName($passage)"/>
           </xsl:when>
           <xsl:when test="$CVNum = 'true'">

Modified: trunk/bibledesktop/src/main/resources/xsl/cswing/simple2.xsl
===================================================================
--- trunk/bibledesktop/src/main/resources/xsl/cswing/simple2.xsl	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/bibledesktop/src/main/resources/xsl/cswing/simple2.xsl	2012-02-02 19:25:21 UTC (rev 2226)
@@ -94,6 +94,9 @@
   <xsl:param name="css"/>
   
   <!-- The order of display. Hebrew is rtl (right to left) -->
+  <xsl:param name="v11n" select="'KJV'"/>
+
+  <!-- The order of display. Hebrew is rtl (right to left) -->
   <xsl:param name="direction" select="'ltr'"/>
 
   <!-- The font that is passed in is in one of two forms:
@@ -111,6 +114,8 @@
       </xsl:call-template>
   </xsl:variable>
 
+  <!-- Create a versification from which verse numbers are understood -->
+  <xsl:variable name="v11nf" select="jsword:org.crosswire.jsword.versification.system.Versifications.instance()"/>
   <!-- Create a global key factory from which OSIS ids will be generated -->
   <xsl:variable name="keyf" select="jsword:org.crosswire.jsword.passage.PassageKeyFactory.instance()"/>
 
@@ -346,7 +351,8 @@
 
   <xsl:template match="verse" mode="print-notes">
     <xsl:if test=".//note[not(@type) or not(@type = 'x-strongsMarkup')]">
-      <xsl:variable name="passage" select="jsword:getValidKey($keyf, @osisID)"/>
+      <xsl:variable name="versification" select="jsword:getVersification($v11nf, $v11n)"/>
+      <xsl:variable name="passage" select="jsword:getValidKey($keyf, $versification, @osisID)"/>
       <a href="#{substring-before(concat(@osisID, ' '), ' ')}">
         <xsl:value-of select="jsword:getName($passage)"/>
       </a>

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-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawFileBackend.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -173,7 +173,7 @@
             idxRaf = ntIdxRaf;
         }
 
-        int sourceOIndex = sourceVerse.getOrdinal();
+        int sourceOIndex = v11n.getOrdinal(sourceVerse);
         sourceOIndex = v11n.getTestamentOrdinal(sourceOIndex);
         DataIndex dataIndex = getIndex(idxRaf, sourceOIndex);
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -40,6 +40,7 @@
 import org.crosswire.jsword.JSOtherMsg;
 import org.crosswire.jsword.versification.BibleBook;
 import org.crosswire.jsword.versification.Versification;
+import org.crosswire.jsword.versification.system.Versifications;
 
 /**
  * This is a base class to help with some of the common implementation details
@@ -355,46 +356,6 @@
     }
 
     /* (non-Javadoc)
-     * @see org.crosswire.jsword.passage.Passage#chaptersInPassage(int)
-     */
-    public int chaptersInPassage(BibleBook book) throws NoSuchVerseException {
-        int current_chapter = 0;
-        int chapter_count = 0;
-
-        for (Key aKey : this) {
-            Verse verse = (Verse) aKey;
-
-            if ((book == null || verse.getBook() == book) && current_chapter != verse.getChapter()) {
-                current_chapter = verse.getChapter();
-                chapter_count++;
-            }
-        }
-
-        return chapter_count;
-    }
-
-    /* (non-Javadoc)
-     * @see org.crosswire.jsword.passage.Passage#versesInPassage(int, int)
-     */
-    public int versesInPassage(BibleBook book, int chapter) throws NoSuchVerseException {
-        if (book != null) {
-            getVersification().validate(book, chapter == 0 ? 1 : chapter, 1);
-        }
-
-        int verse_count = 0;
-
-        for (Key aKey : this) {
-            Verse verse = (Verse) aKey;
-
-            if ((book == null || verse.getBook() == book) && (chapter == 0 || verse.getChapter() == chapter)) {
-                verse_count++;
-            }
-        }
-
-        return verse_count;
-    }
-
-    /* (non-Javadoc)
      * @see org.crosswire.jsword.passage.Passage#getVerseAt(int)
      */
     public Verse getVerseAt(int offset) throws ArrayIndexOutOfBoundsException {
@@ -1038,7 +999,7 @@
          * iterate, amalgamating Verses into VerseRanges
          */
         protected VerseRangeIterator(Versification v11n, Iterator<Key> it, RestrictionType restrict) {
-            this.referenceSystem = v11n;
+            this.v11n = v11n;
             this.it = it;
             this.restrict = restrict;
 
@@ -1098,26 +1059,26 @@
                 next_verse = (Verse) it.next();
 
                 // If the next verse adjacent
-                if (!end.adjacentTo(next_verse)) {
+                if (!v11n.adjacentTo(end, next_verse)) {
                     break;
                 }
 
                 // Even if the next verse is adjacent we might want to break
                 // if we have moved into a new chapter/book
-                if (!restrict.isSameScope(end, next_verse)) {
+                if (!restrict.isSameScope(v11n, end, next_verse)) {
                     break findnext;
                 }
 
                 end = next_verse;
             }
 
-            next_range = new VerseRange(referenceSystem, start, end);
+            next_range = new VerseRange(v11n, start, end);
         }
 
         /**
          * The Versification to which these verses belong.
          */
-        private Versification referenceSystem;
+        private Versification v11n;
 
         /**
          * The Iterator that we are proxying to
@@ -1163,8 +1124,11 @@
      *             if the read fails
      */
     protected void writeObjectSupport(ObjectOutputStream out) throws IOException {
+        // Save off the versification by name
+        out.writeUTF(v11n.getName());
+
         // the size in bits of teach storage method
-        int bitwise_size = getVersification().maximumOrdinal();
+        int bitwise_size = v11n.maximumOrdinal();
         int ranged_size = 8 * countRanges(RestrictionType.NONE);
         int distinct_size = 4 * countVerses();
 
@@ -1175,7 +1139,7 @@
             BitSet store = new BitSet(bitwise_size);
             for (Key aKey : this) {
                 Verse verse = (Verse) aKey;
-                store.set(verse.getOrdinal() - 1);
+                store.set(v11n.getOrdinal(verse) - 1);
             }
 
             out.writeObject(store);
@@ -1188,7 +1152,7 @@
             // write the verse ordinals in a loop
             for (Key aKey : this) {
                 Verse verse = (Verse) aKey;
-                out.writeInt(verse.getOrdinal());
+                out.writeInt(v11n.getOrdinal(verse));
             }
         } else {
             // otherwise use ranges
@@ -1200,7 +1164,7 @@
             Iterator<Key> it = rangeIterator(RestrictionType.NONE);
             while (it.hasNext()) {
                 VerseRange range = (VerseRange) it.next();
-                out.writeInt(range.getStart().getOrdinal());
+                out.writeInt(v11n.getOrdinal(range.getStart()));
                 out.writeInt(range.getCardinality());
             }
         }
@@ -1241,6 +1205,10 @@
         raiseEventSuppresion();
         raiseNormalizeProtection();
 
+        // Read the versification by name
+        String v11nName = is.readUTF();
+        v11n = Versifications.instance().getVersification(v11nName);
+
         int type = is.readInt();
         switch (type) {
         case BITWISE:
@@ -1310,7 +1278,7 @@
     /**
      * The Versification to which this passage belongs.
      */
-    private Versification v11n;
+    private transient Versification v11n;
 
     /**
      * The parent key. See the key interface for more information. NOTE(joe):

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -29,6 +29,7 @@
 import java.util.NoSuchElementException;
 
 import org.crosswire.jsword.versification.Versification;
+import org.crosswire.jsword.versification.system.Versifications;
 
 /**
  * A Passage that is implemented using a BitSet - one for each verse. The
@@ -116,9 +117,10 @@
 
     @Override
     public boolean contains(Key obj) {
+        Versification v11n = getVersification();
         for (Key aKey : obj) {
             Verse verse = (Verse) aKey;
-            if (!store.get(verse.getOrdinal())) {
+            if (!store.get(v11n.getOrdinal(verse))) {
                 return false;
             }
         }
@@ -130,6 +132,7 @@
      * @see org.crosswire.jsword.passage.Passage#add(org.crosswire.jsword.passage.Key)
      */
     public void add(Key obj) {
+        Versification v11n = getVersification();
         optimizeWrites();
 
         Verse firstVerse = null;
@@ -139,7 +142,7 @@
             if (firstVerse == null) {
                 firstVerse = lastVerse;
             }
-            store.set(lastVerse.getOrdinal());
+            store.set(v11n.getOrdinal(lastVerse));
         }
 
         // we do an extra check here because the cost of calculating the
@@ -153,6 +156,7 @@
      * @see org.crosswire.jsword.passage.Passage#remove(org.crosswire.jsword.passage.Key)
      */
     public void remove(Key obj) {
+        Versification v11n = getVersification();
         optimizeWrites();
 
         Verse firstVerse = null;
@@ -162,7 +166,7 @@
             if (firstVerse == null) {
                 firstVerse = lastVerse;
             }
-            store.clear(lastVerse.getOrdinal());
+            store.clear(v11n.getOrdinal(lastVerse));
         }
 
         // we do an extra check here because the cost of calculating the
@@ -215,6 +219,7 @@
 
     @Override
     public void retainAll(Key key) {
+        Versification v11n = getVersification();
         Passage that = KeyUtil.getPassage(key);
 
         optimizeWrites();
@@ -223,10 +228,10 @@
         if (that instanceof BitwisePassage) {
             thatStore = ((BitwisePassage) that).store;
         } else {
-            thatStore = new BitSet(getVersification().maximumOrdinal() + 1);
+            thatStore = new BitSet(v11n.maximumOrdinal() + 1);
 
             for (Key aKey : that) {
-                int ord = ((Verse) aKey).getOrdinal();
+                int ord = v11n.getOrdinal((Verse) aKey);
                 if (store.get(ord)) {
                     thatStore.set(ord);
                 }
@@ -349,6 +354,9 @@
     private void writeObject(ObjectOutputStream out) throws IOException {
         out.defaultWriteObject();
 
+        // Save off the versification by name
+        out.writeUTF(getVersification().getName());
+
         writeObjectSupport(out);
     }
 
@@ -369,8 +377,12 @@
 
         in.defaultReadObject();
 
-        store = new BitSet(getVersification().maximumOrdinal() + 1);
+        // Read the versification by name
+        String v11nName = in.readUTF();
+        Versification v11n = Versifications.instance().getVersification(v11nName);
 
+        store = new BitSet(v11n.maximumOrdinal() + 1);
+
         readObjectSupport(in);
     }
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -26,7 +26,6 @@
 import java.io.Writer;
 import java.util.Iterator;
 
-import org.crosswire.jsword.versification.BibleBook;
 import org.crosswire.jsword.versification.Versification;
 
 /**
@@ -165,31 +164,6 @@
     int booksInPassage();
 
     /**
-     * How many chapters are there in a particular book in this Passage
-     * 
-     * @param book
-     *            The book to check (null for distinct chapters in all books)
-     * @return The number of distinct chapters
-     * @throws NoSuchVerseException
-     *             if the book is invalid
-     */
-    int chaptersInPassage(BibleBook book) throws NoSuchVerseException;
-
-    /**
-     * How many chapters are there in a particular book in this Passage Note
-     * that <code>versesInPassage(ref, 0, 0) == ref.countVerses()</code>
-     * 
-     * @param book
-     *            The book to check (null for distinct chapters in all books)
-     * @param chapter
-     *            The chapter to check (0 for distinct verses in all chapters)
-     * @return The number of distinct chapters
-     * @throws NoSuchVerseException
-     *             if the book/chapter is invalid
-     */
-    int versesInPassage(BibleBook book, int chapter) throws NoSuchVerseException;
-
-    /**
      * Get a specific Verse from this collection
      * 
      * @param offset

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageEvent.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageEvent.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageEvent.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -23,8 +23,6 @@
 
 import java.util.EventObject;
 
-import org.crosswire.jsword.versification.BibleBook;
-
 /**
  * Defines an event that encapsulates changes to a Passage. For many operations
  * on a Passage, calculating the extent of the changes is hard. In these cases
@@ -74,13 +72,6 @@
         this.type = versesChanged;
         this.lower = lower;
         this.upper = upper;
-
-        if (this.lower == null) {
-            this.lower = VERSE_LOWEST;
-        }
-        if (this.upper == null) {
-            this.upper = VERSE_HIGHEST;
-        }
     }
 
     /**
@@ -118,16 +109,6 @@
     }
 
     /**
-     * When the lower verse is null
-     */
-    private static final Verse VERSE_LOWEST = new Verse(BibleBook.GEN, 1, 1);
-
-    /**
-     * When the upper verse is null
-     */
-    private static final Verse VERSE_HIGHEST = new Verse(BibleBook.REV, 22, 21);
-
-    /**
      * The type of change
      */
     private EventType type;

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -155,7 +155,8 @@
      * @return a byte array
      */
     static byte[] toBinaryRepresentation(Passage ref) {
-        int maxOrdinal = ref.getVersification().maximumOrdinal();
+        Versification v11n = ref.getVersification();
+        int maxOrdinal = v11n.maximumOrdinal();
         // store these locally we use them so often
         int verses = ref.countVerses();
         int ranges = ref.countRanges(RestrictionType.NONE);
@@ -175,7 +176,7 @@
 
             for (Key aKey : ref) {
                 Verse verse = (Verse) aKey;
-                int ord = verse.getOrdinal();
+                int ord = v11n.getOrdinal(verse);
 
                 // Which byte should we be altering
                 int idx0 = (ord / 8) + index;
@@ -202,7 +203,7 @@
             // write the verse ordinals in a loop
             for (Key aKey : ref) {
                 Verse verse = (Verse) aKey;
-                int ord = verse.getOrdinal();
+                int ord = v11n.getOrdinal(verse);
                 index += toBinary(buffer, index, ord, maxOrdinal);
             }
 
@@ -222,7 +223,7 @@
             Iterator<Key> it = ref.rangeIterator(RestrictionType.NONE);
             while (it.hasNext()) {
                 VerseRange range = (VerseRange) it.next();
-                index += toBinary(buffer, index, range.getStart().getOrdinal(), maxOrdinal);
+                index += toBinary(buffer, index, v11n.getOrdinal(range.getStart()), maxOrdinal);
                 index += toBinary(buffer, index, range.getCardinality(), maxOrdinal);
             }
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -324,9 +324,10 @@
      */
     @Override
     public boolean contains(Key that) {
+        Versification v11n = getVersification();
         for (Key aKey : that) {
             Verse verse = (Verse) aKey;
-            if (board[verse.getOrdinal()] == 0) {
+            if (board[v11n.getOrdinal(verse)] == 0) {
                 return false;
             }
         }
@@ -342,7 +343,8 @@
      * @return The rank of the verse in question
      */
     public int getTallyOf(Verse verse) {
-        return board[verse.getOrdinal()];
+        Versification v11n = getVersification();
+        return board[v11n.getOrdinal(verse)];
     }
 
     /**
@@ -353,7 +355,8 @@
      * @return The index of the verse or -1 if the verse was not found
      */
     public int getIndexOf(Verse verse) {
-        int pos = verse.getOrdinal();
+        Versification v11n = getVersification();
+        int pos = v11n.getOrdinal(verse);
         int tally = board[pos];
         return tally > 0 ? pos : -1;
     }
@@ -409,11 +412,12 @@
      *            The verses to remove/decrement
      */
     public void remove(Key that) {
+        Versification v11n = getVersification();
         optimizeWrites();
 
         for (Key aKey : that) {
             Verse verse = (Verse) aKey;
-            kill(verse.getOrdinal());
+            kill(v11n.getOrdinal(verse));
         }
 
         fireIntervalRemoved(this, null, null);
@@ -421,6 +425,7 @@
 
     @Override
     public void addAll(Key that) {
+        Versification v11n = getVersification();
         optimizeWrites();
 
         if (that instanceof PassageTally) {
@@ -435,7 +440,7 @@
         } else {
             for (Key aKey : that) {
                 Verse verse = (Verse) aKey;
-                increment(verse.getOrdinal(), 1);
+                increment(v11n.getOrdinal(verse), 1);
             }
 
             incrementMax(1);
@@ -451,6 +456,7 @@
      *            The verses to remove/decrement
      */
     public void unAddAll(Passage that) {
+        Versification v11n = getVersification();
         optimizeWrites();
 
         if (that instanceof PassageTally) {
@@ -463,7 +469,7 @@
         } else {
             for (Key aKey : that) {
                 Verse verse = (Verse) aKey;
-                increment(verse.getOrdinal(), -1);
+                increment(v11n.getOrdinal(verse), -1);
             }
         }
 
@@ -476,6 +482,7 @@
 
     @Override
     public void removeAll(Key key) {
+        Versification v11n = getVersification();
         Passage that = KeyUtil.getPassage(key);
 
         optimizeWrites();
@@ -492,7 +499,7 @@
         } else {
             for (Key aKey : that) {
                 Verse verse = (Verse) aKey;
-                kill(verse.getOrdinal());
+                kill(v11n.getOrdinal(verse));
             }
         }
 
@@ -663,9 +670,10 @@
      *            The amount to increment/decrement by
      */
     private void alterVerseBase(Key that, int tally) {
+        Versification v11n = getVersification();
         for (Key aKey : that) {
             Verse verse = (Verse) aKey;
-            increment(verse.getOrdinal(), tally);
+            increment(v11n.getOrdinal(verse), tally);
         }
 
         if (tally > 0) {
@@ -1023,10 +1031,10 @@
         /**
          * Find the first unused verse
          */
-        public OrderedVerseRangeIterator(Versification referenceSystem, Iterator<Key> vit, int[] board) {
+        public OrderedVerseRangeIterator(Versification v11n, Iterator<Key> vit, int[] board) {
             Set<TalliedVerseRange> output = new TreeSet<TalliedVerseRange>();
 
-            Iterator<Key> rit = new VerseRangeIterator(referenceSystem, vit, RestrictionType.NONE);
+            Iterator<Key> rit = new VerseRangeIterator(v11n, vit, RestrictionType.NONE);
             while (rit.hasNext()) {
                 VerseRange range = (VerseRange) rit.next();
 
@@ -1034,7 +1042,7 @@
                 int rank = 0;
                 for (Key aKey : range) {
                     Verse verse = (Verse) aKey;
-                    int temp = board[verse.getOrdinal()];
+                    int temp = board[v11n.getOrdinal(verse)];
                     if (temp > rank) {
                         rank = temp;
                     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -335,9 +335,11 @@
 
             while (it.hasNext()) {
                 VerseRange range = (VerseRange) it.next();
+                int start = v11n.getOrdinal(range.getStart());
+                int end = range.getCardinality();
 
-                for (int i = 0; i < range.getCardinality(); i++) {
-                    temp.add(v11n.decodeOrdinal(range.getStart().getOrdinal() + i));
+                for (int i = 0; i < end; i++) {
+                    temp.add(v11n.decodeOrdinal(start + i));
                 }
             }
 
@@ -411,7 +413,7 @@
 
             // So we know what is broadly next, however the range might need
             // splitting according to restrict
-            if (restrict.isSameScope(next.getStart(), next.getEnd())) {
+            if (restrict.isSameScope(next.getVersification(), next.getStart(), next.getEnd())) {
                 return replyNext();
             }
             return splitNext();

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -27,7 +27,6 @@
 import java.util.Iterator;
 
 import org.crosswire.jsword.JSOtherMsg;
-import org.crosswire.jsword.versification.BibleBook;
 import org.crosswire.jsword.versification.Versification;
 
 /**
@@ -243,20 +242,6 @@
     }
 
     /* (non-Javadoc)
-     * @see org.crosswire.jsword.passage.Passage#chaptersInPassage(BibleBook)
-     */
-    public int chaptersInPassage(BibleBook book) throws NoSuchVerseException {
-        return ref.chaptersInPassage(book);
-    }
-
-    /* (non-Javadoc)
-     * @see org.crosswire.jsword.passage.Passage#versesInPassage(BibleBook, int)
-     */
-    public int versesInPassage(BibleBook book, int chapter) throws NoSuchVerseException {
-        return ref.versesInPassage(book, chapter);
-    }
-
-    /* (non-Javadoc)
      * @see org.crosswire.jsword.passage.Passage#getVerseAt(int)
      */
     public Verse getVerseAt(int offset) throws ArrayIndexOutOfBoundsException {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -23,7 +23,6 @@
 
 import org.crosswire.jsword.versification.BibleBook;
 import org.crosswire.jsword.versification.Versification;
-import org.crosswire.jsword.versification.system.Versifications;
 
 /**
  * Types of Passage Blurring Restrictions.
@@ -39,21 +38,21 @@
      */
     NONE {
         @Override
-        public boolean isSameScope(Verse start, Verse end) {
+        public boolean isSameScope(Versification v11n, Verse start, Verse end) {
             return true;
         }
 
         @Override
         public VerseRange blur(Versification v11n, VerseRange range, int blurDown, int blurUp) {
-            Verse start = range.getStart().subtract(blurDown);
-            Verse end = range.getEnd().add(blurUp);
+            Verse start = v11n.subtract(range.getStart(), blurDown);
+            Verse end = v11n.add(range.getEnd(), blurUp);
             return new VerseRange(v11n, start, end);
         }
 
         @Override
         public VerseRange blur(Versification v11n, Verse verse, int blurDown, int blurUp) {
-            Verse start = verse.subtract(blurDown);
-            Verse end = verse.add(blurUp);
+            Verse start = v11n.subtract(verse, blurDown);
+            Verse end = v11n.add(verse, blurUp);
             return new VerseRange(v11n, start, end);
         }
 
@@ -61,7 +60,7 @@
         public VerseRange toRange(Versification v11n, Verse verse, int count) {
             Verse end = verse;
             if (count > 1) {
-                end = verse.add(count - 1);
+                end = v11n.add(verse, count - 1);
             }
             return new VerseRange(v11n, verse, end);
         }
@@ -72,14 +71,12 @@
      */
     CHAPTER {
         @Override
-        public boolean isSameScope(Verse start, Verse end) {
-            return start.isSameChapter(end);
+        public boolean isSameScope(Versification v11n, Verse start, Verse end) {
+            return v11n.isSameChapter(start, end);
         }
 
         @Override
         public VerseRange blur(Versification v11n, VerseRange range, int blurDown, int blurUp) {
-            Versification rs = range.getVersification();
-
             Verse start = range.getStart();
             BibleBook startBook = start.getBook();
             int startChapter = start.getChapter();
@@ -90,8 +87,8 @@
             int endChapter = end.getChapter();
             int endVerse = end.getVerse() + blurUp;
 
-            startVerse = Math.max(startVerse, 1);
-            endVerse = Math.min(endVerse, rs.getLastVerse(endBook, endChapter));
+            startVerse = Math.max(startVerse, 0);
+            endVerse = Math.min(endVerse, v11n.getLastVerse(endBook, endChapter));
 
             Verse newStart = new Verse(startBook, startChapter, startVerse);
             Verse newEnd = new Verse(endBook, endChapter, endVerse);
@@ -100,30 +97,22 @@
 
         @Override
         public VerseRange blur(Versification v11n, Verse verse, int blurDown, int blurUp) {
-            int verseNumber = verse.getVerse();
-
-            int down = verseNumber - Math.max(verseNumber - blurDown, 1);
-
-            Verse start = verse;
-            if (down > 0) {
-                start = verse.subtract(down);
-            }
-
             BibleBook book = verse.getBook();
-            int chapterNumber = verse.getChapter();
-            // AV11N(DMS): Is this right?
-            int up = Math.min(verseNumber + blurUp, Versifications.instance().getDefaultVersification().getLastVerse(book, chapterNumber)) - verseNumber;
-            Verse end = verse;
-            if (up > 0) {
-                end = verse.add(up);
-            }
+            int chapter = verse.getChapter();
+            int startVerse = verse.getVerse() - blurDown;
+            int endVerse = verse.getVerse() + blurUp;
 
+            startVerse = Math.max(startVerse, 0);
+            endVerse = Math.min(endVerse, v11n.getLastVerse(book, chapter));
+
+            Verse start = new Verse(book, chapter, startVerse);
+            Verse end = new Verse(book, chapter, endVerse);
             return new VerseRange(v11n, start, end);
         }
 
         @Override
         public VerseRange toRange(Versification v11n, Verse verse, int count) {
-            Verse end = verse.add(count - 1);
+            Verse end = v11n.add(verse, count - 1);
             return new VerseRange(v11n, verse, end);
         }
     };
@@ -137,7 +126,7 @@
      *            the second verse
      * @return true if the two are in the same scope.
      */
-    public abstract boolean isSameScope(Verse start, Verse end);
+    public abstract boolean isSameScope(Versification v11n, Verse start, Verse end);
 
     /**
      * Blur a verse range the specified amount. Since verse ranges are

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -25,7 +25,6 @@
 import java.io.ObjectInputStream;
 import java.util.Iterator;
 
-import org.crosswire.jsword.versification.BibleBook;
 import org.crosswire.jsword.versification.Versification;
 
 /**
@@ -229,34 +228,6 @@
     /*
      * (non-Javadoc)
      * 
-     * @see org.crosswire.jsword.passage.Passage#chaptersInPassage(int)
-     */
-    @Override
-    public int chaptersInPassage(BibleBook book) throws NoSuchVerseException {
-        if (distinct != null) {
-            return distinct.chaptersInPassage(book);
-        }
-
-        return super.chaptersInPassage(book);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.crosswire.jsword.passage.Passage#versesInPassage(int, int)
-     */
-    @Override
-    public int versesInPassage(BibleBook book, int chapter) throws NoSuchVerseException {
-        if (distinct != null) {
-            return distinct.versesInPassage(book, chapter);
-        }
-
-        return super.versesInPassage(book, chapter);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
      * @see
      * org.crosswire.jsword.passage.Passage#containsAll(org.crosswire.jsword
      * .passage.Passage)

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -26,7 +26,6 @@
 import java.io.Writer;
 import java.util.Iterator;
 
-import org.crosswire.jsword.versification.BibleBook;
 import org.crosswire.jsword.versification.Versification;
 
 /**
@@ -225,20 +224,6 @@
     }
 
     /* (non-Javadoc)
-     * @see org.crosswire.jsword.passage.Passage#chaptersInPassage(BibleBook)
-     */
-    public synchronized int chaptersInPassage(BibleBook book) throws NoSuchVerseException {
-        return ref.chaptersInPassage(book);
-    }
-
-    /* (non-Javadoc)
-     * @see org.crosswire.jsword.passage.Passage#versesInPassage(BibleBook, int)
-     */
-    public synchronized int versesInPassage(BibleBook book, int chapter) throws NoSuchVerseException {
-        return ref.versesInPassage(book, chapter);
-    }
-
-    /* (non-Javadoc)
      * @see org.crosswire.jsword.passage.Passage#getVerseAt(int)
      */
     public synchronized Verse getVerseAt(int offset) throws ArrayIndexOutOfBoundsException {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -278,7 +278,9 @@
      * @param that
      *            The thing to compare against
      * @return 1 means he is earlier than me, -1 means he is later ...
+     * @deprecated
      */
+    @Deprecated
     public boolean adjacentTo(Verse that) {
         return Math.abs(that.getOrdinal() - getOrdinal()) == 1;
     }
@@ -291,7 +293,9 @@
      * @param start
      *            The Verse to compare this to
      * @return The count of verses between this and that.
+     * @deprecated
      */
+    @Deprecated
     public int subtract(Verse start) {
         return getOrdinal() - start.getOrdinal();
     }
@@ -302,7 +306,9 @@
      * @param n
      *            The number to count down by
      * @return The new Verse
+     * @deprecated
      */
+    @Deprecated
     public Verse subtract(int n) {
         // AV11N(DMS): deprecate?
         return Versifications.instance().getDefaultVersification().subtract(this, n);
@@ -314,7 +320,9 @@
      * @param n
      *            the number of verses later than the one we're one
      * @return The new verse
+     * @deprecated
      */
+    @Deprecated
     public Verse add(int n) {
         // AV11N(DMS): deprecate?
         return Versifications.instance().getDefaultVersification().add(this, n);
@@ -351,16 +359,20 @@
      * Is this verse the first in a chapter
      * 
      * @return true or false ...
+     * @deprecated
      */
+    @Deprecated
     public boolean isStartOfChapter() {
-        return verse == 1 || verse == 0;
+        return verse == 0;
     }
 
     /**
      * Is this verse the first in a chapter
      * 
      * @return true or false ...
+     * @deprecated
      */
+    @Deprecated
     public boolean isEndOfChapter() {
         // AV11N(DMS): deprecate?
         return Versifications.instance().getDefaultVersification().isEndOfChapter(this);
@@ -370,16 +382,20 @@
      * Is this verse the first in a chapter
      * 
      * @return true or false ...
+     * @deprecated
      */
+    @Deprecated
     public boolean isStartOfBook() {
-        return (verse == 1 || verse == 0) && (chapter == 1 || chapter == 0);
+        return verse == 0 && chapter == 0;
     }
 
     /**
      * Is this verse the first in a chapter
      * 
      * @return true or false ...
+     * @deprecated
      */
+    @Deprecated
     public boolean isEndOfBook() {
         // AV11N(DMS): deprecate?
         return Versifications.instance().getDefaultVersification().isEndOfBook(this);
@@ -391,7 +407,9 @@
      * @param that
      *            The verse to compare to
      * @return true or false ...
+     * @deprecated
      */
+    @Deprecated
     public boolean isSameChapter(Verse that) {
         return book == that.book && chapter == that.chapter;
     }
@@ -402,7 +420,9 @@
      * @param that
      *            The verse to compare to
      * @return true or false ...
+     * @deprecated
      */
+    @Deprecated
     public boolean isSameBook(Verse that) {
         return book == that.book;
     }
@@ -412,7 +432,9 @@
      * 31104
      * 
      * @return The verse number
+     * @deprecated do not use
      */
+    @Deprecated
     public int getOrdinal() {
         // AV11N(DMS): deprecate?
         return Versifications.instance().getDefaultVersification().getOrdinal(this);
@@ -427,7 +449,9 @@
      * @param b
      *            The second verse to compare
      * @return The bigger of the 2 verses
+     * @deprecated do not use
      */
+    @Deprecated
     public static Verse max(Verse a, Verse b) {
         if (a.compareTo(b) == -1) {
             return b;
@@ -444,7 +468,9 @@
      * @param b
      *            The second verse to compare
      * @return The smaller of the 2 verses
+     * @deprecated do not use
      */
+    @Deprecated
     public static Verse min(Verse a, Verse b) {
         if (a.compareTo(b) == 1) {
             return b;
@@ -489,7 +515,9 @@
      * @param verseBase
      *            the context or null if there is none
      * @return the verse representation
+     * @deprecated do not use
      */
+    @Deprecated
     private String doGetName(Verse verseBase) {
         // To cope with thing like Jude 2...
         // AV11N(DMS): move to Versification???
@@ -541,7 +569,9 @@
      *            The chapter to set
      * @param verse
      *            The verse to set
+     * @deprecated do not use
      */
+    @Deprecated
     private void setAndPatch(BibleBook book, int chapter, int verse) {
         // AV11N(DMS): deprecate?
         Versification v11n = Versifications.instance().getDefaultVersification();
@@ -574,7 +604,9 @@
      * 
      * @param ordinal
      *            The ordinal of the verse
+     * @deprecated do not use
      */
+    @Deprecated
     private void set(int ordinal) {
         // AV11N(DMS): deprecate?
         Versification v11n = Versifications.instance().getDefaultVersification();

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -86,8 +86,8 @@
      * provide this constructor however, you are supposed to provide a default
      * ctor for all beans. For this reason I suggest you don't use it.
      */
-    public VerseRange(Versification rs) {
-        this(rs, null, Verse.DEFAULT, Verse.DEFAULT);
+    public VerseRange(Versification v11n) {
+        this(v11n, null, Verse.DEFAULT, Verse.DEFAULT);
     }
 
     /**
@@ -97,12 +97,12 @@
      * @param start
      *            The verse to start from
      */
-    public VerseRange(Versification rs, Verse start) {
-        this(rs, null, start, start);
+    public VerseRange(Versification v11n, Verse start) {
+        this(v11n, null, start, start);
     }
 
-    public VerseRange(Versification rs, Verse start, Verse end) {
-        this(rs, null, start, end);
+    public VerseRange(Versification v11n, Verse start, Verse end) {
+        this(v11n, null, start, end);
     }
 
     /**
@@ -121,13 +121,13 @@
         this(null, original, start, end);
     }
 
-    /* package */VerseRange(Versification rs, String original, Verse start, Verse end) {
+    /* package */VerseRange(Versification v11n, String original, Verse start, Verse end) {
         assert start != null;
         assert end != null;
 
-        v11n = rs;
-        if (v11n == null) {
-            v11n = Versifications.instance().getDefaultVersification();
+        this.v11n = v11n;
+        if (this.v11n == null) {
+            this.v11n = Versifications.instance().getDefaultVersification();
         }
 
         this.originalName = original;
@@ -137,7 +137,7 @@
         case -1:
             this.start = start;
             this.end = end;
-            this.verseCount = calcVerseCount(start, end);
+            this.verseCount = calcVerseCount();
             break;
 
         case 0:
@@ -149,7 +149,7 @@
         case 1:
             this.start = end;
             this.end = start;
-            this.verseCount = calcVerseCount(this.start, this.end);
+            this.verseCount = calcVerseCount();
             break;
 
         default:
@@ -178,10 +178,11 @@
      *            The second verse range to be merged
      */
     public VerseRange(VerseRange a, VerseRange b) {
+        v11n = a.v11n;
         shaper = new NumberShaper();
-        start = Verse.min(a.getStart(), b.getStart());
-        end = Verse.max(a.getEnd(), b.getEnd());
-        verseCount = calcVerseCount(start, end);
+        start = v11n.min(a.getStart(), b.getStart());
+        end = v11n.max(a.getEnd(), b.getEnd());
+        verseCount = calcVerseCount();
     }
 
     /* (non-Javadoc)
@@ -232,9 +233,9 @@
         // If this is in 2 separate books
         if (startBook != endBook) {
             StringBuilder buf = new StringBuilder();
-            if (start.isStartOfBook()) {
+            if (v11n.isStartOfBook(start)) {
                 buf.append(startBook.getOSIS());
-            } else if (start.isStartOfChapter()) {
+            } else if (v11n.isStartOfChapter(start)) {
                 buf.append(startBook.getOSIS());
                 buf.append(Verse.VERSE_OSIS_DELIM);
                 buf.append(startChapter);
@@ -244,9 +245,9 @@
 
             buf.append(VerseRange.RANGE_PREF_DELIM);
 
-            if (end.isEndOfBook()) {
+            if (v11n.isEndOfBook(end)) {
                 buf.append(endBook.getOSIS());
-            } else if (end.isEndOfChapter()) {
+            } else if (v11n.isEndOfChapter(end)) {
                 buf.append(endBook.getOSIS());
                 buf.append(Verse.VERSE_OSIS_DELIM);
                 buf.append(endChapter);
@@ -270,7 +271,7 @@
         // If this is 2 separate chapters in the same book
         if (startChapter != endChapter) {
             StringBuilder buf = new StringBuilder();
-            if (start.isStartOfChapter()) {
+            if (v11n.isStartOfChapter(start)) {
                 buf.append(startBook.getOSIS());
                 buf.append(Verse.VERSE_OSIS_DELIM);
                 buf.append(startChapter);
@@ -280,7 +281,7 @@
 
             buf.append(VerseRange.RANGE_PREF_DELIM);
 
-            if (end.isEndOfChapter()) {
+            if (v11n.isEndOfChapter(end)) {
                 buf.append(endBook.getOSIS());
                 buf.append(Verse.VERSE_OSIS_DELIM);
                 buf.append(endChapter);
@@ -333,8 +334,8 @@
             return start.getBook().getOSIS() + Verse.VERSE_OSIS_DELIM + start.getChapter();
         }
 
-        int startOrdinal = start.getOrdinal();
-        int endOrdinal = end.getOrdinal();
+        int startOrdinal = v11n.getOrdinal(start);
+        int endOrdinal = v11n.getOrdinal(end);
 
         // to see if it is wholly contained in the range and output it if it is.
 
@@ -411,6 +412,7 @@
             copy.verseCount = verseCount;
             copy.originalName = originalName;
             copy.shaper = new NumberShaper();
+            copy.v11n = v11n;
         } catch (CloneNotSupportedException e) {
             assert false : e;
         }
@@ -450,7 +452,7 @@
 
     @Override
     public int hashCode() {
-        return (start.getOrdinal() << 16) + verseCount;
+        return (v11n.getOrdinal(start) << 16) + verseCount;
     }
 
     /* (non-Javadoc)
@@ -500,10 +502,10 @@
      * @return true if the ranges are adjacent
      */
     public boolean adjacentTo(VerseRange that) {
-        int thatStart = that.getStart().getOrdinal();
-        int thatEnd = that.getEnd().getOrdinal();
-        int thisStart = getStart().getOrdinal();
-        int thisEnd = getEnd().getOrdinal();
+        int thatStart = v11n.getOrdinal(that.getStart());
+        int thatEnd = v11n.getOrdinal(that.getEnd());
+        int thisStart = v11n.getOrdinal(getStart());
+        int thisEnd = v11n.getOrdinal(getEnd());
 
         // if that starts inside or is next to this we are adjacent.
         if (thatStart >= thisStart - 1 && thatStart <= thisEnd + 1) {
@@ -531,10 +533,10 @@
      * @return true if the ranges are adjacent
      */
     public boolean overlaps(VerseRange that) {
-        int thatStart = that.getStart().getOrdinal();
-        int thatEnd = that.getEnd().getOrdinal();
-        int thisStart = getStart().getOrdinal();
-        int thisEnd = getEnd().getOrdinal();
+        int thatStart = v11n.getOrdinal(that.getStart());
+        int thatEnd = v11n.getOrdinal(that.getEnd());
+        int thisStart = v11n.getOrdinal(getStart());
+        int thisEnd = v11n.getOrdinal(getEnd());
 
         // if that starts inside this we are adjacent.
         if (thatStart >= thisStart && thatStart <= thisEnd) {
@@ -598,15 +600,15 @@
      * @return true if we are exactly one chapter.
      */
     public boolean isWholeChapter() {
-        if (!start.isStartOfChapter()) {
+        if (!v11n.isStartOfChapter(start)) {
             return false;
         }
 
-        if (!end.isEndOfChapter()) {
+        if (!v11n.isEndOfChapter(end)) {
             return false;
         }
 
-        if (!start.isSameChapter(end)) {
+        if (!v11n.isSameChapter(start, end)) {
             return false;
         }
 
@@ -619,11 +621,11 @@
      * @return true if we are a whole number of chapters.
      */
     public boolean isWholeChapters() {
-        if (!start.isStartOfChapter()) {
+        if (!v11n.isStartOfChapter(start)) {
             return false;
         }
 
-        if (!end.isEndOfChapter()) {
+        if (!v11n.isEndOfChapter(end)) {
             return false;
         }
 
@@ -636,15 +638,15 @@
      * @return true if we are exactly one book.
      */
     public boolean isWholeBook() {
-        if (!start.isStartOfBook()) {
+        if (!v11n.isStartOfBook(start)) {
             return false;
         }
 
-        if (!end.isEndOfBook()) {
+        if (!v11n.isEndOfBook(end)) {
             return false;
         }
 
-        if (!start.isSameBook(end)) {
+        if (!v11n.isSameBook(start, end)) {
             return false;
         }
 
@@ -657,11 +659,11 @@
      * @return true if we are a whole number of books.
      */
     public boolean isWholeBooks() {
-        if (!start.isStartOfBook()) {
+        if (!v11n.isStartOfBook(start)) {
             return false;
         }
 
-        if (!end.isEndOfBook()) {
+        if (!v11n.isEndOfBook(end)) {
             return false;
         }
 
@@ -684,9 +686,9 @@
      */
     public Verse[] toVerseArray() {
         Verse[] retcode = new Verse[verseCount];
-
+        int ord = v11n.getOrdinal(start);
         for (int i = 0; i < verseCount; i++) {
-            retcode[i] = v11n.decodeOrdinal(start.getOrdinal() + i);
+            retcode[i] = v11n.decodeOrdinal(ord + i);
         }
 
         return retcode;
@@ -720,27 +722,29 @@
     }
 
     /**
-     * Create a DistinctPassage that is the stuff left of VerseRange a when you
+     * Create a VerseRange that is the stuff left of VerseRange a when you
      * remove the stuff in VerseRange b.
      * 
      * @param a
-     *            The verses that you might want
+     *            Verses at the start or end of b
      * @param b
-     *            The verses that you definitely don't
+     *            All the verses
      * @return A list of the Verses outstanding
      */
     public static VerseRange[] remainder(VerseRange a, VerseRange b) {
         VerseRange rstart = null;
         VerseRange rend = null;
 
+        Versification v11n = a.getVersification();
+
         // If a starts before b get the Range of the prequel
-        if (a.getStart().compareTo(b.getStart()) == -1) {
-            rstart = new VerseRange(a.getStart(), b.getEnd().subtract(1));
+        if (v11n.distance(a.getStart(), b.getStart()) > 0) {
+            rstart = new VerseRange(v11n, a.getStart(), v11n.subtract(b.getEnd(), 1));
         }
 
         // If a ends after b get the Range of the sequel
-        if (a.getEnd().compareTo(b.getEnd()) == 1) {
-            rend = new VerseRange(b.getEnd().add(1), a.getEnd());
+        if (v11n.distance(a.getEnd(), b.getEnd()) < 0) {
+            rend = new VerseRange(v11n, v11n.add(b.getEnd(), 1), a.getEnd());
         }
 
         if (rstart == null) {
@@ -763,7 +767,7 @@
     }
 
     /**
-     * Create a DistinctPassage that is the stuff in VerseRange a that is also
+     * Create a VerseRange that is the stuff in VerseRange a that is also
      * in VerseRange b.
      * 
      * @param a
@@ -773,11 +777,12 @@
      * @return A list of the Verses outstanding
      */
     public static VerseRange intersection(VerseRange a, VerseRange b) {
-        Verse new_start = Verse.max(a.getStart(), b.getStart());
-        Verse new_end = Verse.min(a.getEnd(), b.getEnd());
+        Versification v11n = a.getVersification();
+        Verse new_start = v11n.max(a.getStart(), b.getStart());
+        Verse new_end = v11n.min(a.getEnd(), b.getEnd());
 
         if (new_start.compareTo(new_end) < 1) {
-            return new VerseRange(new_start, new_end);
+            return new VerseRange(a.getVersification(), new_start, new_end);
         }
 
         return null;
@@ -858,28 +863,31 @@
      *            The number of verses
      * @return The last verse in the range
      */
-    private static Verse calcEnd(Verse start, int verseCount) {
-        return start.add(verseCount - 1);
+    private Verse calcEnd() {
+        if (verseCount == 1) {
+            return start;
+        }
+        return v11n.add(start, verseCount - 1);
     }
 
     /**
      * Calculate how many verses in this range
      * 
-     * @param start
+     * @param a
      *            The first verse in the range
-     * @param end
+     * @param b
      *            The last verse in the range
      * @return The number of verses. Always >= 1.
      */
-    private static int calcVerseCount(Verse start, Verse end) {
-        return end.subtract(start) + 1;
+    private int calcVerseCount() {
+        return v11n.distance(start, end) + 1;
     }
 
     /**
      * Check to see that everything is ok with the Data
      */
     private void verifyData() {
-        assert verseCount == end.subtract(start) + 1 : "start=" + start + ", end=" + end + ", verseCount=" + verseCount;
+        assert verseCount == calcVerseCount() : "start=" + start + ", end=" + end + ", verseCount=" + verseCount;
     }
 
     /**
@@ -895,7 +903,8 @@
         // Call even if there is no default serializable fields.
         out.defaultWriteObject();
 
-        out.writeInt(start.getOrdinal());
+        out.writeUTF(v11n.getName());
+        out.writeInt(v11n.getOrdinal(start));
         out.writeInt(verseCount);
 
         // Ignore the original name. Is this wise?
@@ -915,14 +924,14 @@
      * @serialData Write the ordinal number of this verse
      */
     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
-        // AV11N(DMS): Is this right?
-        Versification rs = Versifications.instance().getDefaultVersification();
         // Call even if there is no default serializable fields.
         in.defaultReadObject();
 
-        start = rs.decodeOrdinal(in.readInt());
+        String v11nName = in.readUTF();
+        v11n = Versifications.instance().getVersification(v11nName);
+        start = v11n.decodeOrdinal(in.readInt());
         verseCount = in.readInt();
-        end = calcEnd(start, verseCount);
+        end = calcEnd();
         shaper = new NumberShaper();
 
         verifyData();
@@ -940,8 +949,8 @@
          */
         protected VerseIterator(VerseRange range) {
             v11n = range.getVersification();
-            next = range.getStart().getOrdinal();
-            last = range.getEnd().getOrdinal();
+            next = v11n.getOrdinal(range.getStart());
+            last = v11n.getOrdinal(range.getEnd());
         }
 
         /* (non-Javadoc)

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRangeFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRangeFactory.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRangeFactory.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -108,6 +108,7 @@
         String[] startParts = AccuracyType.tokenize(startVerseDesc);
         AccuracyType accuracyStart = AccuracyType.fromText(v11n, original, startParts, basis);
         Verse start = accuracyStart.createStartVerse(v11n, startVerseDesc, basis, startParts);
+        v11n.validate(start.getBook(), start.getChapter(), start.getVerse());
 
         String[] endParts;
         if (startVerseDesc.equals(endVerseDesc)) {
@@ -118,6 +119,7 @@
 
         AccuracyType accuracyEnd = AccuracyType.fromText(v11n, original, endParts, accuracyStart, basis);
         Verse end = accuracyEnd.createEndVerse(v11n, endVerseDesc, start, endParts);
+        v11n.validate(end.getBook(), end.getChapter(), end.getVerse());
 
         return new VerseRange(v11n, original, start, end);
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/DivisionName.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/DivisionName.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/DivisionName.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -26,6 +26,30 @@
 /**
  * DivisionName deals with traditional sections of the Bible.
  * 
+ * AV11N(DMS): Is this right?
+ * <ul>
+ * <li><strong>contains(BibleBook)</strong> - This has several problems:
+ * <ol>
+ * <li>The use of BibleBook.ordinal() is dependent upon the ordering of the
+ * members of the BibleBook enum. Currently it is ordered OT and NT according to
+ * the KJV and then has the deuterocanonical and apocryphal books in no
+ * particular order.</li>
+ * <li>Each versification defines the what books are present and the order of
+ * books. So for one versification, GEN might not be the first and REV might not
+ * be the last. E.g. Some V11Ns consist only of the OT.</li>
+ * </ol>
+ * </li>
+ * <li><strong>getSize()</strong> - This can vary by versification for at least
+ * BIBLE, OT and NT for those that include deuterocanonical or apocryphal books.
+ * </li>
+ * <li><strong>getRange()</strong> - This range is fixed text giving end points
+ * that may include BibleBooks that are not intended and may exclude BibleBooks
+ * that are intended. It works for the default Versification and may not work
+ * for others.</li>
+ * <li>A given V11N might be a single testament or just the gospels. In this case,
+ * it'd be good to know whether a division isDefined()</li>
+ * </ul>
+ * 
  * @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]
@@ -36,14 +60,12 @@
     BIBLE {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.GEN.ordinal() && bookNum <= BibleBook.REV.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 66;
         }
 
@@ -55,23 +77,20 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Gen-Rev";
         }
 
     },
-    /** OLD_TESTAMENT consists of the old testament (Gen - Rev) **/
+    /** OLD_TESTAMENT consists of the old testament (Gen - Mal) **/
     OLD_TESTAMENT {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.GEN.ordinal() && bookNum <= BibleBook.MAL.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 39;
         }
 
@@ -83,7 +102,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Gen-Mal";
         }
     },
@@ -91,14 +109,12 @@
     PENTATEUCH {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.GEN.ordinal() && bookNum <= BibleBook.DEUT.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 5;
         }
 
@@ -110,7 +126,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Gen-Deu";
         }
     },
@@ -118,14 +133,12 @@
     HISTORY {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.JOSH.ordinal() && bookNum <= BibleBook.ESTH.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 12;
         }
 
@@ -137,7 +150,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Jos-Est";
         }
     },
@@ -145,14 +157,12 @@
     POETRY {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.JOB.ordinal() && bookNum <= BibleBook.SONG.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 5;
         }
 
@@ -165,7 +175,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Job-Song";
         }
     },
@@ -173,14 +182,12 @@
     PROPHECY {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum == BibleBook.REV.ordinal() || bookNum >= BibleBook.ISA.ordinal() && bookNum <= BibleBook.MAL.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 18;
         }
 
@@ -197,7 +204,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Deu 28,Isa-Mal,Rev";
         }
     },
@@ -205,14 +211,12 @@
     MAJOR_PROPHETS {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.ISA.ordinal() && bookNum <= BibleBook.DAN.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 5;
         }
 
@@ -225,7 +229,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Isa-Dan";
         }
     },
@@ -233,14 +236,12 @@
     MINOR_PROPHETS {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.HOS.ordinal() && bookNum <= BibleBook.MAL.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 12;
         }
 
@@ -254,7 +255,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Hos-Mal";
         }
     },
@@ -262,14 +262,12 @@
     NEW_TESTAMENT {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.GEN.ordinal() && bookNum <= BibleBook.REV.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 27;
         }
 
@@ -281,7 +279,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Mat-Rev";
         }
     },
@@ -289,14 +286,12 @@
     GOSPELS_AND_ACTS {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.MATT.ordinal() && bookNum <= BibleBook.ACTS.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 5;
         }
 
@@ -309,7 +304,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Mat-Acts";
         }
     },
@@ -317,14 +311,12 @@
     LETTERS {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.ROM.ordinal() && bookNum <= BibleBook.JUDE.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 21;
         }
 
@@ -339,7 +331,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Rom-Jud";
         }
     },
@@ -347,14 +338,12 @@
     PAULINE_LETTERS {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.ROM.ordinal() && bookNum <= BibleBook.JUDE.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 14;
         }
 
@@ -368,7 +357,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Rom-Heb";
         }
     },
@@ -376,14 +364,12 @@
     GENERAL_LETTERS {
         @Override
         public boolean contains(BibleBook book) {
-            // AV11N(DMS): Is this right?
             int bookNum = book.ordinal();
             return bookNum >= BibleBook.ROM.ordinal() && bookNum <= BibleBook.JUDE.ordinal();
         }
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 7;
         }
 
@@ -396,7 +382,6 @@
 
         @Override
         public String getRange() {
-            // AV11N(DMS): Is this right?
             return "Jas-Jud";
         }
     },
@@ -409,7 +394,6 @@
 
         @Override
         public int getSize() {
-            // AV11N(DMS): Is this right?
             return 1;
         }
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/Versification.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/Versification.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/Versification.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -292,7 +292,7 @@
      */
     public boolean isStartOfChapter(Verse verse) {
         int v = verse.getVerse();
-        return v == 1 || v == 0;
+        return v == 0;
     }
 
     /**
@@ -301,8 +301,10 @@
      * @return true or false ...
      */
     public boolean isEndOfChapter(Verse verse) {
+        BibleBook b = verse.getBook();
         int v = verse.getVerse();
-        return v == getLastVerse(verse.getBook(), verse.getChapter());
+        int c = verse.getChapter();
+        return v == getLastVerse(b, c);
     }
 
     /**
@@ -313,7 +315,7 @@
     public boolean isStartOfBook(Verse verse) {
         int v = verse.getVerse();
         int c = verse.getChapter();
-        return (v == 1 || v == 0) && (c == 1 || c == 0);
+        return v == 0 && c == 0;
     }
 
     /**
@@ -342,12 +344,14 @@
     /**
      * Is this verse in the same book as that one
      *
-     * @param that
+     * @param a
      *            The verse to compare to
+     * @param b
+     *            The verse to compare to
      * @return true or false ...
      */
-    public boolean isSameBook(Verse a, Verse that) {
-        return a.getBook() == that.getBook();
+    public boolean isSameBook(Verse a, Verse b) {
+        return a.getBook() == b.getBook();
     }
 
     /**
@@ -374,10 +378,30 @@
      * @return The count of verses between this and that.
      */
     public int distance(Verse start, Verse end) {
-        return getOrdinal(start) - getOrdinal(end);
+        return getOrdinal(end) - getOrdinal(start);
     }
 
     /**
+     * Determine the earlier of the two verses. If a == b then return a.
+     * @param a the first verse to compare
+     * @param b the second verse to compare
+     * @return The earlier of the two verses
+     */
+    public Verse min(Verse a, Verse b) {
+        return getOrdinal(a) <= getOrdinal(b) ? a : b;
+    }
+
+    /**
+     * Determine the later of the two verses. If a == b then return b.
+     * @param a the first verse to compare
+     * @param b the second verse to compare
+     * @return The later of the two verses
+     */
+    public Verse max(Verse a, Verse b) {
+        return getOrdinal(a) > getOrdinal(b) ? a : b;
+    }
+
+    /**
      * Get the verse n down from here this Verse.
      *
      * @param n
@@ -556,10 +580,6 @@
      */
     public Verse decodeOrdinal(int ordinal) {
         int ord = ordinal;
-        BibleBook book = null;
-        int bookIndex = -1;
-        int chapterIndex = 0;
-        int verse = 0;
 
         if (ord < 0) {
             ord = 0;
@@ -583,29 +603,55 @@
             return new Verse(BibleBook.INTRO_NT, 0, 0);
         }
 
-        int lastBook = chapterStarts.length - 1;
-        for (int b = lastBook; b >= 0; b--) {
-            // A book has a slot for a heading followed by a slot for a chapter heading.
-            // These precede the start of the chapter.
-            if (ord >= chapterStarts[b][0]) {
-                bookIndex = b;
+        // To find the book, do a binary search in chapterStarts against chapter 0
+        int low = 0;
+        int high = chapterStarts.length;
+        int match = -1;
+
+        while (high - low > 1) {
+            // use >>> to keep mid always in range
+            int mid = (low + high) >>> 1;
+
+            // Compare the for the item at "mid"
+            int cmp = chapterStarts[mid][0] - ord;
+            if (cmp < 0) {
+                low = mid;
+            } else if (cmp > 0) {
+                high = mid;
+            } else {
+                match = mid;
                 break;
             }
         }
 
-        book = bookList.getBook(bookIndex);
-        int cib = getLastChapter(book);
-        for (int c = cib; c >= 0; c--) {
-            if (ord >= chapterStarts[bookIndex][c]) {
-                chapterIndex = c;
+        // If we didn't have an exact match then use the low value
+        int bookIndex = match >= 0 ? match : low;
+        BibleBook book = bookList.getBook(bookIndex);
+
+        // To find the chapter, do a binary search in chapterStarts against bookIndex
+        low = 0;
+        high = chapterStarts[bookIndex].length;
+        match = -1;
+
+        while (high - low > 1) {
+            // use >>> to keep mid always in range
+            int mid = (low + high) >>> 1;
+
+            // Compare the for the item at "mid"
+            int cmp = chapterStarts[bookIndex][mid] - ord;
+            if (cmp < 0) {
+                low = mid;
+            } else if (cmp > 0) {
+                high = mid;
+            } else {
+                match = mid;
                 break;
             }
         }
 
-        if (chapterIndex > 0) {
-            verse = ord - chapterStarts[bookIndex][chapterIndex];
-        }
-
+        // If we didn't have an exact match then use the low value
+        int chapterIndex = match >= 0 ? match : low;
+        int verse = chapterIndex == 0 ? 0 : ord - chapterStarts[bookIndex][chapterIndex];
         return new Verse(book, chapterIndex, verse);
     }
 
@@ -706,6 +752,11 @@
             patchedVerse = 0;
         }
 
+        // Goal is to start in the current book and go forward that number of chapters
+        // which might cause one to land in a later book.
+        // For each book, the chapters number from 0 to n, where n is the last chapter number.
+        // So if we want Genesis 53, then that would be 3 chapters into Exodus,
+        // which would be chapter 2.
         while (patchedChapter > getLastChapter(patchedBook)) {
             patchedChapter -= getLastChapter(patchedBook) + 1;
             patchedBook = bookList.getNextBook(patchedBook);
@@ -720,12 +771,17 @@
             }
         }
 
+        // At this point we have a valid chapter.
+        // Now we do the same for the verses.
+        // For each book, the chapters number from 0 to n, where n is the last chapter number.
+        // So if we want Genesis 49:36, then that would be 3 verses into Genesis 50,
+        // which would be verse 50:2.     
         while (patchedVerse > getLastVerse(patchedBook, patchedChapter)) {
-            patchedVerse -= getLastVerse(patchedBook, patchedChapter);
+            patchedVerse -= getLastVerse(patchedBook, patchedChapter) + 1;
             patchedChapter += 1;
 
             if (patchedChapter > getLastChapter(patchedBook)) {
-                patchedChapter -= getLastChapter(patchedBook);
+                patchedChapter -= getLastChapter(patchedBook) + 1;
                 patchedBook = bookList.getNextBook(patchedBook);
 
                 // If we have gone beyond the last book

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -115,7 +115,7 @@
         start = System.currentTimeMillis();
         gen1_135 = (Passage) keyf.getKey(v11n, "Gen 1:1, Gen 1:3, Gen 1:5");
         exo2a_3b = (Passage) keyf.getKey(v11n, "Exo 2:1-10, Exo 3:1-11");
-        gen_rev = (Passage) keyf.getKey(v11n, "Gen 1:1-Rev 22:21");
+        gen_rev = (Passage) keyf.getKey(v11n, "Gen-Rev 22:21");
         grace = (Passage) keyf.createEmptyKeyList(v11n);
         grace.addAll(keyf.getKey(v11n, "Gen 6:8, 19:19, 32:5, 33:8, 10, 15, 39:4, 47:25, 29, 50:4, Exo 33:12-13, 16-17, 34:9, Num 32:5, Judg 6:17, Rut 2:2, 10, 1Sa 1:18, 20:3, 27:5"));
         grace.addAll(keyf.getKey(v11n, "2Sa 14:22, 16:4, Ezr 9:8, Est 2:17, Psa 45:2, 84:11, Pro 1:9, 3:22, 34, 4:9, 22:11, Jer 31:2, Zec 4:7, 12:10, Luk 2:40, Joh 1:14, 16-17"));
@@ -186,13 +186,13 @@
 
         it = gen_rev.rangeIterator(RestrictionType.CHAPTER);
         assertTrue(it.hasNext());
+        assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 0"));
+        assertTrue(it.hasNext());
         assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 1"));
         assertTrue(it.hasNext());
         assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 2"));
         assertTrue(it.hasNext());
         assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 3"));
-        assertTrue(it.hasNext());
-        assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 4"));
         // assertTrue(!it.hasNext());
 
         it = empty.rangeIterator(RestrictionType.NONE);
@@ -320,54 +320,6 @@
         }
     }
 
-    public void testReadChaptersInPassage() throws Exception {
-        // for (int i=0; i<3; i++)
-        {
-            assertEquals(1, gen1_135.chaptersInPassage(BibleBook.GEN));
-            assertEquals(0, exo2a_3b.chaptersInPassage(BibleBook.GEN));
-            assertEquals(0, gen1_135.chaptersInPassage(BibleBook.EXOD));
-            assertEquals(2, exo2a_3b.chaptersInPassage(BibleBook.EXOD));
-            assertEquals(0, gen1_135.chaptersInPassage(BibleBook.LEV));
-            assertEquals(0, exo2a_3b.chaptersInPassage(BibleBook.LEV));
-            assertEquals(1, gen1_135.chaptersInPassage(null));
-            assertEquals(2, exo2a_3b.chaptersInPassage(null));
-        }
-    }
-
-    public void testReadVersesInPassage() throws Exception {
-        // for (int i=0; i<1; i++)
-        {
-            assertEquals(3, gen1_135.versesInPassage(BibleBook.GEN, 1));
-            assertEquals(0, exo2a_3b.versesInPassage(BibleBook.GEN, 1));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.GEN, 2));
-            assertEquals(0, exo2a_3b.versesInPassage(BibleBook.GEN, 2));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.EXOD, 1));
-            assertEquals(0, exo2a_3b.versesInPassage(BibleBook.EXOD, 1));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.EXOD, 2));
-            assertEquals(10, exo2a_3b.versesInPassage(BibleBook.EXOD, 2));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.EXOD, 3));
-            assertEquals(11, exo2a_3b.versesInPassage(BibleBook.EXOD, 3));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.EXOD, 4));
-            assertEquals(0, exo2a_3b.versesInPassage(BibleBook.EXOD, 4));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.LEV, 1));
-            assertEquals(0, exo2a_3b.versesInPassage(BibleBook.LEV, 1));
-            assertEquals(3, gen1_135.versesInPassage(BibleBook.GEN, 0));
-            assertEquals(0, exo2a_3b.versesInPassage(BibleBook.GEN, 0));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.EXOD, 0));
-            assertEquals(21, exo2a_3b.versesInPassage(BibleBook.EXOD, 0));
-            assertEquals(0, gen1_135.versesInPassage(BibleBook.LEV, 0));
-            assertEquals(0, exo2a_3b.versesInPassage(BibleBook.LEV, 0));
-            assertEquals(3, gen1_135.versesInPassage(null, 1));
-            assertEquals(0, exo2a_3b.versesInPassage(null, 1));
-            assertEquals(0, gen1_135.versesInPassage(null, 2));
-            assertEquals(10, exo2a_3b.versesInPassage(null, 2));
-            assertEquals(0, gen1_135.versesInPassage(null, 3));
-            assertEquals(11, exo2a_3b.versesInPassage(null, 3));
-            assertEquals(gen1_135.countVerses(), gen1_135.versesInPassage(null, 0));
-            assertEquals(exo2a_3b.countVerses(), exo2a_3b.versesInPassage(null, 0));
-        }
-    }
-
     public void testReadContainsVerse() {
         // for (int i=0; i<1200; i++)
         {
@@ -428,29 +380,29 @@
     // ==========================================================================
 
     public void testWriteCreatePassage() {
-        assertEquals(((Passage) keyf.createEmptyKeyList(v11n)).countVerses(), 0);
+        assertEquals(0, ((Passage) keyf.createEmptyKeyList(v11n)).countVerses());
     }
 
     public void testWriteToString() throws Exception {
-        assertEquals(keyf.getKey(v11n, "gen 1 1,gen 1 3,rev 22 21,gen 1 2").toString(), "Gen 1:1-3, Rev 22:21");
-        assertEquals(
-                keyf.getKey(v11n, "Gen 1 3;gen 22 2;rev 22 21;gen 22 3-10; rev 22 19;gen 1 1;rev 22 10-18; gen 1 2; rev 22 1-21").toString(), "Gen 1:1-3, 22:2-10, Rev 22");
-        assertEquals(keyf.getKey(v11n, "").toString(), "");
-        assertEquals(keyf.getKey(v11n, "gen 1 1-50:26,e,e 1 2,e 1 3-10").toString(), "Gen-Exo");
-        assertEquals(keyf.getKey(v11n, null).toString(), "");
+        assertEquals("Gen 1:1-3, Rev 22:21", keyf.getKey(v11n, "gen 1 1,gen 1 3,rev 22 21,gen 1 2").toString());
+        assertEquals("Gen 1:1-3, 22:2-10, Rev 22:1-21",
+                keyf.getKey(v11n, "Gen 1 3;gen 22 2;rev 22 21;gen 22 3-10; rev 22 19;gen 1 1;rev 22 10-18; gen 1 2; rev 22 1-21").toString());
+        assertEquals("", keyf.getKey(v11n, "").toString());
+        assertEquals("Gen 1:1-Exo 40:38", keyf.getKey(v11n, "gen 1 1-50:26,e,e 1 2,e 1 3-10").toString());
+        assertEquals("", keyf.getKey(v11n, null).toString());
     }
 
     public void testWriteGetName() throws Exception {
-        assertEquals(keyf.getKey(v11n, "gen 1 1,gen 1 3,rev 22 21,gen 1 2").getName(), "Gen 1:1-3, Rev 22:21");
-        assertEquals(
-                keyf.getKey(v11n, "Gen 1 3;gen 22 2;rev 22 21;gen 22 3-10; rev 22 19;gen 1 1;rev 22 10-18; gen 1 2; rev 22 1-21").getName(), "Gen 1:1-3, 22:2-10, Rev 22");
-        assertEquals(keyf.getKey(v11n, "").getName(), "");
-        assertEquals(keyf.getKey(v11n, "gen 1 1-50:26,e,e 1 2,e 1 3-10").getName(), "Gen-Exo");
-        assertEquals(keyf.getKey(v11n, "exo 1:1, 4").getName(), "Exo 1:1, 4");
-        assertEquals(keyf.getKey(v11n, "exo 1:1, 4, 2-3, 11-ff, 6-10").getName(), "Exo 1:1-4, 6-22");
-        assertEquals(keyf.getKey(v11n, "Num 1, 2").getName(), "Num 1-2");
+        assertEquals("Gen 1:1-3, Rev 22:21", keyf.getKey(v11n, "gen 1 1,gen 1 3,rev 22 21,gen 1 2").getName());
+        assertEquals("Gen 1:1-3, 22:2-10, Rev 22:1-21", 
+                keyf.getKey(v11n, "Gen 1 3;gen 22 2;rev 22 21;gen 22 3-10; rev 22 19;gen 1 1;rev 22 10-18; gen 1 2; rev 22 1-21").getName());
+        assertEquals("", keyf.getKey(v11n, "").getName());
+        assertEquals("Gen 1:1-Exo 40:38", keyf.getKey(v11n, "gen 1 1-50:26,e,e 1 2,e 1 3-10").getName());
+        assertEquals("Exo 1:1, 4", keyf.getKey(v11n, "exo 1:1, 4").getName());
+        assertEquals("Exo 1:1-4, 6-22", keyf.getKey(v11n, "exo 1:1, 4, 2-3, 11-ff, 6-10").getName());
+        assertEquals("Num 1-2", keyf.getKey(v11n, "Num 1, 2").getName());
         // Test for the separator being a space. This comes from "Clarke"
-        assertEquals(keyf.getKey(v11n, "Ge 1:26  3:22  11:7  20:13  31:7, 53  35:7").getName(), "Gen 1:26, 3:22, 11:7, 20:13, 31:7, 53, 35:7");
+        assertEquals("Gen 1:26, 3:22, 11:7, 20:13, 31:7, 53, 35:7", keyf.getKey(v11n, "Ge 1:26  3:22  11:7  20:13  31:7, 53  35:7").getName());
     }
 
     public void testWriteBlur() throws Exception {
@@ -462,31 +414,31 @@
         // assertEquals(temp, gen1_135);
         temp = (Passage) gen1_135.clone();
         temp.blur(1, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Gen 1:1-6"));
+        assertEquals(temp, keyf.getKey(v11n, "Gen 1:0-6"));
         temp = (Passage) gen1_135.clone();
         temp.blur(1, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Gen 1:0-6"));
         temp = (Passage) gen1_135.clone();
         temp.blur(2, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Gen 1:1-7"));
+        assertEquals(temp, keyf.getKey(v11n, "Gen 1:0-7"));
         temp = (Passage) gen1_135.clone();
         temp.blur(2, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Gen 0:0-1:7"));
         temp = (Passage) gen1_135.clone();
         temp.blur(12, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Gen 1:1-17"));
+        assertEquals(temp, keyf.getKey(v11n, "Gen 1:0-17"));
         temp = (Passage) gen1_135.clone();
         temp.blur(12, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Intro.OT 0:0-Gen 1:17"));
         temp = (Passage) gen1_135.clone();
         temp.blur(26, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Gen 1:1-31"));
+        assertEquals(temp, keyf.getKey(v11n, "Gen 1:0-31"));
         temp = (Passage) gen1_135.clone();
         temp.blur(26, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Intro.OT-Gen 1:31"));
         temp = (Passage) gen1_135.clone();
         temp.blur(27, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Gen 1:1-31"));
+        assertEquals(temp, keyf.getKey(v11n, "Gen 1:0-31"));
         temp = (Passage) gen1_135.clone();
         temp.blur(27, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Intro.OT-Gen 2:0"));
@@ -498,31 +450,31 @@
         //        assertEquals(temp, keyf.getKey(v11n, "Exo 2:1-10, Exo 3:1-11"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(1, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Exo 2:1-11, Exo 3:1-12"));
+        assertEquals(temp, keyf.getKey(v11n, "Exo 2:0-11, Exo 3:0-12"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(1, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Exo 2:0-2:11, Exo 3:0-3:12"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(2, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Exo 2:1-12, Exo 3:1-13"));
+        assertEquals(temp, keyf.getKey(v11n, "Exo 2:0-12, Exo 3:0-13"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(2, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Exo 1:22-2:12, Exo 2:25-3:13"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(3, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Exo 2:1-13, Exo 3:1-14"));
+        assertEquals(temp, keyf.getKey(v11n, "Exo 2:0-13, Exo 3:0-14"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(3, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Exo 1:21-2:13, Exo 2:24-3:14"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(14, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Exo 2:1-24, Exo 3:1-22"));
+        assertEquals(temp, keyf.getKey(v11n, "Exo 2:0-24, Exo 3:0-22"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(14, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Exo 1:10-2:24, Exo 2:12-4:2"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(15, RestrictionType.CHAPTER);
-        assertEquals(temp, keyf.getKey(v11n, "Exo 2:1-25, Exo 3:1-22"));
+        assertEquals(temp, keyf.getKey(v11n, "Exo 2:0-25, Exo 3:0-22"));
         temp = (Passage) exo2a_3b.clone();
         temp.blur(15, RestrictionType.NONE);
         assertEquals(temp, keyf.getKey(v11n, "Exo 1:9-2:25, Exo 2:11-4:3"));
@@ -599,13 +551,13 @@
 
         it = gen_rev.rangeIterator(RestrictionType.CHAPTER);
         assertTrue(it.hasNext());
+        assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 0"));
+        assertTrue(it.hasNext());
         assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 1"));
         assertTrue(it.hasNext());
         assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 2"));
         assertTrue(it.hasNext());
         assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 3"));
-        assertTrue(it.hasNext());
-        assertEquals(it.next(), VerseRangeFactory.fromString(v11n, "Gen 4"));
         // assertTrue(!it.hasNext());
 
         it = empty.rangeIterator(RestrictionType.NONE);
@@ -666,48 +618,6 @@
         assertEquals(exo2a_3b.booksInPassage(), 1);
     }
 
-    public void testWriteChaptersInPassage() throws Exception {
-        assertEquals(gen1_135.chaptersInPassage(BibleBook.GEN), 1);
-        assertEquals(exo2a_3b.chaptersInPassage(BibleBook.GEN), 0);
-        assertEquals(gen1_135.chaptersInPassage(BibleBook.EXOD), 0);
-        assertEquals(exo2a_3b.chaptersInPassage(BibleBook.EXOD), 2);
-        assertEquals(gen1_135.chaptersInPassage(BibleBook.LEV), 0);
-        assertEquals(exo2a_3b.chaptersInPassage(BibleBook.LEV), 0);
-        assertEquals(gen1_135.chaptersInPassage(null), 1);
-        assertEquals(exo2a_3b.chaptersInPassage(null), 2);
-    }
-
-    public void testWriteVersesInPassage() throws Exception {
-        assertEquals(gen1_135.versesInPassage(BibleBook.GEN, 1), 3);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.GEN, 1), 0);
-        assertEquals(gen1_135.versesInPassage(BibleBook.GEN, 2), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.GEN, 2), 0);
-        assertEquals(gen1_135.versesInPassage(BibleBook.EXOD, 1), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.EXOD, 1), 0);
-        assertEquals(gen1_135.versesInPassage(BibleBook.EXOD, 2), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.EXOD, 2), 10);
-        assertEquals(gen1_135.versesInPassage(BibleBook.EXOD, 3), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.EXOD, 3), 11);
-        assertEquals(gen1_135.versesInPassage(BibleBook.EXOD, 4), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.EXOD, 4), 0);
-        assertEquals(gen1_135.versesInPassage(BibleBook.LEV, 1), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.LEV, 1), 0);
-        assertEquals(gen1_135.versesInPassage(BibleBook.GEN, 0), 3);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.GEN, 0), 0);
-        assertEquals(gen1_135.versesInPassage(BibleBook.EXOD, 0), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.EXOD, 0), 21);
-        assertEquals(gen1_135.versesInPassage(BibleBook.LEV, 0), 0);
-        assertEquals(exo2a_3b.versesInPassage(BibleBook.LEV, 0), 0);
-        assertEquals(gen1_135.versesInPassage(null, 1), 3);
-        assertEquals(exo2a_3b.versesInPassage(null, 1), 0);
-        assertEquals(gen1_135.versesInPassage(null, 2), 0);
-        assertEquals(exo2a_3b.versesInPassage(null, 2), 10);
-        assertEquals(gen1_135.versesInPassage(null, 3), 0);
-        assertEquals(exo2a_3b.versesInPassage(null, 3), 11);
-        assertEquals(gen1_135.versesInPassage(null, 0), gen1_135.countVerses());
-        assertEquals(exo2a_3b.versesInPassage(null, 0), exo2a_3b.countVerses());
-    }
-
     public void testWriteContainsVerse() {
         assertTrue(!empty.contains(gen11));
         assertTrue(gen1_135.contains(gen11));

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -296,9 +296,8 @@
     public void testBlur() {
         temp = tally.clone();
         temp.blur(1, RestrictionType.NONE);
-        assertEquals(
-                temp.getNameAndTally(),
-                "Gen 1:1 (100%), Gen 1:2 (100%), Gen 1:0 (75%), Gen 1:4 (75%), Gen 1:5 (75%), Gen 1:6 (75%), Gen 1:3 (50%), Gen 1:7 (50%), Gen 2:1 (50%), Gen 3:1 (50%), Gen 1:8 (25%), Gen 1:31 (25%), Gen 2:2 (25%), Gen 2:25 (25%), Gen 3:2 (25%)");
+        assertEquals("Gen 1:1 (100%), Gen 1:2 (100%), Gen 1:0 (75%), Gen 1:4 (75%), Gen 1:5 (75%), Gen 1:6 (75%), Gen 1:3 (50%), Gen 1:7 (50%), Gen 2:1 (50%), Gen 3:1 (50%), Gen 1:8 (25%), Gen 2:0 (25%), Gen 2:2 (25%), Gen 3:0 (25%), Gen 3:2 (25%)",
+                temp.getNameAndTally());
         // temp = (PassageTally) tally.clone();
         // temp.blur(1, Verse.RESTRICT_CHAPTER);
         // assertEquals(temp.getOrderedNameAndTally(),

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageUtilTest.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -21,6 +21,8 @@
  */
 package org.crosswire.jsword.passage;
 
+import org.crosswire.jsword.book.CaseType;
+import org.crosswire.jsword.versification.BookName;
 import org.crosswire.jsword.versification.Versification;
 import org.crosswire.jsword.versification.system.Versifications;
 
@@ -42,6 +44,10 @@
      * How we create Passages
      */
     private static PassageKeyFactory keyf = PassageKeyFactory.instance();
+    /** Control the output of names */
+    private CaseType storedCase;
+    private boolean fullName;
+    private boolean persist;
     private Versification v11n;
 
     /*
@@ -51,6 +57,12 @@
      */
     @Override
     protected void setUp() throws Exception {
+        storedCase = BookName.getDefaultCase();
+        BookName.setCase(CaseType.SENTENCE);
+        fullName = BookName.isFullBookName();
+        BookName.setFullBookName(false);
+        persist = PassageUtil.isPersistentNaming();
+
         // AV11N(DMS): Update test to test all V11Ns
         v11n = Versifications.instance().getDefaultVersification();
     }
@@ -62,6 +74,9 @@
      */
     @Override
     protected void tearDown() throws Exception {
+        BookName.setCase(storedCase);
+        BookName.setFullBookName(fullName);
+        PassageUtil.setPersistentNaming(persist);
     }
 
     public void testOther() {
@@ -76,26 +91,24 @@
     }
 
     public void testPersistentNaming() throws Exception {
-        boolean stored_naming = PassageUtil.isPersistentNaming();
         PassageUtil.setPersistentNaming(false);
         assertTrue(!PassageUtil.isPersistentNaming());
-        assertEquals(VerseFactory.fromString(v11n, "Genesis 1 1").toString(), "Gen 1:1");
-        assertEquals(VerseFactory.fromString(v11n, "Gen 1 1").toString(), "Gen 1:1");
-        assertEquals(VerseFactory.fromString(v11n, "Genesis 1:1").toString(), "Gen 1:1");
-        assertEquals(VerseFactory.fromString(v11n, "Gen 1 1").toString(), "Gen 1:1");
-        assertEquals(VerseFactory.fromString(v11n, "g 1 1").toString(), "Gen 1:1");
-        assertEquals(VerseFactory.fromString(v11n, "g").toString(), "Gen 0:0");
-        assertEquals(VerseFactory.fromString(v11n, "G:1:1").toString(), "Gen 1:1");
+        assertEquals("Gen 1:1", VerseFactory.fromString(v11n, "Genesis 1 1").toString());
+        assertEquals("Gen 1:1", VerseFactory.fromString(v11n, "Gen 1 1").toString());
+        assertEquals("Gen 1:1", VerseFactory.fromString(v11n, "Genesis 1:1").toString());
+        assertEquals("Gen 1:1", VerseFactory.fromString(v11n, "Gen 1 1").toString());
+        assertEquals("Gen 1:1", VerseFactory.fromString(v11n, "g 1 1").toString());
+        assertEquals("Gen 0:0", VerseFactory.fromString(v11n, "g").toString());
+        assertEquals("Gen 1:1", VerseFactory.fromString(v11n, "G:1:1").toString());
         PassageUtil.setPersistentNaming(true);
         assertTrue(PassageUtil.isPersistentNaming());
-        assertEquals(VerseFactory.fromString(v11n, "Genesis 1 1").toString(), "Genesis 1 1");
-        assertEquals(VerseFactory.fromString(v11n, "Gen 1 1").toString(), "Gen 1 1");
-        assertEquals(VerseFactory.fromString(v11n, "Genesis 1:1").toString(), "Genesis 1:1");
-        assertEquals(VerseFactory.fromString(v11n, "Gen 1 1").toString(), "Gen 1 1");
-        assertEquals(VerseFactory.fromString(v11n, "g 1 1").toString(), "g 1 1");
-        assertEquals(VerseFactory.fromString(v11n, "g").toString(), "g");
-        assertEquals(VerseFactory.fromString(v11n, "G:1:1").toString(), "G:1:1");
-        PassageUtil.setPersistentNaming(stored_naming);
+        assertEquals("Genesis 1 1", VerseFactory.fromString(v11n, "Genesis 1 1").toString());
+        assertEquals("Gen 1 1", VerseFactory.fromString(v11n, "Gen 1 1").toString());
+        assertEquals("Genesis 1:1", VerseFactory.fromString(v11n, "Genesis 1:1").toString());
+        assertEquals("Gen 1 1", VerseFactory.fromString(v11n, "Gen 1 1").toString());
+        assertEquals("g 1 1", VerseFactory.fromString(v11n, "g 1 1").toString());
+        assertEquals("g", VerseFactory.fromString(v11n, "g").toString());
+        assertEquals("G:1:1", VerseFactory.fromString(v11n, "G:1:1").toString());
     }
 
     public void testTokenize() {

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -25,7 +25,9 @@
 
 import junit.framework.TestCase;
 
+import org.crosswire.jsword.book.CaseType;
 import org.crosswire.jsword.versification.BibleBook;
+import org.crosswire.jsword.versification.BookName;
 import org.crosswire.jsword.versification.Versification;
 import org.crosswire.jsword.versification.system.Versifications;
 
@@ -41,10 +43,18 @@
         super(s);
     }
 
+    /** Control the output of names */
+    private CaseType storedCase;
+    private boolean fullName;
+
     private Versification v11n;
+    private VerseRange gen10_9 = null;
+    private VerseRange gen10_1 = null;
     private VerseRange gen11_1 = null;
+    private VerseRange gen10_2 = null;
     private VerseRange gen11_2 = null;
     private VerseRange gen11_9 = null;
+    private VerseRange gen10_a = null;
     private VerseRange gen11_a = null;
     private VerseRange gen12_1 = null;
     private VerseRange gen_all = null;
@@ -55,59 +65,65 @@
     private VerseRange rev11_9 = null;
     private VerseRange rev99_1 = null;
 
+    private Verse gen00 = null;
     private Verse gen11 = null;
     private Verse gen12 = null;
     private Verse gen19 = null;
     private Verse gen21 = null;
     private Verse gen99 = null;
     private Verse exo11 = null;
+    private Verse rev00 = null;
     private Verse rev11 = null;
     private Verse rev12 = null;
     private Verse rev99 = null;
+    private Verse rev90 = null;
     private Verse rev91 = null;
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see junit.framework.TestCase#setUp()
-     */
     @Override
     protected void setUp() throws Exception {
+        storedCase = BookName.getDefaultCase();
+        BookName.setCase(CaseType.SENTENCE);
+        fullName = BookName.isFullBookName();
+        BookName.setFullBookName(false);
         // AV11N(DMS): Update test to test all V11Ns
         v11n = Versifications.instance().getDefaultVersification();
 
+        gen10_9 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 0), 32);
+        gen10_1 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 0), 2);
         gen11_1 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 1);
+        gen10_2 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 0), 3);
         gen11_2 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 2);
         gen11_9 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 31);
+        gen10_a = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 0), 34);
         gen11_a = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 33);
         gen12_1 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 2), 1);
-        gen_all = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 1582);
-        gen_ex1 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 1585);
-        gen_exo = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 2746);
+        gen_all = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 0, 0), 1584);
+        gen_ex1 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 0, 0), 1587);
+        gen_exo = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 0, 0), 2838);
         gen_rev = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.GEN, 1, 1), 32356);
-        rev99_9 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.REV, 22, 1), 21);
-        rev11_9 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.REV, 1, 1), 425);
+        rev99_9 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.REV, 22, 0), 22);
+        rev11_9 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.REV, 0, 0), 428);
         rev99_1 = RestrictionType.NONE.toRange(v11n, new Verse(BibleBook.REV, 22, 21), 1);
 
+        gen00 = new Verse(BibleBook.GEN, 0, 0);
         gen11 = new Verse(BibleBook.GEN, 1, 1);
         gen12 = new Verse(BibleBook.GEN, 1, 2);
         gen19 = new Verse(BibleBook.GEN, 1, 31);
         gen21 = new Verse(BibleBook.GEN, 2, 1);
         gen99 = new Verse(BibleBook.GEN, 50, 26);
         exo11 = new Verse(BibleBook.EXOD, 1, 1);
+        rev00 = new Verse(BibleBook.REV, 0, 0);
         rev11 = new Verse(BibleBook.REV, 1, 1);
         rev12 = new Verse(BibleBook.REV, 1, 2);
         rev99 = new Verse(BibleBook.REV, 22, 21);
+        rev90 = new Verse(BibleBook.REV, 22, 0);
         rev91 = new Verse(BibleBook.REV, 22, 1);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see junit.framework.TestCase#tearDown()
-     */
     @Override
     protected void tearDown() {
+        BookName.setCase(storedCase);
+        BookName.setFullBookName(fullName);
     }
 
     public void testNewViaString() throws Exception {
@@ -115,16 +131,16 @@
         assertEquals(gen11_2, VerseRangeFactory.fromString(v11n, "Gen 1:1-2"));
         assertEquals(gen11_2, VerseRangeFactory.fromString(v11n, "Gen 1:1-1:2"));
         assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-50:26"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-50:$"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-50:ff"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-$:26"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-ff:26"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-$:$"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-$:ff"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-ff:$"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-ff:ff"));
-        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "Gen 1:1-Exo 1:1"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-50:26"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-50:$"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-50:ff"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-$:26"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-ff:26"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-$:$"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-$:ff"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-ff:$"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-ff:ff"));
+        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "Gen 0:0-Exo 1:1"));
         assertEquals(gen_exo, VerseRangeFactory.fromString(v11n, "Gen-Exo"));
         assertEquals(gen_rev, VerseRangeFactory.fromString(v11n, "Gen 1:1-Rev 22:21"));
         assertEquals(gen_rev, VerseRangeFactory.fromString(v11n, "Gen 1:1-Rev 22:$"));
@@ -134,33 +150,37 @@
         assertEquals(rev99_1, VerseRangeFactory.fromString(v11n, "Rev 22:21-21"));
         assertEquals(gen11_1, VerseRangeFactory.fromString(v11n, "Gen 1:1-Gen 1:1"));
         assertEquals(gen11_2, VerseRangeFactory.fromString(v11n, "Gen 1:1-Gen 1:2"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-50:26"));
-        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 1:1-Gen 50:26"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-50:26"));
+        assertEquals(gen_all, VerseRangeFactory.fromString(v11n, "Gen 0:0-Gen 50:26"));
         assertEquals(rev99_1, VerseRangeFactory.fromString(v11n, "Rev 22:21-Rev 22:21"));
         assertEquals(rev99_1, VerseRangeFactory.fromString(v11n, "Rev 22:21-Rev 22:ff"));
         assertEquals(rev99_1, VerseRangeFactory.fromString(v11n, "Rev 22:21-Rev 22:$"));
         assertEquals(rev99_1, VerseRangeFactory.fromString(v11n, "Rev 22:21-$"));
         assertEquals(rev99_1, VerseRangeFactory.fromString(v11n, "Rev 22:21-21"));
         assertEquals(gen11_1, VerseRangeFactory.fromString(v11n, "Gen 1:1-1:1"));
-        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "g 1 1-e 1 1"));
-        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "g 1-e 1 1"));
-        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "Genesis 1:1-e 1 1"));
+        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "g 0 0-e 1 1"));
+        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "g -e 1 1"));
+        assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "Genesis 0:0-e 1 1"));
         assertEquals(gen_ex1, VerseRangeFactory.fromString(v11n, "g-e:1:1"));
         try {
-            VerseRangeFactory.fromString(v11n, "Gen 1:1-Gen 1:2-Gen 1:3");fail();}
-        catch (NoSuchVerseException ex) {
+            VerseRangeFactory.fromString(v11n, "Gen 1:1-Gen 1:2-Gen 1:3");
+            fail();
+        } catch (NoSuchVerseException ex) {
         }
         try {
-            VerseRangeFactory.fromString(v11n, "Gen 1:1-2-3");fail();}
-        catch (NoSuchVerseException ex) {
+            VerseRangeFactory.fromString(v11n, "Gen 1:1-2-3");
+            fail();
+        } catch (NoSuchVerseException ex) {
         }
         try {
-            VerseRangeFactory.fromString(v11n, "b 1:1-2");fail();}
-        catch (NoSuchVerseException ex) {
+            VerseRangeFactory.fromString(v11n, "b 1:1-2");
+            fail();
+        } catch (NoSuchVerseException ex) {
         }
         try {
-            VerseRangeFactory.fromString(v11n, "g-f 1 2");fail();}
-        catch (NoSuchVerseException ex) {
+            VerseRangeFactory.fromString(v11n, "g-f 1 2");
+            fail();
+        } catch (NoSuchVerseException ex) {
         }
         try {
             VerseRangeFactory.fromString(v11n, (String) null);
@@ -173,31 +193,31 @@
     }
 
     public void testToString() {
-        assertEquals(gen11_1.toString(), "Gen 1:1");
-        assertEquals(gen11_2.toString(), "Gen 1:1-2");
-        assertEquals(gen11_9.toString(), "Gen 1");
-        assertEquals(gen11_a.toString(), "Gen 1:1-2:1");
-        assertEquals(gen12_1.toString(), "Gen 1:2");
-        assertEquals(gen_all.toString(), "Gen");
-        assertEquals(gen_ex1.toString(), "Gen 1:1-Exo 1:1");
-        assertEquals(gen_rev.toString(), "Gen-Rev");
-        assertEquals(rev99_9.toString(), "Rev 22");
-        assertEquals(rev11_9.toString(), "Rev");
-        assertEquals(rev99_1.toString(), "Rev 22:21");
+        assertEquals("Gen 1:1", gen11_1.toString());
+        assertEquals("Gen 1:1-2", gen11_2.toString());
+        assertEquals("Gen 1:1-31", gen11_9.toString());
+        assertEquals("Gen 1:1-2:1", gen11_a.toString());
+        assertEquals("Gen 1:2", gen12_1.toString());
+        assertEquals("Gen", gen_all.toString());
+        assertEquals("Gen 0:0-Exo 1:1", gen_ex1.toString());
+        assertEquals("Gen 1:1-Rev 22:21", gen_rev.toString());
+        assertEquals("Rev 22", rev99_9.toString());
+        assertEquals("Rev", rev11_9.toString());
+        assertEquals("Rev 22:21", rev99_1.toString());
     }
 
     public void testPersistentNaming() throws Exception {
         PassageUtil.setPersistentNaming(false);
-        assertEquals(VerseRangeFactory.fromString(v11n, "1corinth 8-9").toString(), "1Cor 8-9");
-        assertEquals(VerseRangeFactory.fromString(v11n, "Genesis 1 1").toString(), "Gen 1:1");
-        assertEquals(VerseRangeFactory.fromString(v11n, "g 1 1-e 1 1").toString(), "Gen 1:1-Exo 1:1");
-        assertEquals(VerseRangeFactory.fromString(v11n, "g-e:1:10").toString(), "Gen 1:1-Exo 1:10");
-        assertEquals(VerseRangeFactory.fromString(v11n, "g 1-e 2").toString(), "Gen 1-Exo 2");
+        assertEquals("1Cor 8-9", VerseRangeFactory.fromString(v11n, "1corinth 8-9").toString());
+        assertEquals("Gen 1:1", VerseRangeFactory.fromString(v11n, "Genesis 1 1").toString());
+        assertEquals("Gen 1:1-Exo 1:1", VerseRangeFactory.fromString(v11n, "g 1 1-e 1 1").toString());
+        assertEquals("Gen 0:0-Exo 1:10", VerseRangeFactory.fromString(v11n, "g-e:1:10").toString());
+        assertEquals("Gen 1-Exo 2", VerseRangeFactory.fromString(v11n, "g 1-e 2").toString());
         PassageUtil.setPersistentNaming(true);
-        assertEquals(VerseRangeFactory.fromString(v11n, "Genesis 1 1").toString(), "Genesis 1 1");
-        assertEquals(VerseRangeFactory.fromString(v11n, "g 1 1-e 1 1").toString(), "g 1 1-e 1 1");
-        assertEquals(VerseRangeFactory.fromString(v11n, "g-e:1:1").toString(), "g-e:1:1");
-        assertEquals(VerseRangeFactory.fromString(v11n, "g 1-e 2").toString(), "g 1-e 2");
+        assertEquals("Genesis 1 1", VerseRangeFactory.fromString(v11n, "Genesis 1 1").toString());
+        assertEquals("g 1 1-e 1 1", VerseRangeFactory.fromString(v11n, "g 1 1-e 1 1").toString());
+        assertEquals("g-e:1:1", VerseRangeFactory.fromString(v11n, "g-e:1:1").toString());
+        assertEquals("g 1-e 2", VerseRangeFactory.fromString(v11n, "g 1-e 2").toString());
         PassageUtil.setPersistentNaming(false);
     }
 
@@ -222,157 +242,150 @@
         assertEquals(gen11_2, new VerseRange(v11n, gen12, gen11));
         assertEquals(gen_rev, new VerseRange(v11n, gen11, rev99));
         assertEquals(gen_rev, new VerseRange(v11n, rev99, gen11));
-        assertEquals(gen_all, new VerseRange(v11n, gen11, gen99));
-        assertEquals(gen_all, new VerseRange(v11n, gen99, gen11));
-        assertEquals(gen_ex1, new VerseRange(v11n, gen11, exo11));
-        assertEquals(gen_ex1, new VerseRange(v11n, exo11, gen11));
+        assertEquals(gen_all, new VerseRange(v11n, gen00, gen99));
+        assertEquals(gen_all, new VerseRange(v11n, gen99, gen00));
+        assertEquals(gen_ex1, new VerseRange(v11n, gen00, exo11));
+        assertEquals(gen_ex1, new VerseRange(v11n, exo11, gen00));
         assertEquals(gen11_1, new VerseRange(v11n, gen11, new Verse(BibleBook.GEN, 1, 1)));
     }
 
     public void testNewViaVerseIntIntBoolean() {
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 1).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 1).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 0).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 0, 1).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 0, 1).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 0, 9).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 0, 9).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 1, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 30).getOsisRef());
-        assertEquals(gen11_a.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 32).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 32).getOsisRef());
-        assertEquals(gen11_a.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 1, 32).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 32).getOsisRef());
-        assertEquals(gen11_a.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 32).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 32).getOsisRef());
-        assertEquals(gen_all.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 1581).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 1581).getOsisRef());
-        assertEquals(gen_all.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 1, 1581).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 1581).getOsisRef());
-        assertEquals(gen_all.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 1581).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 1581).getOsisRef());
-        assertEquals(gen_ex1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 1584).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 1533).getOsisRef());
-        assertEquals(gen_ex1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 1, 1584).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 1584).getOsisRef());
-        assertEquals(gen_ex1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 1584).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 1584).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 32356).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 32356).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 1, 32356).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 32356).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 32356).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 32356).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 32357).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 32357).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 1, 32357).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 32357).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 32357).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 32357).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 99999).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 0, 99999).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 1, 99999).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 1, 99999).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11, 0, 99999).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11, 9, 99999).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen12, 1, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.NONE.blur(v11n, gen12, 1, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen12, 9, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.NONE.blur(v11n, gen12, 1, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 20, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 20, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 20, 1).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 20, 1).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 20, 9).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 20, 9).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 425, 0).getOsisRef());
-        assertEquals(rev11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 425, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 425, 1).getOsisRef());
-        assertEquals(rev11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 425, 1).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99, 425, 9).getOsisRef());
-        assertEquals(rev11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99, 425, 9).getOsisRef());
+        assertEquals(gen11_1, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 0));
+        assertEquals(gen11_1, RestrictionType.NONE.blur(v11n, gen11, 0, 0));
+        assertEquals(gen11_2, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 1));
+        assertEquals(gen11_2, RestrictionType.NONE.blur(v11n, gen11, 0, 1));
+        assertEquals(gen10_1, RestrictionType.CHAPTER.blur(v11n, gen11, 1, 0));
+        assertEquals(gen11_1, RestrictionType.NONE.blur(v11n, gen11, 0, 0));
+        assertEquals(gen10_1, RestrictionType.CHAPTER.blur(v11n, gen11, 9, 0));
+        assertEquals(gen11_1, RestrictionType.NONE.blur(v11n, gen11, 0, 0));
+        assertEquals(rev99_1, RestrictionType.CHAPTER.blur(v11n, rev99, 0, 1));
+        assertEquals(rev99_1, RestrictionType.NONE.blur(v11n, rev99, 0, 1));
+        assertEquals(rev99_1, RestrictionType.CHAPTER.blur(v11n, rev99, 0, 9));
+        assertEquals(rev99_1, RestrictionType.NONE.blur(v11n, rev99, 0, 9));
+        assertEquals(gen11_9, RestrictionType.NONE.blur(v11n, gen11, 0, 30));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 30));
+        assertEquals(gen10_9, RestrictionType.NONE.blur(v11n, gen11, 1, 30));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 1, 30));
+        assertEquals(gen11_9, RestrictionType.NONE.blur(v11n, gen11, 0, 30));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 9, 30));
+        assertEquals(gen11_a, RestrictionType.NONE.blur(v11n, gen11, 0, 32));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 32));
+        assertEquals(gen10_a, RestrictionType.NONE.blur(v11n, gen11, 1, 32));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 1, 32));
+        assertEquals(gen11_a, RestrictionType.NONE.blur(v11n, gen11, 0, 32));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 9, 32));
+        assertEquals(gen_all, RestrictionType.NONE.blur(v11n, gen11, 2, 1581));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 1581));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 3, 1581));
+        assertEquals(gen_all, RestrictionType.NONE.blur(v11n, gen11, 2, 1581));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 9, 1581));
+        assertEquals(gen_ex1, RestrictionType.NONE.blur(v11n, gen11, 2, 1584));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 1533));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 1, 1584));
+        assertEquals(gen_ex1, RestrictionType.NONE.blur(v11n, gen11, 2, 1584));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 2, 1584));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 32356));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 32356));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 32356));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 1, 32356));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 32356));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 9, 32356));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 32357));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 32357));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 32357));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 1, 32357));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 32357));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 9, 32357));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 99999));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11, 0, 99999));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 99999));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 1, 99999));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11, 0, 99999));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11, 9, 99999));
+        assertEquals(gen11_2, RestrictionType.CHAPTER.blur(v11n, gen12, 1, 0));
+        assertEquals(gen11_2, RestrictionType.NONE.blur(v11n, gen12, 1, 0));
+        assertEquals(gen10_2, RestrictionType.CHAPTER.blur(v11n, gen12, 9, 0));
+        assertEquals(gen11_2, RestrictionType.NONE.blur(v11n, gen12, 1, 0));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99, 21, 0));
+        assertEquals(rev99_9, RestrictionType.NONE.blur(v11n, rev99, 21, 0));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99, 21, 1));
+        assertEquals(rev99_9, RestrictionType.NONE.blur(v11n, rev99, 21, 1));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99, 21, 9));
+        assertEquals(rev99_9, RestrictionType.NONE.blur(v11n, rev99, 21, 9));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99, 425, 0));
+        assertEquals(rev11_9, RestrictionType.NONE.blur(v11n, rev99, 426, 0));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99, 427, 1));
+        assertEquals(rev11_9, RestrictionType.NONE.blur(v11n, rev99, 426, 1));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99, 427, 9));
+        assertEquals(rev11_9, RestrictionType.NONE.blur(v11n, rev99, 426, 9));
     }
 
     public void testNewViaVerseRangeIntIntBoolean() {
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 1).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 1).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 0).getOsisRef());
-        assertEquals(gen11_1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 0).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 0, 1).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 0, 1).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 0, 9).getOsisRef());
-        assertEquals(rev99_1.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 0, 9).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 30).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 30).getOsisRef());
-        assertEquals(gen11_a.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 31).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 31).getOsisRef());
-        assertEquals(gen11_a.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 31).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 31).getOsisRef());
-        assertEquals(gen11_a.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 31).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 31).getOsisRef());
-        assertEquals(gen_all.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 1581).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 1581).getOsisRef());
-        assertEquals(gen_all.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 1581).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 1581).getOsisRef());
-        assertEquals(gen_all.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 1581).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 1581).getOsisRef());
-        assertEquals(gen_ex1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 1584).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 1584).getOsisRef());
-        assertEquals(gen_ex1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 1584).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 1584).getOsisRef());
-        assertEquals(gen_ex1.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 1584).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 1584).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 32356).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 32356).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 32356).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 32356).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 32356).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 32356).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 32357).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 32357).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 32357).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 32357).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 32357).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 32357).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 0, 99999).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 99999).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 1, 99999).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 99999).getOsisRef());
-        assertEquals(gen_rev.getOsisRef(), RestrictionType.NONE.blur(v11n, gen11_1, 9, 99999).getOsisRef());
-        assertEquals(gen11_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 99999).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen12_1, 1, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.NONE.blur(v11n, gen12_1, 1, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, gen12_1, 9, 0).getOsisRef());
-        assertEquals(gen11_2.getOsisRef(), RestrictionType.NONE.blur(v11n, gen12_1, 9, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 20, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 20, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 20, 1).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 20, 1).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 20, 9).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 20, 9).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 425, 0).getOsisRef());
-        assertEquals(rev11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 425, 0).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 425, 1).getOsisRef());
-        assertEquals(rev11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 425, 1).getOsisRef());
-        assertEquals(rev99_9.getOsisRef(), RestrictionType.CHAPTER.blur(v11n, rev99_1, 425, 9).getOsisRef());
-        assertEquals(rev11_9.getOsisRef(), RestrictionType.NONE.blur(v11n, rev99_1, 425, 9).getOsisRef());
+        assertEquals(gen11_1, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 0));
+        assertEquals(gen11_1, RestrictionType.NONE.blur(v11n, gen11_1, 0, 0));
+        assertEquals(gen11_2, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 1));
+        assertEquals(gen11_2, RestrictionType.NONE.blur(v11n, gen11_1, 0, 1));
+        assertEquals(gen10_1, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 0));
+        assertEquals(gen10_1, RestrictionType.NONE.blur(v11n, gen11_1, 1, 0));
+        assertEquals(gen10_1, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 0));
+        assertEquals(rev99_1, RestrictionType.CHAPTER.blur(v11n, rev99_1, 0, 1));
+        assertEquals(rev99_1, RestrictionType.NONE.blur(v11n, rev99_1, 0, 1));
+        assertEquals(rev99_1, RestrictionType.CHAPTER.blur(v11n, rev99_1, 0, 9));
+        assertEquals(rev99_1, RestrictionType.NONE.blur(v11n, rev99_1, 0, 9));
+        assertEquals(gen11_9, RestrictionType.NONE.blur(v11n, gen11_1, 0, 30));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 30));
+        assertEquals(gen10_9, RestrictionType.NONE.blur(v11n, gen11_1, 1, 30));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 30));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 30));
+        assertEquals(gen11_a, RestrictionType.NONE.blur(v11n, gen11_1, 0, 32));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 33));
+        assertEquals(gen10_a, RestrictionType.NONE.blur(v11n, gen11_1, 1, 32));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 31));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 31));
+        assertEquals(gen_all, RestrictionType.NONE.blur(v11n, gen11_1, 2, 1581));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 1581));
+        assertEquals(gen_all, RestrictionType.NONE.blur(v11n, gen11_1, 2, 1581));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 1581));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 1581));
+        assertEquals(gen_ex1, RestrictionType.NONE.blur(v11n, gen11_1, 2, 1584));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 1584));
+        assertEquals(gen_ex1, RestrictionType.NONE.blur(v11n, gen11_1, 2, 1584));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 1584));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 1584));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 32356));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 32356));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 32356));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 32356));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 32356));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 32356));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 32357));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 32357));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 32357));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 32357));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 32357));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 32357));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 99999));
+        assertEquals(gen11_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 0, 99999));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 99999));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 1, 99999));
+        assertEquals(gen_rev, RestrictionType.NONE.blur(v11n, gen11_1, 0, 99999));
+        assertEquals(gen10_9, RestrictionType.CHAPTER.blur(v11n, gen11_1, 9, 99999));
+        assertEquals(gen11_2, RestrictionType.CHAPTER.blur(v11n, gen12_1, 1, 0));
+        assertEquals(gen11_2, RestrictionType.NONE.blur(v11n, gen12_1, 1, 0));
+        assertEquals(gen10_2, RestrictionType.CHAPTER.blur(v11n, gen12_1, 9, 0));
+        assertEquals(gen10_2, RestrictionType.NONE.blur(v11n, gen12_1, 2, 0));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99_1, 21, 0));
+        assertEquals(rev99_9, RestrictionType.NONE.blur(v11n, rev99_1, 21, 0));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99_1, 21, 1));
+        assertEquals(rev99_9, RestrictionType.NONE.blur(v11n, rev99_1, 21, 1));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99_1, 21, 9));
+        assertEquals(rev99_9, RestrictionType.NONE.blur(v11n, rev99_1, 21, 9));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99_1, 426, 0));
+        assertEquals(rev11_9, RestrictionType.NONE.blur(v11n, rev99_1, 426, 0));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99_1, 426, 1));
+        assertEquals(rev11_9, RestrictionType.NONE.blur(v11n, rev99_1, 426, 1));
+        assertEquals(rev99_9, RestrictionType.CHAPTER.blur(v11n, rev99_1, 426, 9));
+        assertEquals(rev11_9, RestrictionType.NONE.blur(v11n, rev99_1, 426, 9));
     }
 
     public void testNewViaVerseRangeVerseRange() {
@@ -398,38 +411,38 @@
     }
 
     public void testGetName() {
-        assertEquals(gen11_1.getName(), "Gen 1:1");
-        assertEquals(gen11_2.getName(), "Gen 1:1-2");
-        assertEquals(gen11_9.getName(), "Gen 1");
-        assertEquals(gen11_a.getName(), "Gen 1:1-2:1");
-        assertEquals(gen12_1.getName(), "Gen 1:2");
-        assertEquals(gen_all.getName(), "Gen");
-        assertEquals(gen_ex1.getName(), "Gen 1:1-Exo 1:1");
-        assertEquals(gen_rev.getName(), "Gen-Rev");
-        assertEquals(rev99_9.getName(), "Rev 22");
-        assertEquals(rev11_9.getName(), "Rev");
-        assertEquals(rev99_1.getName(), "Rev 22:21");
+        assertEquals("Gen 1:1", gen11_1.getName());
+        assertEquals("Gen 1:1-2", gen11_2.getName());
+        assertEquals("Gen 1:1-31", gen11_9.getName());
+        assertEquals("Gen 1:1-2:1", gen11_a.getName());
+        assertEquals("Gen 1:2", gen12_1.getName());
+        assertEquals("Gen", gen_all.getName());
+        assertEquals("Gen 0:0-Exo 1:1", gen_ex1.getName());
+        assertEquals("Gen 1:1-Rev 22:21", gen_rev.getName());
+        assertEquals("Rev 22", rev99_9.getName());
+        assertEquals("Rev", rev11_9.getName());
+        assertEquals("Rev 22:21", rev99_1.getName());
     }
 
     public void testGetNameVerse() {
-        assertEquals(gen11_2.getName(gen11), "1-2");
-        assertEquals(gen12_1.getName(gen11), "2");
-        assertEquals(rev99_9.getName(gen11), "Rev 22");
-        assertEquals(rev99_9.getName(null), "Rev 22");
+        assertEquals("1-2", gen11_2.getName(gen11));
+        assertEquals("2", gen12_1.getName(gen11));
+        assertEquals("Rev 22", rev99_9.getName(gen11));
+        assertEquals("Rev 22",rev99_9.getName(null));
     }
 
     public void testGetStart() {
-        assertEquals(gen11_1.getStart(), gen11);
-        assertEquals(gen11_2.getStart(), gen11);
-        assertEquals(gen11_9.getStart(), gen11);
-        assertEquals(gen11_a.getStart(), gen11);
-        assertEquals(gen12_1.getStart(), gen12);
-        assertEquals(gen_all.getStart(), gen11);
-        assertEquals(gen_ex1.getStart(), gen11);
-        assertEquals(gen_rev.getStart(), gen11);
-        assertEquals(rev99_9.getStart(), rev91);
-        assertEquals(rev11_9.getStart(), rev11);
-        assertEquals(rev99_1.getStart(), rev99);
+        assertEquals(gen11, gen11_1.getStart());
+        assertEquals(gen11, gen11_2.getStart());
+        assertEquals(gen11, gen11_9.getStart());
+        assertEquals(gen11, gen11_a.getStart());
+        assertEquals(gen12, gen12_1.getStart());
+        assertEquals(gen00, gen_all.getStart());
+        assertEquals(gen00, gen_ex1.getStart());
+        assertEquals(gen11, gen_rev.getStart());
+        assertEquals(rev90, rev99_9.getStart());
+        assertEquals(rev00, rev11_9.getStart());
+        assertEquals(rev99, rev99_1.getStart());
     }
 
     public void testGetEnd() {
@@ -447,17 +460,17 @@
     }
 
     public void testGetVerseCount() {
-        assertEquals(gen11_1.getCardinality(), 1);
-        assertEquals(gen11_2.getCardinality(), 2);
-        assertEquals(gen11_9.getCardinality(), 31);
-        assertEquals(gen11_a.getCardinality(), 33);
-        assertEquals(gen12_1.getCardinality(), 1);
-        assertEquals(gen_all.getCardinality(), 1582);
-        assertEquals(gen_ex1.getCardinality(), 1585);
-        assertEquals(gen_rev.getCardinality(), 32356);
-        assertEquals(rev99_9.getCardinality(), 21);
-        assertEquals(rev11_9.getCardinality(), 425);
-        assertEquals(rev99_1.getCardinality(), 1);
+        assertEquals(1, gen11_1.getCardinality());
+        assertEquals(2, gen11_2.getCardinality());
+        assertEquals(31, gen11_9.getCardinality());
+        assertEquals(33, gen11_a.getCardinality());
+        assertEquals(1, gen12_1.getCardinality());
+        assertEquals(1584, gen_all.getCardinality());
+        assertEquals(1587, gen_ex1.getCardinality());
+        assertEquals(32356, gen_rev.getCardinality());
+        assertEquals(22, rev99_9.getCardinality());
+        assertEquals(427, rev11_9.getCardinality());
+        assertEquals(1, rev99_1.getCardinality());
     }
 
     public void testClone() {
@@ -474,7 +487,7 @@
         assertEquals(gen11_1.compareTo(gen11_2), -1);
         assertEquals(gen11_1.compareTo(gen11_9), -1);
         assertEquals(gen11_1.compareTo(gen11_a), -1);
-        assertEquals(gen11_1.compareTo(gen_all), -1);
+        assertEquals(gen11_1.compareTo(gen_all), 1);
         assertEquals(gen12_1.compareTo(gen11_1), 1);
         assertEquals(gen12_1.compareTo(gen11_2), 1);
         assertEquals(gen12_1.compareTo(gen_rev), 1);
@@ -573,11 +586,11 @@
 
     public void testIsChapter() throws Exception {
         assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1").isWholeChapter());
-        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1:1-ff").isWholeChapter());
-        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1:1-$").isWholeChapter());
+        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1:0-ff").isWholeChapter());
+        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1:0-$").isWholeChapter());
         assertTrue(VerseRangeFactory.fromString(v11n, "Exo 2").isWholeChapter());
-        assertTrue(VerseRangeFactory.fromString(v11n, "Exo 2:1-ff").isWholeChapter());
-        assertTrue(VerseRangeFactory.fromString(v11n, "Exo 2:1-$").isWholeChapter());
+        assertTrue(VerseRangeFactory.fromString(v11n, "Exo 2:0-ff").isWholeChapter());
+        assertTrue(VerseRangeFactory.fromString(v11n, "Exo 2:0-$").isWholeChapter());
         assertTrue(!VerseRangeFactory.fromString(v11n, "Num 3:1").isWholeChapter());
         assertTrue(!VerseRangeFactory.fromString(v11n, "Num 4:1-5:1").isWholeChapter());
         assertTrue(!VerseRangeFactory.fromString(v11n, "Num 5:1-6:ff").isWholeChapter());
@@ -586,9 +599,9 @@
 
     public void testIsBook() throws Exception {
         assertTrue(VerseRangeFactory.fromString(v11n, "Gen").isWholeBook());
-        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1:1-Gen 50:ff").isWholeBook());
-        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1:1-Gen 50:$").isWholeBook());
-        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 1-50:ff").isWholeBook());
+        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 0:0-Gen 50:ff").isWholeBook());
+        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 0:0-Gen 50:$").isWholeBook());
+        assertTrue(VerseRangeFactory.fromString(v11n, "Gen 0-50:ff").isWholeBook());
         assertTrue(!VerseRangeFactory.fromString(v11n, "Num 1:2-Num $:$").isWholeBook());
         assertTrue(!VerseRangeFactory.fromString(v11n, "Num 4:1-5:1").isWholeBook());
         assertTrue(!VerseRangeFactory.fromString(v11n, "Num 5:1-6:ff").isWholeBook());
@@ -596,26 +609,26 @@
     }
 
     public void testToVerseArray() {
-        assertEquals(gen11_1.toVerseArray()[0], gen11);
-        assertEquals(gen11_2.toVerseArray()[0], gen11);
-        assertEquals(gen11_2.toVerseArray()[1], gen12);
-        assertEquals(gen11_9.toVerseArray()[0], gen11);
-        assertEquals(gen11_9.toVerseArray()[30], gen19);
-        assertEquals(gen12_1.toVerseArray()[0], gen12);
-        assertEquals(gen_all.toVerseArray()[0], gen11);
-        assertEquals(gen_ex1.toVerseArray()[0], gen11);
-        assertEquals(gen_ex1.toVerseArray()[1584], exo11);
-        assertEquals(rev11_9.toVerseArray()[0], rev11);
-        assertEquals(rev11_9.toVerseArray()[1], rev12);
-        assertEquals(rev11_9.toVerseArray()[424], rev99);
-        assertEquals(gen11_1.toVerseArray().length, 1);
-        assertEquals(gen11_2.toVerseArray().length, 2);
-        assertEquals(gen11_9.toVerseArray().length, 31);
-        assertEquals(gen11_a.toVerseArray().length, 33);
-        assertEquals(gen12_1.toVerseArray().length, 1);
-        assertEquals(gen_all.toVerseArray().length, 1582);
-        assertEquals(gen_ex1.toVerseArray().length, 1585);
-        assertEquals(rev11_9.toVerseArray().length, 425);
+        assertEquals(1, gen11_1.toVerseArray().length);
+        assertEquals(2, gen11_2.toVerseArray().length);
+        assertEquals(31, gen11_9.toVerseArray().length);
+        assertEquals(33, gen11_a.toVerseArray().length);
+        assertEquals(1, gen12_1.toVerseArray().length);
+        assertEquals(1584, gen_all.toVerseArray().length);
+        assertEquals(1587, gen_ex1.toVerseArray().length);
+        assertEquals(427, rev11_9.toVerseArray().length);
+        assertEquals(gen11, gen11_1.toVerseArray()[0]);
+        assertEquals(gen11, gen11_2.toVerseArray()[0]);
+        assertEquals(gen12, gen11_2.toVerseArray()[1]);
+        assertEquals(gen11, gen11_9.toVerseArray()[0]);
+        assertEquals(gen19, gen11_9.toVerseArray()[30]);
+        assertEquals(gen12, gen12_1.toVerseArray()[0]);
+        assertEquals(gen11, gen_all.toVerseArray()[2]);
+        assertEquals(gen11, gen_ex1.toVerseArray()[2]);
+        assertEquals(exo11, gen_ex1.toVerseArray()[1586]);
+        assertEquals(rev11, rev11_9.toVerseArray()[2]);
+        assertEquals(rev12, rev11_9.toVerseArray()[3]);
+        assertEquals(rev99, rev11_9.toVerseArray()[426]);
     }
 
     public void testVerseElements() {

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseTest.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseTest.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -234,8 +234,8 @@
     }
 
     public void testNewViaIntIntIntBoolean() {
-        assertEquals(gen11, new Verse(null, 1, 1, true));
-        assertEquals(gen11, new Verse(BibleBook.GEN, 0, 1, true));
+        assertEquals(gen00, new Verse(null, 1, 1, true));
+        assertEquals(gen10, new Verse(BibleBook.GEN, 0, 1, true));
         assertEquals(gen10, new Verse(BibleBook.GEN, 1, 0, true));
         assertEquals(rev99, new Verse(BibleBook.REV, 22, 22, true));
         assertEquals(rev99, new Verse(BibleBook.REV, 23, 21, true));
@@ -263,8 +263,8 @@
 
     public void testHashCode() {
         assertEquals(gen11.hashCode(), gen11a.hashCode());
-        assertEquals(gen11.hashCode(), gen11.getOrdinal());
-        assertTrue(gen11.hashCode() != gen12.getOrdinal());
+        assertEquals(gen11.hashCode(), v11n.getOrdinal(gen11));
+        assertTrue(gen11.hashCode() != v11n.getOrdinal(gen12));
         assertTrue(gen11.hashCode() != 0);
     }
 
@@ -275,36 +275,36 @@
     }
 
     public void testAddSubtract() {
-        assertEquals(gen12.subtract(gen11), 1);
-        assertEquals(gen11.subtract(gen11), 0);
-        assertEquals(gen11.subtract(gen12), -1);
+        assertEquals(v11n.distance(gen11, gen12), 1);
+        assertEquals(v11n.distance(gen11, gen11), 0);
+        assertEquals(v11n.distance(gen12, gen11), -1);
         Verse last = gen11.clone();
         for (int i = 0; i < v11n.maximumOrdinal(); i += 99) {
-            Verse next = last.add(i);
-            assertEquals(next.subtract(last), i);
+            Verse next = v11n.add(last, i);
+            assertEquals(v11n.distance(last, next), i);
 
-            Verse next2 = next.subtract(i);
+            Verse next2 = v11n.subtract(next, i);
             assertEquals(gen11.getOsisID(), gen11, next2);
         }
-        assertEquals(gen11.getOsisID(), gen11, gen11.subtract(0));
-//        assertEquals(gen11.getOsisID(), gen11, gen11.subtract(1));
-//        assertEquals(gen11.getOsisID(), gen11, gen11.subtract(2));
-        assertEquals(gen11.getOsisID(), gen11, gen11.add(0));
-        assertEquals(rev99.getOsisID(), rev99, rev99.add(0));
-        assertEquals(rev99.getOsisID(), rev99, rev99.add(1));
-        assertEquals(rev99.getOsisID(), rev99, rev99.add(2));
+        assertEquals(gen11.getOsisID(), gen11, v11n.subtract(gen11, 0));
+//        assertEquals(gen11.getOsisID(), gen11, v11n.subtract(gen11, 1));
+//        assertEquals(gen11.getOsisID(), gen11, v11n.subtract(gen11, 2));
+        assertEquals(gen11.getOsisID(), gen11, v11n.add(gen11, 0));
+        assertEquals(rev99.getOsisID(), rev99, v11n.add(rev99, 0));
+        assertEquals(rev99.getOsisID(), rev99, v11n.add(rev99, 1));
+        assertEquals(rev99.getOsisID(), rev99, v11n.add(rev99, 2));
     }
 
     public void testToString() {
-        assertEquals(gen11.toString(), "Gen 1:1");
-        assertEquals(gen12.toString(), "Gen 1:2");
-        assertEquals(gen21.toString(), "Gen 2:1");
-        assertEquals(gen22.toString(), "Gen 2:2");
-        assertEquals(rev11.toString(), "Rev 1:1");
-        assertEquals(rev12.toString(), "Rev 1:2");
-        assertEquals(rev21.toString(), "Rev 2:1");
-        assertEquals(rev22.toString(), "Rev 2:2");
-        assertEquals(rev99.toString(), "Rev 22:21");
+        assertEquals("Gen 1:1", gen11.toString());
+        assertEquals("Gen 1:2", gen12.toString());
+        assertEquals("Gen 2:1", gen21.toString());
+        assertEquals("Gen 2:2", gen22.toString());
+        assertEquals("Rev 1:1", rev11.toString());
+        assertEquals("Rev 1:2", rev12.toString());
+        assertEquals("Rev 2:1", rev21.toString());
+        assertEquals("Rev 2:2", rev22.toString());
+        assertEquals("Rev 22:21", rev99.toString());
     }
 
     public void testGetBook() {
@@ -344,15 +344,15 @@
     }
 
     public void testGetOrdinal() {
-        assertEquals(gen11.getOrdinal(), 4);
-        assertEquals(gen12.getOrdinal(), 5);
-        assertEquals(gen21.getOrdinal(), 36);
-        assertEquals(gen22.getOrdinal(), 37);
-        assertEquals(rev11.getOrdinal(), 31935);
-        assertEquals(rev12.getOrdinal(), 31936);
-        assertEquals(rev21.getOrdinal(), 31956);
-        assertEquals(rev22.getOrdinal(), 31957);
-        assertEquals(rev99.getOrdinal(), 32359);
+        assertEquals(4, v11n.getOrdinal(gen11));
+        assertEquals(5, v11n.getOrdinal(gen12));
+        assertEquals(36, v11n.getOrdinal(gen21));
+        assertEquals(37, v11n.getOrdinal(gen22));
+        assertEquals(31935, v11n.getOrdinal(rev11));
+        assertEquals(31936, v11n.getOrdinal(rev12));
+        assertEquals(31956, v11n.getOrdinal(rev21));
+        assertEquals(31957, v11n.getOrdinal(rev22));
+        assertEquals(32359, v11n.getOrdinal(rev99));
     }
 
     public void testGetAccuracy() throws Exception {
@@ -382,60 +382,61 @@
     }
 
     public void testIsStartEndOfChapterBook() throws Exception {
-        assertTrue(VerseFactory.fromString(v11n, "Gen 1:1").isStartOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:10").isStartOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:$").isStartOfChapter());
-        assertTrue(VerseFactory.fromString(v11n, "Gen 10:1").isStartOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:10").isStartOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:$").isStartOfChapter());
-        assertTrue(VerseFactory.fromString(v11n, "Gen $:1").isStartOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:10").isStartOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:$").isStartOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:1").isEndOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:10").isEndOfChapter());
-        assertTrue(VerseFactory.fromString(v11n, "Gen 1:$").isEndOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:1").isEndOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:10").isEndOfChapter());
-        assertTrue(VerseFactory.fromString(v11n, "Gen 10:$").isEndOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:1").isEndOfChapter());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:10").isEndOfChapter());
-        assertTrue(VerseFactory.fromString(v11n, "Gen $:$").isEndOfChapter());
-        assertTrue(VerseFactory.fromString(v11n, "Gen 1:1").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:10").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:$").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:1").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:10").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:$").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:1").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:10").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:$").isStartOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:1").isEndOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:10").isEndOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 1:$").isEndOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:1").isEndOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:10").isEndOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen 10:$").isEndOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:1").isEndOfBook());
-        assertTrue(!VerseFactory.fromString(v11n, "Gen $:10").isEndOfBook());
-        assertTrue(VerseFactory.fromString(v11n, "Gen $:$").isEndOfBook());
+        assertTrue(v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen 0:0")));
+        assertTrue(!v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen 1:10")));
+        assertTrue(!v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen 1:$")));
+        assertTrue(v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen 10:0")));
+        assertTrue(!v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen 10:10")));
+        assertTrue(!v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen 10:$")));
+        assertTrue(v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen $:0")));
+        assertTrue(!v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen $:10")));
+        assertTrue(!v11n.isStartOfChapter(VerseFactory.fromString(v11n, "Gen $:$")));
+        assertTrue(!v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen 1:1")));
+        assertTrue(!v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen 1:10")));
+        assertTrue(v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen 1:$")));
+        assertTrue(!v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen 10:1")));
+        assertTrue(!v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen 10:10")));
+        assertTrue(v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen 10:$")));
+        assertTrue(!v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen $:1")));
+        assertTrue(!v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen $:10")));
+        assertTrue(v11n.isEndOfChapter(VerseFactory.fromString(v11n, "Gen $:$")));
+        assertTrue(v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen 0:0")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen 1:10")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen 1:$")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen 10:1")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen 10:10")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen 10:$")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen $:1")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen $:10")));
+        assertTrue(!v11n.isStartOfBook(VerseFactory.fromString(v11n, "Gen $:$")));
+        
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen 1:1")));
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen 1:10")));
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen 1:$")));
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen 10:1")));
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen 10:10")));
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen 10:$")));
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen $:1")));
+        assertTrue(!v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen $:10")));
+        assertTrue(v11n.isEndOfBook(VerseFactory.fromString(v11n, "Gen $:$")));
     }
 
     public void testMax() {
-        assertEquals(Verse.max(gen11, gen12), gen12);
-        assertEquals(Verse.max(gen11, rev99), rev99);
-        assertEquals(Verse.max(gen11, gen11a), gen11);
-        assertEquals(Verse.max(gen12, gen11), gen12);
-        assertEquals(Verse.max(rev99, gen11), rev99);
-        assertEquals(Verse.max(gen11a, gen11), gen11a);
+        assertEquals(v11n.max(gen11, gen12), gen12);
+        assertEquals(v11n.max(gen11, rev99), rev99);
+        assertEquals(v11n.max(gen11, gen11a), gen11);
+        assertEquals(v11n.max(gen12, gen11), gen12);
+        assertEquals(v11n.max(rev99, gen11), rev99);
+        assertEquals(v11n.max(gen11a, gen11), gen11a);
     }
 
     public void testMin() {
-        assertEquals(Verse.min(gen11, gen12), gen11);
-        assertEquals(Verse.min(gen11, rev99), gen11);
-        assertEquals(Verse.min(gen11, gen11a), gen11);
-        assertEquals(Verse.min(gen12, gen11), gen11);
-        assertEquals(Verse.min(rev99, gen11), gen11);
-        assertEquals(Verse.min(gen11a, gen11a), gen11a);
+        assertEquals(v11n.min(gen11, gen12), gen11);
+        assertEquals(v11n.min(gen11, rev99), gen11);
+        assertEquals(v11n.min(gen11, gen11a), gen11);
+        assertEquals(v11n.min(gen12, gen11), gen11);
+        assertEquals(v11n.min(rev99, gen11), gen11);
+        assertEquals(v11n.min(gen11a, gen11a), gen11a);
     }
 
     public void testToVerseArray() {

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/versification/VersificationTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/versification/VersificationTest.java	2012-02-02 05:36:37 UTC (rev 2225)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/versification/VersificationTest.java	2012-02-02 19:25:21 UTC (rev 2226)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.jsword.versification;
 
-import java.util.EnumSet;
-
 import junit.framework.TestCase;
 
 import org.crosswire.jsword.book.CaseType;
@@ -143,7 +141,6 @@
     public void testPatch() throws Exception {
 
         int all = 0;
-/*
         // For all the books
         for (BibleBook b : v11n.getBooks()) {
             int cib = v11n.getLastChapter(b);
@@ -158,60 +155,27 @@
                 }
             }
         }
-*/
-        // for (BibleBook b : BibleBook.values()) {
-        all = 1;
-        for (BibleBook b: EnumSet.range(BibleBook.GEN, BibleBook.MAL)) {
-            int cib = v11n.getLastChapter(b);
-            for (int c = 1; c <= cib; c++) {
-                int vic = v11n.getLastVerse(b, c);
-                for (int v = 1; v <= vic; v++) {
-                    Verse pv = v11n.patch(BibleBook.GEN, 1, all);
 
-                    assertEquals(pv.getName(), b, pv.getBook());
-                    assertEquals(pv.getName(), c, pv.getChapter());
-                    assertEquals(pv.getName(), v, pv.getVerse());
-                    all++;
-                }
-            }
-        }
-        all = 1;
-        for (BibleBook b: EnumSet.range(BibleBook.MATT, BibleBook.REV)) {
-            int cib = v11n.getLastChapter(b);
-            for (int c = 1; c <= cib; c++) {
-                int vic = v11n.getLastVerse(b, c);
-                for (int v = 1; v <= vic; v++) {
-                    Verse pv = v11n.patch(BibleBook.MATT, 1, all);
-
-                    assertEquals(pv.getName(), b, pv.getBook());
-                    assertEquals(pv.getName(), c, pv.getChapter());
-                    assertEquals(pv.getName(), v, pv.getVerse());
-                    all++;
-                }
-            }
-        }
         Verse gen11 = new Verse(BibleBook.GEN, 1, 1);
         assertEquals(gen11, v11n.patch(BibleBook.GEN, 1, 1));
-//        assertEquals(gen11, v11n.patch(BibleBook.GEN, 1, 0));
-        assertEquals(gen11, v11n.patch(BibleBook.GEN, 0, 1));
-//        assertEquals(gen11, v11n.patch(BibleBook.GEN, 0, 0));
-        assertEquals(gen11, v11n.patch(null, 1, 1));
-//        assertEquals(gen11, v11n.patch(null, 1, 0));
-        assertEquals(gen11, v11n.patch(null, 0, 1));
-//        assertEquals(gen11, v11n.patch(null, 0, 0));
+        assertEquals(gen11, v11n.patch(BibleBook.GEN, 0, 2));
+        assertEquals(gen11, v11n.patch(null, 3, 1));
+        assertEquals(gen11, v11n.patch(null, 0, 4));
     }
 
     public void testVerseCount() throws Exception {
         int count_up = 0;
-        Verse gen00 = new Verse(BibleBook.GEN, 0, 0);
-        Verse gen110 = new Verse(BibleBook.GEN, 1, 10);
-        Verse rev99 = new Verse(BibleBook.REV, 22, 21);
-        // for (BibleBook b : BibleBook.values()) {
-        for (BibleBook b: EnumSet.range(BibleBook.GEN, BibleBook.REV)) {
-            for (int c = 0; c <= v11n.getLastChapter(b); c++) {
-                for (int v = 0; v <= v11n.getLastVerse(b, c); v++) {
+        Verse firstVerse = new Verse(v11n.getBooks().getFirstBook(), 0, 0);
+        BibleBook lastBook = v11n.getBooks().getLastBook();
+        int lastChapter = v11n.getLastChapter(lastBook);
+        Verse lastVerse = new Verse(lastBook, lastChapter, v11n.getLastVerse(lastBook, lastChapter));
+        for (BibleBook b : v11n.getBooks()) {
+            int cib = v11n.getLastChapter(b);
+            for (int c = 0; c <= cib; c++) {
+                int vic = v11n.getLastVerse(b, c);
+                for (int v = 0; v <= vic; v++) {
                     Verse curVerse = new Verse(b, c, v);
-                    int up = curVerse.subtract(gen00) + 1;
+                    int up = v11n.distance(firstVerse, curVerse) + 1;
                     assertEquals(++count_up, up);
 //                    assertEquals(verseCountSlow(gen00, curVerse), up);
                 }
@@ -219,19 +183,19 @@
 
         }
         int count_down = v11n.maximumOrdinal();
-        assertEquals(rev99.getOrdinal(), count_down);
-        count_down -= 2; // Subtract for the Module and OT intros
-        for (BibleBook b: EnumSet.range(BibleBook.GEN, BibleBook.REV)) {
-            for (int c = 0; c <= v11n.getLastChapter(b); c++) {
-                for (int v = 0; v <= v11n.getLastVerse(b, c); v++) {
+        assertEquals(v11n.getOrdinal(lastVerse), count_down);
+        for (BibleBook b : v11n.getBooks()) {
+            int cib = v11n.getLastChapter(b);
+            for (int c = 0; c <= cib; c++) {
+                int vic = v11n.getLastVerse(b, c);
+                for (int v = 0; v <= vic; v++) {
                     Verse curVerse = new Verse(b, c, v);
-                    int down = rev99.subtract(curVerse);
+                    int down = v11n.distance(curVerse, lastVerse);
                     assertEquals(count_down--, down);
                 }
             }
 
         }
-        assertEquals(11, gen110.subtract(gen00));
     }
 
     public void testNames() {




More information about the jsword-svn mailing list