[jsword-svn] r1177 - in trunk/jsword/src: main/java/org/crosswire/jsword/passage test/java/org/crosswire/jsword/passage

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Sun Nov 5 13:28:43 MST 2006


Author: dmsmith
Date: 2006-11-05 13:28:23 -0700 (Sun, 05 Nov 2006)
New Revision: 1177

Added:
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java
Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageConstantsTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageMixTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSizeTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedOptTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTallyTest.java
   trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageWriteSpeedTest.java
Log:
Fixed a passage parsing problem that was found against the Clarke module.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -641,8 +641,9 @@
      * number that stands alone.</p>
      * @param input The string to parse.
      * @return The string array
+     * @throws NoSuchVerseException 
      */
-    public static String[] tokenize(String input)
+    public static String[] tokenize(String input) throws NoSuchVerseException
     {
         // The results are expected to be no more than 3 parts
         String [] args = { null, null, null, null, null, null, null, null};
@@ -682,6 +683,11 @@
                     // Letters always continue a previous token
                     if (charIsDigit)
                     {
+                        if (tokenCount >= args.length)
+                        {
+                            throw new NoSuchVerseException(Msg.VERSE_PARTS, new Object[] { input });
+                        }
+
                         token = new String(normalized, startIndex, normalizedLength - startIndex);
                         args[tokenCount++] = token;
                         normalizedLength = 0;
@@ -700,6 +706,12 @@
                 lastChar = curChar;
             }
         }
+
+        if (tokenCount >= args.length)
+        {
+            throw new NoSuchVerseException(Msg.VERSE_PARTS, new Object[] { input });
+        }
+
         token = new String(normalized, startIndex, normalizedLength - startIndex);
         args[tokenCount++] = token;
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -34,35 +34,11 @@
  * @see gnu.lgpl.License for license details.
  *      The copyright to this program is held by it's authors.
  * @author Joe Walker [joe at eireneh dot com]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
  */
 public final class PassageKeyFactory implements KeyFactory
 {
     /**
-     * Optimize the Passage for speed
-     */
-    public static final int SPEED = 0;
-
-    /**
-     * Optimize the Passage for speed
-     */
-    public static final int WRITE_SPEED = 1;
-
-    /**
-     * Optimize the Passage for size
-     */
-    public static final int SIZE = 2;
-
-    /**
-     * Optimize the Passage for a mix
-     */
-    public static final int MIX = 3;
-
-    /**
-     * Optimize the Passage for tally operations
-     */
-    public static final int TALLY = 4;
-
-    /**
      * This class implements a Singleton pattern. So the ctor is private
      */
     private PassageKeyFactory()
@@ -79,7 +55,7 @@
      */
     public Key createEmptyKeyList()
     {
-        return createPassage();
+        return defaultType.createEmptyPassage();
     }
 
     /* (non-Javadoc)
@@ -102,7 +78,16 @@
      */
     public Key getKey(String name) throws NoSuchKeyException
     {
-        return createPassage(name);
+        // since normalization is relatively expensive
+        // don't try it unless it solves a problem.
+        try
+        {
+            return defaultType.createPassage(name);
+        }
+        catch (Exception e)
+        {
+            return defaultType.createPassage(normalize(name));
+        }
     }
 
     /* (non-Javadoc)
@@ -114,7 +99,7 @@
         {
             if (whole == null)
             {
-                whole = new ReadOnlyPassage(createPassage("Gen 1:1-Rev 22:21"), true); //$NON-NLS-1$
+                whole = new ReadOnlyPassage(defaultType.createPassage("Gen 1:1-Rev 22:21"), true); //$NON-NLS-1$
             }
 
             return whole;
@@ -122,117 +107,23 @@
         catch (NoSuchKeyException ex)
         {
             assert false : ex;
-            return createPassage();
+            return defaultType.createEmptyPassage();
         }
     }
 
     /**
-     * Create an empty Passage using the default type.
-     * @return The new Passage
-     */
-    protected Passage createPassage()
-    {
-        return createPassage(defaultType);
-    }
-
-    /**
-     * Create an empty Passage using the default type. And set the
-     * contents of the Passage using a string.
-     * @param name The Passage description.
-     * @return The new Passage
-     * @throws NoSuchVerseException if the name is invalid
-     */
-    protected Passage createPassage(String name) throws NoSuchVerseException
-    {
-        if (name == null)
-        {
-            createPassage(defaultType);
-        }
-
-        return createPassage(defaultType, name);
-    }
-
-    /**
-     * Create an empty Passage using a specified type.
-     * @param type The type of Passage to create.
-     * @return The new Passage
-     * @see PassageKeyFactory#setDefaultPassage(int)
-     */
-    protected Passage createPassage(int type)
-    {
-        switch (type)
-        {
-        case PassageKeyFactory.MIX:
-            return new RangedPassage();
-
-        case PassageKeyFactory.WRITE_SPEED:
-            return new BitwisePassage();
-
-        case PassageKeyFactory.SPEED:
-            return new RocketPassage();
-
-        case PassageKeyFactory.SIZE:
-            return new DistinctPassage();
-
-        case PassageKeyFactory.TALLY:
-            return new PassageTally();
-
-        default :
-            throw new IllegalArgumentException(Integer.toString(type));
-        }
-    }
-
-    /**
-     * Create an empty Passage using a specified type. And set the
-     * contents of the Passage using a string.
-     * @param type The type of Passage to create.
-     * @param name The Passage description.
-     * @return The new Passage
-     * @throws NoSuchVerseException if the name is invalid
-     * @see PassageKeyFactory#setDefaultPassage(int)
-     */
-    protected Passage createPassage(int type, String name) throws NoSuchVerseException
-    {
-        if (name == null)
-        {
-            createPassage(type);
-        }
-
-        switch (type)
-        {
-        case PassageKeyFactory.MIX:
-            return new RangedPassage(name);
-
-        case PassageKeyFactory.WRITE_SPEED:
-            return new BitwisePassage(name);
-
-        case PassageKeyFactory.SPEED:
-            return new RocketPassage(name);
-
-        case PassageKeyFactory.SIZE:
-            return new DistinctPassage(name);
-
-        case PassageKeyFactory.TALLY:
-            return new PassageTally(name);
-
-        default:
-            throw new IllegalArgumentException(Integer.toString(type));
-        }
-    }
-
-    /**
      * Set the default reference type. Must be one of:<ul>
-     * <li>PassageFactory.SPEED
-     * <li>PassageFactory.WRITE_SPEED
-     * <li>PassageFactory.SIZE
-     * <li>PassageFactory.MIX
-     * <li>PassageFactory.TALLY
+     * <li>PassageType.SPEED
+     * <li>PassageType.WRITE_SPEED
+     * <li>PassageType.SIZE
+     * <li>PassageType.MIX
+     * <li>PassageType.TALLY
      * </ul>
-     * @param defaultType The new default type.
+     * @param newDefaultType The new default type.
      */
-    public static void setDefaultPassage(int defaultType)
+    public static void setDefaultPassage(int newDefaultType)
     {
-        PassageKeyFactory.defaultType = defaultType;
+        PassageKeyFactory.defaultType = PassageType.fromInteger(newDefaultType);
     }
 
     /**
@@ -242,7 +133,7 @@
      */
     public static int getDefaultPassage()
     {
-        return defaultType;
+        return PassageType.toInteger(defaultType);
     }
 
     /**
@@ -270,7 +161,7 @@
 
     /**
      * Convert us to a binary representation.
-     * There are sme distinctly endianist happenings here, but that is OK
+     * There are some distinctly endianist happenings here, but that is OK
      * because we are reading the stuff we write here just below.
      * @param ref The Passage to convert
      * @return a byte array
@@ -571,6 +462,103 @@
     }
 
     /**
+     * The internals of a Passage require that references are separated with a reference delimiter.
+     * However, people and other systems may not be so stringent.
+     * So we want to allow for "Ge 1:26  3:22  11:7  20:13  31:7, 53  35:7" (which is from Clarke)
+     * This should become "Ge 1:26, 3:22, 11:7, 20:13, 31:7, 53, 35:7"
+     * Basically, the rule of thumb is that if two numbers are found separated by whitespace
+     * then add a comma between them. One note $, and ff are taken to be numbers.
+     * But it is complicated by Book names that are like 1 Cor
+     * And by verse references like Gen 1.2 Gen.1.2 Gen 1 2 which are all equivalent.
+     * So we use a counter when we see a number, if the counter reaches 2 and then we see a name
+     * or a number we emit a reference delimiter.
+     * 
+     * @param name
+     * @return the normalized value
+     */
+    private String normalize(String name)
+    {
+        if (name == null)
+        {
+            return null;
+        }
+
+        // Note this has a lot in common with AccuracyType.tokenize
+        int size = name.length();
+        StringBuffer buf = new StringBuffer(size * 2);
+
+        char curChar = ' ';
+        boolean isNumber = false;
+        boolean wasNumber = false;
+        int i = 0;
+        while (i < size)
+        {
+            curChar = name.charAt(i);
+
+            // Determine whether we are starting a number
+            isNumber = curChar == '$' || Character.isDigit(curChar) || (curChar == 'f' && (i + 1 < size ? name.charAt(i + 1) : ' ') == 'f');
+
+            // If the last thing we saw was a number and the next thing we see is another number or a word
+            // then we want to put in a ',' or a ' '
+            if (wasNumber)
+            {
+                if (isNumber)
+                {
+                    buf.append(AbstractPassage.REF_PREF_DELIM);
+                }
+                else if (Character.isLetter(curChar))
+                {
+                    buf.append(' ');
+                }
+
+                // Having handled the condition, we now set it to false
+                wasNumber = false;
+            }
+
+            if (isNumber)
+            {
+                wasNumber = true;
+                buf.append(curChar);
+                i++;
+
+                // If it started with an 'f' it was also followed by another.
+                if (curChar == 'f')
+                {
+                    buf.append('f');
+                    i++;
+                }
+                // If it wasn't an 'f' or a '$' then it was digits
+                else if (curChar != '$')
+                {
+                    while (i < size)
+                    {
+                       curChar = name.charAt(i);
+                       if (!Character.isDigit(curChar))
+                        {
+                            break;
+                        }
+                        buf.append(curChar);
+                        i++;
+                    }
+                }
+
+                // skip all following whitespace, it will be added back in as needed
+                while (i < size && Character.isWhitespace(name.charAt(i)))
+                {
+                    i++;
+                }
+            }
+            else
+            {
+                buf.append(curChar);
+                i++;
+            }
+        }
+
+        return buf.toString();
+    }
+
+    /**
      * How we create Passages
      */
     private static KeyFactory keyf = new PassageKeyFactory();
@@ -583,5 +571,5 @@
     /**
      * The default type
      */
-    private static int defaultType = PassageKeyFactory.SPEED;
+    private static PassageType defaultType = PassageType.SPEED;
 }

Added: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -0,0 +1,310 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: PassageListType.java 1068 2006-04-08 02:20:41Z dmsmith $
+ */
+package org.crosswire.jsword.passage;
+
+import java.io.Serializable;
+
+/**
+ * Types of Passage optimizations.
+ * 
+ * @see gnu.lgpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public abstract class PassageType implements Serializable
+{
+    /**
+     * Optimize the Passage for speed
+     */
+    public static final PassageType SPEED = new PassageType("SPEED") //$NON-NLS-1$
+    {
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createPassage(java.lang.String)
+         */
+        public Passage createPassage(String passage) throws NoSuchVerseException
+        {
+            if (passage == null || passage.length() == 0)
+            {
+                return createEmptyPassage();
+            }
+            return new RocketPassage(passage);
+        }
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createEmptyPassage()
+         */
+        public Passage createEmptyPassage()
+        {
+            return new RocketPassage();
+        }
+
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = -5432599732858220775L;
+    };
+
+    /**
+     * Optimize the Passage for write speed
+     */
+    public static final PassageType WRITE_SPEED = new PassageType("WRITE_SPEED") //$NON-NLS-1$
+    {
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createPassage(java.lang.String)
+         */
+        public Passage createPassage(String passage) throws NoSuchVerseException
+        {
+            if (passage == null || passage.length() == 0)
+            {
+                return createEmptyPassage();
+            }
+            return new BitwisePassage(passage);
+        }
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createEmptyPassage()
+         */
+        public Passage createEmptyPassage()
+        {
+            return new BitwisePassage();
+        }
+
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = -8808127396341614058L;
+    };
+
+    /**
+     * Optimize the Passage for size
+     */
+    public static final PassageType SIZE = new PassageType("SIZE") //$NON-NLS-1$
+    {
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createPassage(java.lang.String)
+         */
+        public Passage createPassage(String passage) throws NoSuchVerseException
+        {
+            if (passage == null || passage.length() == 0)
+            {
+                return createEmptyPassage();
+            }
+            return new DistinctPassage(passage);
+        }
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createEmptyPassage()
+         */
+        public Passage createEmptyPassage()
+        {
+            return new DistinctPassage();
+        }
+
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = -1959355535575121168L;
+    };
+
+    /**
+     * Optimize the Passage for a mix
+     */
+    public static final PassageType MIX = new PassageType("MIX") //$NON-NLS-1$
+    {
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createPassage(java.lang.String)
+         */
+        public Passage createPassage(String passage) throws NoSuchVerseException
+        {
+            if (passage == null || passage.length() == 0)
+            {
+                return createEmptyPassage();
+            }
+            return new PassageTally(passage);
+        }
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createEmptyPassage()
+         */
+        public Passage createEmptyPassage()
+        {
+            return new PassageTally();
+        }
+
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = -8426713571411491868L;
+    };
+
+    /**
+     * Optimize the Passage for tally operations
+     */
+    public static final PassageType TALLY = new PassageType("TALLY") //$NON-NLS-1$
+    {
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createPassage(java.lang.String)
+         */
+        public Passage createPassage(String passage) throws NoSuchVerseException
+        {
+            if (passage == null || passage.length() == 0)
+            {
+                return createEmptyPassage();
+            }
+            return new PassageTally(passage);
+        }
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.passage.PassageType#createEmptyPassage()
+         */
+        public Passage createEmptyPassage()
+        {
+            return new PassageTally();
+        }
+
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = -4148688085074351220L;
+    };
+
+    /**
+     * Simple ctor
+     */
+    public PassageType(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Create an optimized passage
+     * @param passage
+     * @return the optimized passage
+     * @throws NoSuchVerseException
+     */
+    public abstract Passage createPassage(String passage) throws NoSuchVerseException;
+
+    /**
+     * Create an empty, optimized passage
+     * @return the optimized, empty passage
+     * @throws NoSuchVerseException
+     */
+    public abstract Passage createEmptyPassage();
+
+    /**
+     * Lookup method to convert from a String
+     */
+    public static PassageType fromString(String name)
+    {
+        for (int i = 0; i < VALUES.length; i++)
+        {
+            PassageType o = VALUES[i];
+            if (o.name.equalsIgnoreCase(name))
+            {
+                return o;
+            }
+        }
+        // cannot get here
+        assert false;
+        return null;
+    }
+
+    /**
+     * Lookup method to convert from an integer
+     */
+    public static PassageType fromInteger(int i)
+    {
+        // on error return SPEED
+        if (i < 0 || i >= VALUES.length)
+        {
+            return SPEED;
+        }
+        return VALUES[i];
+    }
+
+    /**
+     * Lookup method to convert from an integer
+     */
+    public static int toInteger(PassageType type)
+    {
+        for (int i = 0; i < VALUES.length; i++)
+        {
+            PassageType o = VALUES[i];
+            if (o.equals(type))
+            {
+                return i;
+            }
+        }
+        // cannot get here
+        assert false;
+        return 0; // SPEED
+    }
+
+    /**
+     * Prevent subclasses from overriding canonical identity based Object methods
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public final boolean equals(Object o)
+    {
+        return super.equals(o);
+    }
+
+    /**
+     * Prevent subclasses from overriding canonical identity based Object methods
+     * @see java.lang.Object#hashCode()
+     */
+    public final int hashCode()
+    {
+        return super.hashCode();
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return name;
+    }
+
+    /**
+     * The name of the PassageListType
+     */
+    private String name;
+
+    // Support for serialization
+    private static int nextObj;
+    private final int obj = nextObj++;
+
+    Object readResolve()
+    {
+        return VALUES[obj];
+    }
+
+    private static final PassageType[] VALUES =
+    {
+        SPEED,
+        WRITE_SPEED,
+        SIZE,
+        MIX,
+        TALLY,
+    };
+}

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -1135,9 +1135,9 @@
     public static final String RANGE_ALLOWED_DELIMS = "-"; //$NON-NLS-1$
 
     /**
-     * What characters should we use to separate VerseRange parts
+     * What characters should we use to separate VerseRange parts on output
      */
-    public static final String RANGE_PREF_DELIM = "-"; //$NON-NLS-1$
+    public static final String RANGE_PREF_DELIM = RANGE_ALLOWED_DELIMS;
 
     /**
      * To make serialization work across new versions

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageConstantsTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageConstantsTest.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageConstantsTest.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -55,7 +55,7 @@
 
     public void testAllowedDelims() throws Exception
     {
-        // Check that we're not re-using delimitters
+        // Check that we're not re-using delimiters
         for (int i=0; i<AccuracyType.VERSE_ALLOWED_DELIMS.length(); i++)
         {
             assertEquals(AbstractPassage.REF_ALLOWED_DELIMS.indexOf(AccuracyType.VERSE_ALLOWED_DELIMS.charAt(i)), -1);

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageMixTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageMixTest.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageMixTest.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -32,6 +32,6 @@
 {
     public PassageMixTest(String s)
     {
-        super(s, PassageKeyFactory.MIX, false);
+        super(s, PassageType.MIX, false);
     }
 }
\ No newline at end of file

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -30,10 +30,10 @@
 import java.io.ObjectOutputStream;
 import java.util.Iterator;
 
+import junit.framework.TestCase;
+
 import org.crosswire.jsword.versification.BibleInfo;
 
-import junit.framework.TestCase;
-
 /**
  * This would be called TestPassage however then people might think it was
  * a separate TestCase, which it is not, needing to be inherited from to
@@ -50,11 +50,11 @@
         super(s);
     }
 
-    public PassageParentTst(String s, int ptype, boolean optimize)
+    public PassageParentTst(String s, PassageType ptype, boolean optimize)
     {
         super(s);
 
-        PassageKeyFactory.setDefaultPassage(ptype);
+        PassageKeyFactory.setDefaultPassage(PassageType.toInteger(ptype));
         this.optimize = optimize;
     }
 
@@ -101,7 +101,7 @@
     protected void setUp() throws Exception
     {
         start = System.currentTimeMillis();
-
+        BibleInfo.setFullBookName(false);
         gen1_135 = (Passage) keyf.getKey("Gen 1:1, Gen 1:3, Gen 1:5"); //$NON-NLS-1$
         exo2a_3b = (Passage) keyf.getKey("Exo 2:1-10, Exo 3:1-11"); //$NON-NLS-1$
         gen_rev = (Passage) keyf.getKey("Gen 1:1-Rev 22:21"); //$NON-NLS-1$
@@ -144,7 +144,6 @@
         exo23 = new Verse(2, 2, 3);
         exo3b = new Verse(2, 3, 11);
         rev99 = VerseFactory.fromString("Rev 22:21"); //$NON-NLS-1$
-        BibleInfo.setFullBookName(false);
     }
 
     /* (non-Javadoc)
@@ -156,7 +155,7 @@
         // float secs = (System.currentTimeMillis() - start) / 1000F;
         // log(type+" total = "+secs+"s =======================");
 
-        PassageKeyFactory.setDefaultPassage(PassageKeyFactory.SPEED);
+        PassageKeyFactory.setDefaultPassage(PassageType.toInteger(PassageType.SPEED));
     }
 
     public void testReadAddPassageListener() throws Exception
@@ -421,6 +420,8 @@
         assertEquals(keyf.getKey("exo 1:1, 4").getName(), "Exo 1:1, 4"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals(keyf.getKey("exo 1:1, 4, 2-3, 11-ff, 6-10").getName(), "Exo 1:1-4, 6-22"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals(keyf.getKey("Num 1, 2").getName(), "Num 1-2"); //$NON-NLS-1$ //$NON-NLS-2$
+        // Test for the sepaator being a space. This comes from "Clarke"
+        assertEquals(keyf.getKey("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"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testWriteBlur() throws Exception

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSizeTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSizeTest.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSizeTest.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -32,6 +32,6 @@
 {
     public PassageSizeTest(String s)
     {
-        super(s, PassageKeyFactory.SIZE, false);
+        super(s, PassageType.SIZE, false);
     }
 }
\ No newline at end of file

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedOptTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedOptTest.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedOptTest.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -32,6 +32,6 @@
 {
     public PassageSpeedOptTest(String s)
     {
-        super(s, PassageKeyFactory.SPEED, true);
+        super(s, PassageType.SPEED, true);
     }
 }

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedTest.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageSpeedTest.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -32,6 +32,6 @@
 {
     public PassageSpeedTest(String s)
     {
-        super(s, PassageKeyFactory.SPEED, false);
+        super(s, PassageType.SPEED, false);
     }
 }
\ No newline at end of file

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTallyTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTallyTest.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTallyTest.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -32,6 +32,6 @@
 {
     public PassageTallyTest(String s)
     {
-        super(s, PassageKeyFactory.TALLY, false);
+        super(s, PassageType.TALLY, false);
     }
 }
\ No newline at end of file

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageWriteSpeedTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageWriteSpeedTest.java	2006-11-03 04:17:16 UTC (rev 1176)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageWriteSpeedTest.java	2006-11-05 20:28:23 UTC (rev 1177)
@@ -32,6 +32,6 @@
 {
     public PassageWriteSpeedTest(String s)
     {
-        super(s, PassageKeyFactory.WRITE_SPEED, false);
+        super(s, PassageType.WRITE_SPEED, false);
     }
 }
\ No newline at end of file




More information about the jsword-svn mailing list