[jsword-svn] r2047 - in trunk: common-swing/src/main/java/org/crosswire/common/swing/desktop jsword jsword/etc/eclipse jsword/src/main/java/org/crosswire/common/compress jsword/src/main/java/org/crosswire/common/diff jsword/src/main/java/org/crosswire/common/options jsword/src/main/java/org/crosswire/common/progress jsword/src/main/java/org/crosswire/common/util jsword/src/main/java/org/crosswire/common/xml jsword/src/main/java/org/crosswire/jsword/book jsword/src/main/java/org/crosswire/jsword/book/sword jsword/src/main/java/org/crosswire/jsword/index/search jsword/src/main/java/org/crosswire/jsword/passage jsword/tools

dmsmith at crosswire.org dmsmith at crosswire.org
Mon Dec 6 20:49:58 MST 2010


Author: dmsmith
Date: 2010-12-06 20:49:58 -0700 (Mon, 06 Dec 2010)
New Revision: 2047

Added:
   trunk/jsword/tools/
Modified:
   trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/LayoutType.java
   trunk/jsword/etc/eclipse/jsword-ant-all.launch
   trunk/jsword/src/main/java/org/crosswire/common/compress/CompressorType.java
   trunk/jsword/src/main/java/org/crosswire/common/diff/EditType.java
   trunk/jsword/src/main/java/org/crosswire/common/options/ArgumentType.java
   trunk/jsword/src/main/java/org/crosswire/common/options/DataType.java
   trunk/jsword/src/main/java/org/crosswire/common/progress/Job.java
   trunk/jsword/src/main/java/org/crosswire/common/util/OSType.java
   trunk/jsword/src/main/java/org/crosswire/common/util/WebResource.java
   trunk/jsword/src/main/java/org/crosswire/common/xml/FormatType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/KeyType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BlockType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/index/search/SearchType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageListType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java
Log:
JS-141: Converted JSword's enums to be Java 5 enums

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/LayoutType.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/LayoutType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/LayoutType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,7 +21,6 @@
  */
 package org.crosswire.common.swing.desktop;
 
-import java.io.Serializable;
 
 /**
  * Types of ViewLayouts. Currently there are two types of desktop layouts:
@@ -35,77 +34,38 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class LayoutType implements Serializable {
+public enum LayoutType {
     /**
      * Tabbed View
      */
-    public static final LayoutType TDI = new LayoutType("TDI")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.common.swing.desktop.LayoutType#createLayout()
-         */
+    TDI {
         public AbstractViewLayout createLayout() {
             return new TDIViewLayout();
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.common.swing.desktop.LayoutType#toString()
-         */
         public String toString() {
             // TRANSLATOR: This is the name of one of two different ways to present Bible Views.
             // These show up in Options/Preferences.
             return UserMsg.gettext("Tabbed Document Interface");
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257572784669800241L;
-    };
-
     /**
      * Multiple Document View
      */
-    public static final LayoutType MDI = new LayoutType("MDI")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.common.swing.desktop.LayoutType#createLayout()
-         */
+    MDI {
         public AbstractViewLayout createLayout() {
             return new MDIViewLayout();
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.common.swing.desktop.LayoutType#toString()
-         */
         public String toString() {
             // TRANSLATOR: This is the name of one of two different ways to present Bible Views.
             // These show up in Options/Preferences.
             return UserMsg.gettext("Multiple Document Interface");
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3904681587101874488L;
     };
 
     /**
-     * Simple ctor
-     */
-    protected LayoutType(String name) {
-        this.name = name;
-    }
-
-    /**
      * Return the layout
      * 
      * @return the layout
@@ -131,91 +91,41 @@
      * Get an integer representation for this LayoutType
      */
     public int toInteger() {
-        for (int i = 0; i < VALUES.length; i++) {
-            if (equals(VALUES[i])) {
-                return i;
-            }
-        }
-        // cannot get here
-        assert false;
-        return -1;
+        return ordinal();
     }
 
     /**
      * Lookup method to convert from a String
      */
     public static LayoutType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            LayoutType obj = VALUES[i];
-            if (obj.name.equalsIgnoreCase(name)) {
-                return obj;
+        for (LayoutType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
     }
 
     /**
-     * Lookup method to convert from an integer
+     * Lookup method by ordinal value
      */
-    public static LayoutType fromInteger(int i) {
-        return VALUES[i];
-    }
+    public static LayoutType fromInteger(int ordinal) {
+        for (LayoutType v : values()) {
+            if (v.ordinal() == ordinal) {
+                return v;
+            }
+        }
 
-    /**
-     * 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);
+        // cannot get here
+        assert false;
+        return null;
     }
 
     /**
-     * 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 LayoutType
-     */
-    private String name;
-
-    /**
      * The actual layout
      */
-    protected AbstractViewLayout layout;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final LayoutType[] VALUES = {
-            TDI, MDI,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 5443546249176482187L;
+    private transient AbstractViewLayout layout;
 }

Modified: trunk/jsword/etc/eclipse/jsword-ant-all.launch
===================================================================
--- trunk/jsword/etc/eclipse/jsword-ant-all.launch	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/etc/eclipse/jsword-ant-all.launch	2010-12-07 03:49:58 UTC (rev 2047)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <launchConfiguration type="org.eclipse.ant.AntLaunchConfigurationType">
-<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
 <listEntry value="/jsword/build.xml"/>
 </listAttribute>
@@ -9,7 +9,7 @@
 </listAttribute>
 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5.0/"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5.0"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.launching.remote.InternalAntRunner"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="jsword"/>
 <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/jsword}"/>

Modified: trunk/jsword/src/main/java/org/crosswire/common/compress/CompressorType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/compress/CompressorType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/compress/CompressorType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -22,7 +22,6 @@
 package org.crosswire.common.compress;
 
 import java.io.ByteArrayInputStream;
-import java.io.Serializable;
 
 /**
  * An Enumeration of the possible Compressions.
@@ -31,112 +30,41 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class CompressorType implements Serializable {
-    /**
-     * Delete a sequence.
-     */
-    public static final CompressorType ZIP = new CompressorType("ZIP") {
-
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.common.compress.CompressorType#getCompressor(byte[])
-         */
+public enum CompressorType {
+    ZIP {
         public Compressor getCompressor(byte[] input) {
             return new Zip(new ByteArrayInputStream(input));
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 7380833510438155782L;
-    };
+    LZSS {
 
-    /**
-     * Insert a sequence
-     */
-    public static final CompressorType LZSS = new CompressorType("LZSS") {
-
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.common.compress.CompressorType#getCompressor(byte[])
-         */
         public Compressor getCompressor(byte[] input) {
             return new LZSS(new ByteArrayInputStream(input));
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = -5794644645111043930L;
     };
 
     /**
-     * @param name
-     *            The name of the CompressorType
-     */
-    protected CompressorType(String name) {
-        this.name = name;
-    }
-
-    /**
      * Get a compressor.
+     * @param input the stream to compress or to uncompress.
      */
     public abstract Compressor getCompressor(byte[] input);
 
     /**
-     * Lookup method to convert from a String
+     * Get a CompressorType from a String
+     * 
+     * @param name the case insensitive representation of the desired CompressorType
+     * @return the desired compressor or null if not found.
      */
     public static CompressorType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            CompressorType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (CompressorType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
     }
-
-    /**
-     * Lookup method to convert from an integer
-     */
-    public static CompressorType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
-    public String toString() {
-        return name;
-    }
-
-    /**
-     * The name of the CompressorType
-     */
-    private String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final CompressorType[] VALUES = {
-            ZIP, LZSS,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3256727260177708345L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/common/diff/EditType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/diff/EditType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/diff/EditType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.common.diff;
 
-import java.io.Serializable;
-
 /**
  * An Enumeration of the possible Edits.
  * 
@@ -30,21 +28,21 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public final class EditType implements Serializable {
+public enum EditType  {
     /**
      * Delete a sequence.
      */
-    public static final EditType DELETE = new EditType("Delete", '-');
+    DELETE  ("Delete", '-'),
 
     /**
      * Insert a sequence
      */
-    public static final EditType INSERT = new EditType("Insert", '+');
+    INSERT  ("Insert", '+'),
 
     /**
      * Equal sequences
      */
-    public static final EditType EQUAL = new EditType("Equal", ' ');
+    EQUAL ("Equal", ' ');
 
     /**
      * @param name
@@ -63,15 +61,18 @@
     }
 
     /**
-     * Lookup method to convert from a String
+     * Get a CompressorType from a String
+     * 
+     * @param name the case insensitive representation of the desired CompressorType
+     * @return the desired compressor or null if not found.
      */
     public static EditType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            EditType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (EditType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
@@ -81,24 +82,17 @@
      * Lookup method to convert from a String
      */
     public static EditType fromSymbol(char symbol) {
-        for (int i = 0; i < VALUES.length; i++) {
-            EditType o = VALUES[i];
-            if (o.symbol == symbol) {
-                return o;
+        for (EditType v : values()) {
+            if (v.symbol == symbol) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
     }
 
-    /**
-     * Lookup method to convert from an integer
-     */
-    public static EditType fromInteger(int i) {
-        return VALUES[i];
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -117,21 +111,4 @@
      * The symbol representing the EditType
      */
     private char symbol;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final EditType[] VALUES = {
-            DELETE, INSERT, EQUAL,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3256727260177708345L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/common/options/ArgumentType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/options/ArgumentType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/options/ArgumentType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -19,11 +19,8 @@
  *
  * ID: $Id: org.eclipse.jdt.ui.prefs 1178 2006-11-06 12:48:02Z dmsmith $
  */
-
 package org.crosswire.common.options;
 
-import java.io.Serializable;
-
 /**
  * An ArgumentType indicates whether and/or how an Option is followed by an
  * argument.
@@ -32,27 +29,27 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class ArgumentType implements Serializable {
+public enum ArgumentType {
     /**
      * The option is not followed by an argument.
      */
-    public static final ArgumentType NO_ARGUMENT = new ArgumentType("NO");
+    NO_ARGUMENT  ("NO"),
 
     /**
      * The option is followed by an argument.
      */
-    public static final ArgumentType REQUIRED_ARGUMENT = new ArgumentType("Required");
+    REQUIRED_ARGUMENT  ("Required"),
 
     /**
      * The option may be followed by an argument.
      */
-    public static final ArgumentType OPTIONAL_ARGUMENT = new ArgumentType("Optional");
+    OPTIONAL_ARGUMENT ("Optional");
 
     /**
      * @param name
      *            The name of the DataType
      */
-    protected ArgumentType(String name) {
+    private ArgumentType(String name) {
         this.name = name;
     }
 
@@ -60,29 +57,20 @@
      * Lookup method to convert from a String
      */
     public static ArgumentType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            ArgumentType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (ArgumentType v : values()) {
+            if (v.name.equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
     }
 
-    /**
-     * Lookup method to convert from an integer
+    /* (non-Javadoc)
+     * @see java.lang.Enum#toString()
      */
-    public static ArgumentType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     public String toString() {
         return name;
     }
@@ -91,22 +79,4 @@
      * The name of the DataType
      */
     private String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final ArgumentType[] VALUES = {
-            NO_ARGUMENT, REQUIRED_ARGUMENT, OPTIONAL_ARGUMENT
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3256727260177708345L;
-
 }

Modified: trunk/jsword/src/main/java/org/crosswire/common/options/DataType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/options/DataType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/options/DataType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -19,11 +19,8 @@
  *
  * ID: $Id: org.eclipse.jdt.ui.prefs 1178 2006-11-06 12:48:02Z dmsmith $
  */
-
 package org.crosswire.common.options;
 
-import java.io.Serializable;
-
 import org.crosswire.common.util.Convert;
 
 /**
@@ -33,83 +30,46 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class DataType implements Serializable {
+public enum DataType {
     /**
      * A string argument.
      */
-    public static final DataType STRING = new DataType("String")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.common.options.DataType#convertFromString(java.lang
-         * .String)
-         */
+    STRING  ("String") {
         public Object convertFromString(String value) {
             return value;
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = -2521783846509171308L;
-    };
-
     /**
      * An integer argument.
      */
-    public static final DataType INTEGER = new DataType("Integer")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.common.options.DataType#convertFromString(java.lang
-         * .String)
-         */
+    INTEGER  ("Integer") {
         public Object convertFromString(String value) {
             return Integer.valueOf(Convert.string2Int(value));
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = -2521783846509171308L;
-    };
-
     /**
      * An boolean argument that allows various values for 'true'.
      */
-    public static final DataType BOOLEAN = new DataType("Boolean")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.common.options.DataType#convertFromString(java.lang
-         * .String)
-         */
+    BOOLEAN ("Boolean") {
         public Object convertFromString(String value) {
             return Boolean.valueOf(Convert.string2Boolean(value));
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = -2521783846509171308L;
     };
 
     /**
      * @param name
      *            The name of the DataType
      */
-    protected DataType(String name) {
+    private DataType(String name) {
         this.name = name;
     }
 
     /**
-     * Convert a String to an Arguments expected value.
+     * Convert a String to an DataType's expected value.
+     * @param input the string to convert
+     * @return the converted value
      */
     public abstract Object convertFromString(String input);
 
@@ -117,10 +77,9 @@
      * Lookup method to convert from a String
      */
     public static DataType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            DataType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (DataType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
         // cannot get here
@@ -128,18 +87,9 @@
         return null;
     }
 
-    /**
-     * Lookup method to convert from an integer
+    /* (non-Javadoc)
+     * @see java.lang.Enum#toString()
      */
-    public static DataType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     public String toString() {
         return name;
     }
@@ -148,20 +98,4 @@
      * The name of the DataType
      */
     private String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final DataType[] VALUES = {};
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3256727260177708345L;
-
 }

Modified: trunk/jsword/src/main/java/org/crosswire/common/progress/Job.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/progress/Job.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/progress/Job.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -277,7 +277,7 @@
             percent = 100;
 
             if (nextPredictionMap != null) {
-                nextPredictionMap.put(currentSectionName, Integer.valueOf((int)(System.currentTimeMillis() - startTime)));
+                nextPredictionMap.put(currentSectionName, Integer.valueOf((int) (System.currentTimeMillis() - startTime)));
             }
         }
 

Modified: trunk/jsword/src/main/java/org/crosswire/common/util/OSType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/util/OSType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/util/OSType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -22,7 +22,6 @@
 package org.crosswire.common.util;
 
 import java.io.File;
-import java.io.Serializable;
 import java.net.URI;
 
 /**
@@ -32,95 +31,41 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class OSType implements Serializable {
-    public static final OSType MAC = new OSType("Mac")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.util.OSType#getUserArea()
-         */
+public enum OSType {
+    MAC  ("Mac") {
         public URI getUserArea() {
             return NetUtil.lengthenURI(getUserHome(), MAC_USER_DATA_AREA);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.util.OSType#getUserAreaFolder(java.lang.String,
-         * java.lang.String)
-         */
         public URI getUserAreaFolder(String hiddenFolderName, String visibleFolderName) {
             return NetUtil.lengthenURI(getUserArea(), visibleFolderName);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = -1575982665011980783L;
-    };
-
-    public static final OSType WIN32 = new OSType("Win")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.util.OSType#getUserArea()
-         */
+    WIN32  ("Win") {
         public URI getUserArea() {
             return NetUtil.lengthenURI(getUserHome(), WIN32_USER_DATA_AREA);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.util.OSType#getUserAreaFolder(java.lang.String,
-         * java.lang.String)
-         */
         public URI getUserAreaFolder(String hiddenFolderName, String visibleFolderName) {
             return NetUtil.lengthenURI(getUserArea(), visibleFolderName);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 2448098399487879399L;
-    };
-
-    public static final OSType DEFAULT = new OSType("*nix")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.util.OSType#getUserArea()
-         */
+    DEFAULT ("*nix") {
         public URI getUserArea() {
             return getUserHome();
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.util.OSType#getUserAreaFolder(java.lang.String,
-         * java.lang.String)
-         */
         public URI getUserAreaFolder(String hiddenFolderName, String visibleFolderName) {
             return NetUtil.lengthenURI(getUserArea(), hiddenFolderName);
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 8260119208395182688L;
     };
 
     /**
      * Simple ctor
      */
-    public OSType(String name) {
+    private OSType(String name) {
         this.name = name;
     }
 
@@ -149,20 +94,6 @@
     }
 
     /**
-     * Get an integer representation for this CaseType
-     */
-    public int toInteger() {
-        for (int i = 0; i < VALUES.length; i++) {
-            if (equals(VALUES[i])) {
-                return i;
-            }
-        }
-        // cannot get here
-        assert false;
-        return -1;
-    }
-
-    /**
      * Get the machine's OSType.
      * 
      * @return the machine's OSType
@@ -175,42 +106,15 @@
      * Lookup method to convert from a String
      */
     public static OSType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            OSType o = VALUES[i];
-            if (name.startsWith(o.name)) {
-                return o;
+        for (OSType v : values()) {
+            if (v.name.equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         return DEFAULT;
     }
 
-    /**
-     * Lookup method to convert from an integer
-     */
-    public static OSType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /**
-     * 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)
      * 
@@ -225,18 +129,6 @@
      */
     private String name;
 
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final OSType[] VALUES = {
-            MAC, WIN32, DEFAULT,
-    };
-
     /**
      * The Windows user settings parent directory
      */
@@ -251,9 +143,4 @@
      * The machine's osType
      */
     private static OSType osType = fromString(System.getProperty("os.name"));
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = -3196320305857293885L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/common/util/WebResource.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/util/WebResource.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/util/WebResource.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -259,14 +259,12 @@
     public void copy(URI dest, Progress meter) throws LucidException  {
         InputStream in = null;
         OutputStream out = null;
-long startDownload = System.currentTimeMillis();
         HttpRequestBase method = new HttpGet(uri);
         HttpResponse response = null;
         HttpEntity entity = null;
         try {
             // Execute the method.
             response = client.execute(method);
-int afterExecute = (int) (System.currentTimeMillis() - startDownload);
             // Initialize the meter, if present
             if (meter != null) {
                 // Find out how big it is
@@ -277,12 +275,10 @@
                 }
                 meter.setTotalWork(size);
             }
-            long afterSize = (System.currentTimeMillis() - startDownload - afterExecute);
 
             entity = response.getEntity();
             if (entity != null) {
                 in = entity.getContent();
-                long afterEntity = (System.currentTimeMillis() - startDownload - afterSize);
 
                 // Download the index file
                 out = NetUtil.getOutputStream(dest);
@@ -296,12 +292,6 @@
                     out.write(buf, 0, count);
                     count = in.read(buf);
                 }
-                long afterWrite = (System.currentTimeMillis() - startDownload - afterEntity);
-                System.out.println("execute = " + afterExecute + "ms\n" +
-                        "size = " + afterSize + "ms\n" +
-                        "entity = " + afterEntity + "ms\n" +
-                        "write = " + afterWrite + "ms\n"
-                        );
             } else {
                 String reason = response.getStatusLine().getReasonPhrase();
                 // TRANSLATOR: Common error condition: {0} is a placeholder for

Modified: trunk/jsword/src/main/java/org/crosswire/common/xml/FormatType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/xml/FormatType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/common/xml/FormatType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.common.xml;
 
-import java.io.Serializable;
-
 /**
  * The PrettySerializingContentHandler uses a FormatType to control its output.
  * 
@@ -30,18 +28,17 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public final class FormatType implements Serializable {
-    public static final FormatType AS_IS = new FormatType("AS_IS", false, false, false);
-    public static final FormatType ANALYSIS = new FormatType("ANALYSIS", true, false, false);
-    public static final FormatType CLASSIC = new FormatType("CLASSIC", true, false, true);
-    public static final FormatType ANALYSIS_INDENT = new FormatType("ANALYSIS_INDENT", true, true, false);
-    public static final FormatType CLASSIC_INDENT = new FormatType("CLASSIC_INDENT", true, true, true);
+public enum FormatType {
+    AS_IS           (false, false, false),
+    ANALYSIS        (true,  false, false),
+    CLASSIC         (true,  false, true),
+    ANALYSIS_INDENT (true,  true,  false),
+    CLASSIC_INDENT  (true,  true,  true);
 
     /**
      * Simple ctor
      */
-    public FormatType(String aName, boolean displayNewlines, boolean doIndenting, boolean classicLines) {
-        name = aName;
+    private FormatType(boolean displayNewlines, boolean doIndenting, boolean classicLines) {
         multiline = displayNewlines;
         // the following are true only if we add newlines.
         indented = doIndenting && multiline;
@@ -87,74 +84,8 @@
         return classic;
     }
 
-    /**
-     * Get an integer representation for this FormatType
-     */
-    public int toInteger() {
-        for (int i = 0; i < VALUES.length; i++) {
-            if (equals(VALUES[i])) {
-                return i;
-            }
-        }
-        // cannot get here
-        assert false;
-        return -1;
-    }
-
-    /**
-     * Lookup method to convert from a String
-     */
-    public static FormatType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            FormatType obj = VALUES[i];
-            if (obj.name.equalsIgnoreCase(name)) {
-                return obj;
-            }
-        }
-        // cannot get here
-        assert false;
-        return null;
-    }
-
-    /**
-     * Lookup method to convert from an integer
-     */
-    public static FormatType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
-    public String toString() {
-        return name;
-    }
-
-    /**
-     * The name of the FormatType
-     */
-    private String name;
     private boolean indented;
     private boolean multiline;
     private boolean analytic;
     private boolean classic;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final FormatType[] VALUES = {
-            AS_IS, ANALYSIS, CLASSIC, ANALYSIS_INDENT, CLASSIC_INDENT,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3544385916136142129L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/CaseType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,7 +21,6 @@
  */
 package org.crosswire.jsword.book;
 
-import java.io.Serializable;
 import java.util.Locale;
 
 /**
@@ -32,21 +31,14 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class CaseType implements Serializable {
-    public static final CaseType LOWER = new CaseType("LOWER")
-    {
+public enum CaseType {
+    LOWER  {
         public String setCase(String word) {
             return word.toLowerCase(Locale.getDefault());
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3546637707360286256L;
-    };
-
-    public static final CaseType SENTENCE = new CaseType("SENTENCE")
-    {
+    SENTENCE {
         public String setCase(String word) {
             int index = word.indexOf('-');
             if (index == -1) {
@@ -69,42 +61,24 @@
             // So cut by the -
             return toSentenceCase(word.substring(0, index)) + "-" + toSentenceCase(word.substring(index + 1));
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3905520510312985138L;
-    };
-
-    public static final CaseType UPPER = new CaseType("UPPER")
-    {
+    UPPER {
         public String setCase(String word) {
             return word.toUpperCase(Locale.getDefault());
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257002163871035698L;
     };
 
     public abstract String setCase(String word);
 
     /**
-     * Simple ctor
-     */
-    public CaseType(String name) {
-        this.name = name;
-    }
-
-    /**
-     * Change to sentence case - ie first character in caps, the rest in lower.
+     * Change to sentence case - that is first character in caps, the rest in lower.
      * 
      * @param word
      *            The word to be manipulated
      * @return The altered word
      */
-    protected static String toSentenceCase(String word) {
+    public static String toSentenceCase(String word) {
         assert word != null;
 
         if (word.length() == 0) {
@@ -158,26 +132,19 @@
      * Get an integer representation for this CaseType
      */
     public int toInteger() {
-        for (int i = 0; i < VALUES.length; i++) {
-            if (equals(VALUES[i])) {
-                return i;
-            }
-        }
-        // cannot get here
-        assert false;
-        return -1;
+        return ordinal();
     }
 
     /**
      * Lookup method to convert from a String
      */
     public static CaseType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            CaseType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (CaseType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
@@ -187,57 +154,15 @@
      * Lookup method to convert from an integer
      */
     public static CaseType fromInteger(int i) {
-        return VALUES[i];
-    }
+        for (CaseType v : values()) {
+            if (v.ordinal() == i) {
+                return v;
+            }
+        }
 
-    /**
-     * 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);
+        // cannot get here
+        assert false;
+        return null;
     }
 
-    /**
-     * 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 type
-     */
-    private transient String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final CaseType[] VALUES = {
-            LOWER, SENTENCE, UPPER,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = -63772726311422060L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/FeatureType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,8 @@
  */
 package org.crosswire.jsword.book;
 
-import java.io.Serializable;
 
+
 /**
  * An Enumeration of the possible Features a Book may have.
  * 
@@ -30,66 +30,66 @@
  *      The copyright to this program is held by it's authors.
  * @author Joe Walker [joe at eireneh dot com]
  */
-public final class FeatureType implements Serializable {
+public enum FeatureType {
     /**
      * The book is one of Greek Definitions. AKA, Strong's.
      */
-    public static final FeatureType GREEK_DEFINITIONS = new FeatureType("GreekDef");
+    GREEK_DEFINITIONS ("GreekDef"),
 
     /**
      * The book is one of Greek word parsings. AKA, Robinson.
      */
-    public static final FeatureType GREEK_PARSE = new FeatureType("GreekParse");
+    GREEK_PARSE ("GreekParse"),
 
     /**
      * The book is one of Hebrew Definitions. AKA, Strong's.
      */
-    public static final FeatureType HEBREW_DEFINITIONS = new FeatureType("HebrewDef");
+    HEBREW_DEFINITIONS ("HebrewDef"),
 
     /**
      * The book is one of Hebrew word parsings. AKA, ???.
      */
-    public static final FeatureType HEBREW_PARSE = new FeatureType("HebrewParse");
+    HEBREW_PARSE ("HebrewParse"),
 
     /**
      * The book is one of Daily Devotions.
      */
-    public static final FeatureType DAILY_DEVOTIONS = new FeatureType("DailyDevotions");
+    DAILY_DEVOTIONS ("DailyDevotions"),
 
     /**
      * The book is glossary of translations from one language to another.
      */
-    public static final FeatureType GLOSSARY = new FeatureType("Glossary");
+    GLOSSARY ("Glossary"),
 
     /**
      * The book contains Strong's Numbers
      */
-    public static final FeatureType STRONGS_NUMBERS = new FeatureType("StrongsNumbers");
+    STRONGS_NUMBERS ("StrongsNumbers"),
 
     /**
      * The book contains footnotes
      */
-    public static final FeatureType FOOTNOTES = new FeatureType("Footnotes");
+    FOOTNOTES ("Footnotes"),
 
     /**
      * The book contains Scripture cross references
      */
-    public static final FeatureType SCRIPTURE_REFERENCES = new FeatureType("Scripref");
+    SCRIPTURE_REFERENCES ("Scripref"),
 
     /**
      * The book marks the Word's of Christ
      */
-    public static final FeatureType WORDS_OF_CHRIST = new FeatureType("RedLetterText");
+    WORDS_OF_CHRIST ("RedLetterText"),
 
     /**
      * The book contains Morphology info
      */
-    public static final FeatureType MORPHOLOGY = new FeatureType("Morph");
+    MORPHOLOGY ("Morph"),
 
     /**
      * The book contains Headings
      */
-    public static final FeatureType HEADINGS = new FeatureType("Headings");
+    HEADINGS ("Headings");
 
     /**
      * @param name
@@ -103,29 +103,20 @@
      * Lookup method to convert from a String
      */
     public static FeatureType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            FeatureType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (FeatureType v : values()) {
+            if (v.name.equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
     }
 
-    /**
-     * Lookup method to convert from an integer
+    /* (non-Javadoc)
+     * @see java.lang.Enum#toString()
      */
-    public static FeatureType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     public String toString() {
         return name;
     }
@@ -134,22 +125,4 @@
      * The name of the FeatureType
      */
     private String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final FeatureType[] VALUES = {
-            GREEK_DEFINITIONS, GREEK_PARSE, HEBREW_DEFINITIONS, HEBREW_PARSE, DAILY_DEVOTIONS, GLOSSARY, STRONGS_NUMBERS, FOOTNOTES, SCRIPTURE_REFERENCES,
-            WORDS_OF_CHRIST, MORPHOLOGY, HEADINGS,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3256727260177708345L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/KeyType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/KeyType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/KeyType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,7 +21,6 @@
  */
 package org.crosswire.jsword.book;
 
-import java.io.Serializable;
 
 /**
  * Types of Key that a Book uses, either verse, list, or tree.
@@ -30,114 +29,42 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class KeyType implements Serializable {
+public enum KeyType {
     /**
      * Book contains verses and can be understood as book, chapter and verse.
      */
-    public static final KeyType VERSE = new KeyType("verse");
+    VERSE,
 
     /**
      * Book organizes its entries in a list, as in a dictionary.
      */
-    public static final KeyType LIST = new KeyType("list");
+    LIST,
 
     /**
      * Book organizes its entries in a tree, as in a general book.
      */
-    public static final KeyType TREE = new KeyType("tree");
+    TREE;
 
     /**
-     * Simple ctor
-     */
-    public KeyType(String name) {
-        this.name = name;
-    }
-
-    /**
      * Get an integer representation for this CaseType
      */
     public int toInteger() {
-        for (int i = 0; i < VALUES.length; i++) {
-            if (equals(VALUES[i])) {
-                return i;
-            }
-        }
-        // cannot get here
-        assert false;
-        return -1;
+        return ordinal();
     }
 
     /**
      * Lookup method to convert from a String
      */
     public static KeyType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            KeyType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (KeyType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
     }
 
-    /**
-     * Lookup method to convert from an integer
-     */
-    public static KeyType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /**
-     * 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 type
-     */
-    private transient String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final KeyType[] VALUES = {
-            VERSE, LIST, TREE,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 8856576924393105712L;
-
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BlockType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BlockType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BlockType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,7 +21,6 @@
  */
 package org.crosswire.jsword.book.sword;
 
-import java.io.Serializable;
 
 /**
  * Block types indicates the grain of compression.
@@ -31,57 +30,28 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class BlockType implements Serializable {
+public enum BlockType {
     /**
      * The level of compression is the Book
      */
-    public static final BlockType BLOCK_BOOK = new BlockType("BOOK")
-    {
-        public char getIndicator() {
-            return 'b';
-        }
+    BLOCK_BOOK ("BOOK", 'b'),
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257569486067807287L;
-    };
-
     /**
      * The level of compression is the Book
      */
-    public static final BlockType BLOCK_CHAPTER = new BlockType("CHAPTER")
-    {
-        public char getIndicator() {
-            return 'c';
-        }
+    BLOCK_CHAPTER ("CHAPTER", 'c'),
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3762533416838968372L;
-    };
-
     /**
      * The level of compression is the Book
      */
-    public static final BlockType BLOCK_VERSE = new BlockType("VERSE")
-    {
-        public char getIndicator() {
-            return 'v';
-        }
+    BLOCK_VERSE ("VERSE", 'v');
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257572793192362551L;
-    };
-
     /**
      * Simple ctor
      */
-    public BlockType(String name) {
+    private BlockType(String name, char indicator) {
         this.name = name;
+        this.indicator = indicator;
     }
 
     /**
@@ -90,54 +60,26 @@
      * 
      * @return the indicator
      */
-    abstract char getIndicator();
+    public char getIndicator() {
+        return indicator;
+    }
 
     /**
      * Lookup method to convert from a String
      */
     public static BlockType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            BlockType obj = VALUES[i];
-            if (obj.name.equalsIgnoreCase(name)) {
-                return obj;
+        for (BlockType v : values()) {
+            if (v.name.equalsIgnoreCase(name)) {
+                return v;
             }
         }
 
         throw new ClassCastException(Msg.UNDEFINED_DATATYPE.toString(name));
     }
 
-    /**
-     * Lookup method to convert from an integer
+    /* (non-Javadoc)
+     * @see java.lang.Enum#toString()
      */
-    public static BlockType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /**
-     * 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;
     }
@@ -146,21 +88,8 @@
      * The name of the BlockType
      */
     private String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final BlockType[] VALUES = {
-            BLOCK_BOOK, BLOCK_CHAPTER, BLOCK_VERSE,
-    };
-
     /**
-     * Serialization ID
+     * The indicator for the BlockType
      */
-    private static final long serialVersionUID = 1411226089933054161L;
+    private char indicator;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.jsword.book.sword;
 
-import java.io.Serializable;
-
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.BookCategory;
 import org.crosswire.jsword.book.BookException;
@@ -36,11 +34,11 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class BookType implements Serializable {
+public enum BookType {
     /**
      * Uncompressed Bibles
      */
-    public static final BookType RAW_TEXT = new BookType("RawText", BookCategory.BIBLE) {
+    RAW_TEXT ("RawText", BookCategory.BIBLE, KeyType.VERSE) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordBook(sbmd, backend);
@@ -49,26 +47,12 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new RawBackend(sbmd, 2);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.VERSE;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3544385920414529336L;
-    };
-
     /**
      * Compressed Bibles
      */
-    public static final BookType Z_TEXT = new BookType("zText", BookCategory.BIBLE) {
+    Z_TEXT ("zText", BookCategory.BIBLE, KeyType.VERSE) {
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordBook(sbmd, backend);
         }
@@ -77,26 +61,12 @@
             BlockType blockType = BlockType.fromString((String) sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
             return new ZVerseBackend(sbmd, blockType);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.VERSE;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257846571620906039L;
-    };
-
     /**
      * Uncompressed Commentaries
      */
-    public static final BookType RAW_COM = new BookType("RawCom", BookCategory.COMMENTARY) {
+    RAW_COM ("RawCom", BookCategory.COMMENTARY, KeyType.VERSE) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordBook(sbmd, backend);
@@ -105,24 +75,10 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new RawBackend(sbmd, 2);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.VERSE;
-        }
+    RAW_COM4 ("RawCom4", BookCategory.COMMENTARY, KeyType.VERSE) {
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3258129141898294837L;
-    };
-
-    public static final BookType RAW_COM4 = new BookType("RawCom4", BookCategory.COMMENTARY) {
-
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordBook(sbmd, backend);
         }
@@ -130,25 +86,12 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new RawBackend(sbmd, 4);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.VERSE;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3258129141898294838L;
-    };
     /**
      * Compressed Commentaries
      */
-    public static final BookType Z_COM = new BookType("zCom", BookCategory.COMMENTARY) {
+    Z_COM ("zCom", BookCategory.COMMENTARY, KeyType.VERSE) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordBook(sbmd, backend);
@@ -158,26 +101,12 @@
             BlockType blockType = BlockType.fromString((String) sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
             return new ZVerseBackend(sbmd, blockType);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.VERSE;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257569516166002487L;
-    };
-
     /**
      * Uncompresses HREF Commentaries
      */
-    public static final BookType HREF_COM = new BookType("HREFCom", BookCategory.COMMENTARY) {
+    HREF_COM ("HREFCom", BookCategory.COMMENTARY, KeyType.VERSE) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordBook(sbmd, backend);
@@ -186,26 +115,12 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new RawBackend(sbmd, 2);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.VERSE;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3256439209706338354L;
-    };
-
     /**
      * Uncompressed Commentaries
      */
-    public static final BookType RAW_FILES = new BookType("RawFiles", BookCategory.COMMENTARY) {
+    RAW_FILES ("RawFiles", BookCategory.COMMENTARY, KeyType.VERSE) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordBook(sbmd, backend);
@@ -214,26 +129,12 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new RawFileBackend(sbmd, 2);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.VERSE;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3256446901875325236L;
-    };
-
     /**
      * 2-Byte Index Uncompressed Dictionaries
      */
-    public static final BookType RAW_LD = new BookType("RawLD", BookCategory.DICTIONARY) {
+    RAW_LD ("RawLD", BookCategory.DICTIONARY, KeyType.LIST) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             if (sbmd.getBookCategory().equals(BookCategory.DAILY_DEVOTIONS)) {
@@ -245,26 +146,12 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new RawLDBackend(sbmd, 2);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.LIST;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257290240195442745L;
-    };
-
     /**
      * 4-Byte Index Uncompressed Dictionaries
      */
-    public static final BookType RAW_LD4 = new BookType("RawLD4", BookCategory.DICTIONARY) {
+    RAW_LD4 ("RawLD4", BookCategory.DICTIONARY, KeyType.LIST) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             if (sbmd.getBookCategory().equals(BookCategory.DAILY_DEVOTIONS)) {
@@ -276,26 +163,12 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new RawLDBackend(sbmd, 4);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.LIST;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3689067356945331762L;
-    };
-
     /**
      * Compressed Dictionaries
      */
-    public static final BookType Z_LD = new BookType("zLD", BookCategory.DICTIONARY) {
+    Z_LD ("zLD", BookCategory.DICTIONARY, KeyType.LIST) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             if (sbmd.getBookCategory().equals(BookCategory.DAILY_DEVOTIONS)) {
@@ -307,26 +180,12 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new ZLDBackend(sbmd);
         }
+    },
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.LIST;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3691037673259414067L;
-    };
-
     /**
      * Generic Books
      */
-    public static final BookType RAW_GEN_BOOK = new BookType("RawGenBook", BookCategory.GENERAL_BOOK) {
+    RAW_GEN_BOOK ("RawGenBook", BookCategory.GENERAL_BOOK, KeyType.TREE) {
 
         protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend) {
             return new SwordGenBook(sbmd, backend);
@@ -335,28 +194,15 @@
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException {
             return new GenBookBackend(sbmd);
         }
-
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.book.sword.BookType#getKeyType()
-         */
-        public KeyType getKeyType() {
-            return KeyType.TREE;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257290218703892528L;
     };
 
     /**
      * Simple ctor
      */
-    public BookType(String name, BookCategory type) {
+    private BookType(String name, BookCategory category, KeyType type) {
         this.name = name;
-        this.type = type;
+        this.category = category;
+        this.keyType = type;
     }
 
     /**
@@ -367,10 +213,9 @@
      * @return The found BookType or null if the name is not found
      */
     public static BookType getBookType(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            BookType mod = VALUES[i];
-            if (mod.name.equalsIgnoreCase(name)) {
-                return mod;
+        for (BookType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
 
@@ -381,10 +226,19 @@
      * The category of this book
      */
     public BookCategory getBookCategory() {
-        return type;
+        return category;
     }
 
     /**
+     * Get the way this type of Book organizes it's keys.
+     * 
+     * @return the organization of keys for this book
+     */
+    public KeyType getKeyType() {
+        return keyType;
+    }
+
+    /**
      * Given a SwordBookMetaData determine whether this BookType will work for
      * it.
      * 
@@ -393,7 +247,7 @@
      * @return true if this is a usable BookType
      */
     public boolean isSupported(SwordBookMetaData sbmd) {
-        return type != null && sbmd != null;
+        return category != null && sbmd != null;
     }
 
     /**
@@ -416,79 +270,37 @@
     protected abstract AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException;
 
     /**
-     * Get the way this type of Book organizes it's keys.
-     * 
-     * @return the organization of keys for this book
+     * The name of the BookType
      */
-    public abstract KeyType getKeyType();
+    private String name;
 
     /**
-     * The name of the BookType
+     * What category is this book
      */
-    private String name;
+    private BookCategory category;
 
     /**
      * What category is this book
      */
-    private BookCategory type;
+    private KeyType keyType;
 
     /**
      * Lookup method to convert from a String
      */
     public static BookType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            BookType mod = VALUES[i];
-            if (mod.name.equalsIgnoreCase(name)) {
-                return mod;
+        for (BookType v : values()) {
+            if (v.name.equalsIgnoreCase(name)) {
+                return v;
             }
         }
 
         throw new ClassCastException(Msg.UNDEFINED_DATATYPE.toString(name));
     }
 
-    /**
-     * Prevent subclasses from overriding canonical identity based Object
-     * methods
-     * 
-     * @see java.lang.Object#equals(java.lang.Object)
+    /* (non-Javadoc)
+     * @see java.lang.Enum#toString()
      */
-    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;
     }
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final BookType[] VALUES = {
-            RAW_TEXT, Z_TEXT, RAW_COM, RAW_COM4, Z_COM, RAW_COM, HREF_COM, RAW_FILES, RAW_LD, RAW_LD4, Z_LD, RAW_GEN_BOOK,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 5597156322295331692L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/search/SearchType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/search/SearchType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/search/SearchType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.jsword.index.search;
 
-import java.io.Serializable;
-
 import org.crosswire.jsword.index.query.QueryDecorator;
 import org.crosswire.jsword.index.query.QueryDecoratorFactory;
 
@@ -33,167 +31,76 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class SearchType implements Serializable {
+public enum SearchType {
     /**
      * Find the words in the specified order.
      */
-    public static final SearchType PHRASE = new SearchType("Phrase")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.index.search.SearchType#decorate(java.lang.String
-         * )
-         */
+    PHRASE ("Phrase") {
         public String decorate(String queryWords) {
             return SEARCH_SYNTAX.decoratePhrase(queryWords);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 4049921554181534256L;
-    };
-
     /**
      * Find all the words regardless of position.
      */
-    public static final SearchType ALL_WORDS = new SearchType("All")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.index.search.SearchType#decorate(java.lang.String
-         * )
-         */
+    ALL_WORDS ("All") {
         public String decorate(String queryWords) {
             return SEARCH_SYNTAX.decorateAllWords(queryWords);
         }
+   },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3256721771208980279L;
-    };
-
     /**
      * Find any of these words
      */
-    public static final SearchType ANY_WORDS = new SearchType("Any")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.index.search.SearchType#decorate(java.lang.String
-         * )
-         */
+    ANY_WORDS ("Any") {
         public String decorate(String queryWords) {
             return SEARCH_SYNTAX.decorateAnyWords(queryWords);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257846580244853043L;
-    };
-
     /**
      * Find verses not containing these words. Note this may require being added
      * after words being sought.
      */
-    public static final SearchType NOT_WORDS = new SearchType("Not")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.index.search.SearchType#decorate(java.lang.String
-         * )
-         */
+    NOT_WORDS ("Not") {
         public String decorate(String queryWords) {
             return SEARCH_SYNTAX.decorateNotWords(queryWords);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 4050480123318842929L;
-    };
-
     /**
      * Find verses with words that start with the these beginnings.
      */
-    public static final SearchType START_WORDS = new SearchType("Start")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.index.search.SearchType#decorate(java.lang.String
-         * )
-         */
+    START_WORDS ("Start") {
         public String decorate(String queryWords) {
             return SEARCH_SYNTAX.decorateStartWords(queryWords);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3544667378161168437L;
-    };
-
     /**
      * Find verses with words spelled something like
      */
-    public static final SearchType SPELL_WORDS = new SearchType("Spell")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.index.search.SearchType#decorate(java.lang.String
-         * )
-         */
+    SPELL_WORDS ("Spell") {
         public String decorate(String queryWords) {
             return SEARCH_SYNTAX.decorateSpellWords(queryWords);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3544387006957237044L;
-    };
-
     /**
      * Find verses in this range
      */
-    public static final SearchType RANGE = new SearchType("Range")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.index.search.SearchType#decorate(java.lang.String
-         * )
-         */
+    RANGE ("Range") {
         public String decorate(String queryWords) {
             return SEARCH_SYNTAX.decorateRange(queryWords);
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257288028421959989L;
     };
 
     /**
      * @param name
      *            The name of the BookCategory
      */
-    protected SearchType(String name) {
+    private SearchType(String name) {
         this.name = name;
     }
 
@@ -206,47 +113,18 @@
      * Lookup method to convert from a String
      */
     public static SearchType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            SearchType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (SearchType v : values()) {
+            if (v.name.equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         throw new ClassCastException("Not a valid search type");
     }
 
-    /**
-     * Lookup method to convert from an integer
+    /* (non-Javadoc)
+     * @see java.lang.Enum#toString()
      */
-    public static SearchType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /**
-     * 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;
     }
@@ -257,21 +135,4 @@
     private String name;
 
     protected static final QueryDecorator SEARCH_SYNTAX = QueryDecoratorFactory.getSearchSyntax();
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final SearchType[] VALUES = {
-            PHRASE, ALL_WORDS, ANY_WORDS, NOT_WORDS, START_WORDS, SPELL_WORDS, RANGE,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3256721767014871089L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AccuracyType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.jsword.passage;
 
-import java.io.Serializable;
-
 import org.crosswire.common.icu.NumberShaper;
 import org.crosswire.jsword.versification.BibleInfo;
 
@@ -67,29 +65,16 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class AccuracyType implements Serializable {
+public enum AccuracyType {
     /**
      * The verse was specified as book, chapter and verse. For example, Gen 1:1,
      * Jude 3 (which only has one chapter)
      */
-    public static final AccuracyType BOOK_VERSE = new AccuracyType("BOOK_VERSE")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.passage.AccuracyType#isVerse()
-         */
+    BOOK_VERSE {
         public boolean isVerse() {
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createStartVerse(java.lang
-         * .String, org.crosswire.jsword.passage.VerseRange, java.lang.String[])
-         */
         public Verse createStartVerse(String original, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException {
             int book = BibleInfo.getBookNumber(parts[0]);
             int chapter = 1;
@@ -104,47 +89,22 @@
             return new Verse(original, book, chapter, verse);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createEndVerse(java.lang
-         * .String, org.crosswire.jsword.passage.Verse, java.lang.String[])
-         */
         public Verse createEndVerse(String endVerseDesc, Verse verseBasis, String[] endParts) throws NoSuchVerseException {
             // A fully specified verse is the same regardless of whether it is a
             // start or an end to a range.
             return createStartVerse(endVerseDesc, null, endParts);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3256719589483165495L;
-    };
-
     /**
      * The passage was specified to a book and chapter (no verse). For example,
      * Gen 1
      */
-    public static final AccuracyType BOOK_CHAPTER = new AccuracyType("BOOK_CHAPTER")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.passage.AccuracyType#isChapter()
-         */
+    BOOK_CHAPTER {
         public boolean isChapter() {
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createStartVerse(java.lang
-         * .String, org.crosswire.jsword.passage.VerseRange, java.lang.String[])
-         */
         public Verse createStartVerse(String original, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException {
             int book = BibleInfo.getBookNumber(parts[0]);
             int chapter = getChapter(book, parts[1]);
@@ -152,13 +112,6 @@
             return new Verse(original, book, chapter, verse);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createEndVerse(java.lang
-         * .String, org.crosswire.jsword.passage.Verse, java.lang.String[])
-         */
         public Verse createEndVerse(String endVerseDesc, Verse verseBasis, String[] endParts) throws NoSuchVerseException {
             // Very similar to the start verse but we want the end of the
             // chapter
@@ -166,47 +119,22 @@
             // except that this gives us end at verse 1, and not the book end
             return end.getLastVerseInChapter();
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3258125864737911609L;
-    };
-
     /**
      * The passage was specified to a book only (no chapter or verse). For
      * example, Gen
      */
-    public static final AccuracyType BOOK_ONLY = new AccuracyType("BOOK_ONLY")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.passage.AccuracyType#isBook()
-         */
+    BOOK_ONLY {
         public boolean isBook() {
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createStartVerse(java.lang
-         * .String, org.crosswire.jsword.passage.VerseRange, java.lang.String[])
-         */
         public Verse createStartVerse(String original, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException {
             int book = BibleInfo.getBookNumber(parts[0]);
             return new Verse(original, book, 1, 1);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createEndVerse(java.lang
-         * .String, org.crosswire.jsword.passage.Verse, java.lang.String[])
-         */
         public Verse createEndVerse(String endVerseDesc, Verse verseBasis, String[] endParts) throws NoSuchVerseException {
             // And we end with a book, so we need to encompass the lot
             // For example "Gen 3-Exo"
@@ -215,35 +143,17 @@
             // except that this gives us end at 1:1, and not the book end
             return end.getLastVerseInBook();
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 4050486707419821620L;
-    };
-
     /**
      * The passage was specified to a chapter and verse (no book). For example,
      * 1:1
      */
-    public static final AccuracyType CHAPTER_VERSE = new AccuracyType("CHAPTER_VERSE")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.passage.AccuracyType#isVerse()
-         */
+    CHAPTER_VERSE {
         public boolean isVerse() {
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createStartVerse(java.lang
-         * .String, org.crosswire.jsword.passage.VerseRange, java.lang.String[])
-         */
         public Verse createStartVerse(String original, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException {
             if (verseRangeBasis == null) {
                 // TRANSLATOR: The user supplied a verse reference but did not give the book of the Bible.
@@ -256,13 +166,6 @@
             return new Verse(original, book, chapter, verse);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createEndVerse(java.lang
-         * .String, org.crosswire.jsword.passage.Verse, java.lang.String[])
-         */
         public Verse createEndVerse(String endVerseDesc, Verse verseBasis, String[] endParts) throws NoSuchVerseException {
             // Very similar to the start verse but use the verse as a basis
             int book = verseBasis.getBook();
@@ -270,34 +173,16 @@
             int verse = getVerse(book, chapter, endParts[1]);
             return new Verse(endVerseDesc, book, chapter, verse);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3691040958808668471L;
-    };
-
     /**
      * There was only a chapter number
      */
-    public static final AccuracyType CHAPTER_ONLY = new AccuracyType("CHAPTER_ONLY")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.passage.AccuracyType#isChapter()
-         */
+    CHAPTER_ONLY {
         public boolean isChapter() {
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createStartVerse(java.lang
-         * .String, org.crosswire.jsword.passage.VerseRange, java.lang.String[])
-         */
         public Verse createStartVerse(String original, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException {
             if (verseRangeBasis == null) {
                 // TRANSLATOR: The user supplied a verse reference but did not give the book of the Bible.
@@ -308,13 +193,6 @@
             return new Verse(original, book, chapter, 1);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createEndVerse(java.lang
-         * .String, org.crosswire.jsword.passage.Verse, java.lang.String[])
-         */
         public Verse createEndVerse(String endVerseDesc, Verse verseBasis, String[] endParts) throws NoSuchVerseException {
             // Very similar to the start verse but use the verse as a basis
             // and it gets the end of the chapter
@@ -322,34 +200,16 @@
             int chapter = getChapter(book, endParts[0]);
             return new Verse(endVerseDesc, book, chapter, 1).getLastVerseInChapter();
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3689918357520463409L;
-    };
-
     /**
      * There was only a verse number
      */
-    public static final AccuracyType VERSE_ONLY = new AccuracyType("VERSE_ONLY")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.passage.AccuracyType#isVerse()
-         */
+    VERSE_ONLY {
         public boolean isVerse() {
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createStartVerse(java.lang
-         * .String, org.crosswire.jsword.passage.VerseRange, java.lang.String[])
-         */
         public Verse createStartVerse(String original, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException {
             if (verseRangeBasis == null) {
                 // TRANSLATOR: The user supplied a verse reference but did not give the book or chapter of the Bible.
@@ -361,13 +221,6 @@
             return new Verse(original, book, chapter, verse);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.AccuracyType#createEndVerse(java.lang
-         * .String, org.crosswire.jsword.passage.Verse, java.lang.String[])
-         */
         public Verse createEndVerse(String endVerseDesc, Verse verseBasis, String[] endParts) throws NoSuchVerseException {
             // Very similar to the start verse but use the verse as a basis
             // and it gets the end of the chapter
@@ -376,21 +229,9 @@
             int verse = getVerse(book, chapter, endParts[0]);
             return new Verse(endVerseDesc, book, chapter, verse);
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3691034361722320178L;
     };
 
     /**
-     * Simple ctor
-     */
-    public AccuracyType(String name) {
-        this.name = name;
-    }
-
-    /**
      * @param original
      *            the original verse reference as a string
      * @param verseRangeBasis
@@ -480,14 +321,7 @@
      * Get an integer representation for this RestrictionType
      */
     public int toInteger() {
-        for (int i = 0; i < VALUES.length; i++) {
-            if (equals(VALUES[i])) {
-                return i;
-            }
-        }
-        // cannot get here
-        assert false;
-        return -1;
+        return ordinal();
     }
 
     /**
@@ -774,87 +608,11 @@
     }
 
     /**
-     * Lookup method to convert from a String
-     * 
-     * @param name
-     *            the name of the AccuracyType
-     * @return the AccuracyType
-     */
-    public static AccuracyType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            AccuracyType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
-            }
-        }
-        // cannot get here
-        assert false;
-        return null;
-    }
-
-    /**
-     * Lookup method to convert from an integer
-     * 
-     * @param i
-     *            the i-th AccuracyType
-     * @return the AccuracyType
-     */
-    public static AccuracyType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /**
-     * 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;
-    }
-
-    /**
      * What characters can we use to separate parts to a verse
      */
     public static final String VERSE_ALLOWED_DELIMS = " :.";
 
     /**
-     * The name of the object
-     */
-    private String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final AccuracyType[] VALUES = {
-            BOOK_CHAPTER, BOOK_VERSE, BOOK_ONLY, CHAPTER_VERSE, VERSE_ONLY,
-    };
-
-    /**
      * Characters that are used to indicate end of verse/chapter, part 1
      */
     public static final String VERSE_END_MARK1 = "$";
@@ -863,9 +621,4 @@
      * Characters that are used to indicate end of verse/chapter, part 2
      */
     public static final String VERSE_END_MARK2 = "ff";
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3414238884915821959L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageListType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageListType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageListType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.jsword.passage;
 
-import java.io.Serializable;
-
 /**
  * Types of Passage Lists.
  * 
@@ -31,12 +29,11 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class PassageListType implements Serializable {
+public enum PassageListType {
     /**
      * Passage to be interpreted as a list of verses.
      */
-    public static final PassageListType VERSES = new PassageListType("VERSES")
-    {
+    VERSES {
         public Object getElementAt(Passage ref, int index, RestrictionType restrict) {
             if (ref == null) {
                 return null;
@@ -50,18 +47,12 @@
             }
             return ref.countVerses();
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 4050199730607109682L;
-    };
-
     /**
      * Passage to be interpreted as a list of ranges.
      */
-    public static final PassageListType RANGES = new PassageListType("RANGES")
-    {
+    RANGES {
         public Object getElementAt(Passage ref, int index, RestrictionType restrict) {
             if (ref == null) {
                 return null;
@@ -75,94 +66,9 @@
             }
             return ref.countRanges(restrict);
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3834030242750083129L;
     };
 
-    /**
-     * Simple ctor
-     */
-    public PassageListType(String name) {
-        this.name = name;
-    }
-
     public abstract Object getElementAt(Passage ref, int index, RestrictionType restrict);
 
     public abstract int count(Passage ref, RestrictionType restrict);
-
-    /**
-     * Lookup method to convert from a String
-     */
-    public static PassageListType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            PassageListType 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 PassageListType fromInteger(int i) {
-        return VALUES[i];
-    }
-
-    /**
-     * 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 PassageListType[] VALUES = {
-            VERSES, RANGES,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 1019448872358899522L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,7 +21,6 @@
  */
 package org.crosswire.jsword.passage;
 
-import java.io.Serializable;
 
 /**
  * Types of Passage optimizations.
@@ -30,19 +29,11 @@
  *      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 {
+public enum PassageType {
     /**
      * Optimize the Passage for speed
      */
-    public static final PassageType SPEED = new PassageType("SPEED")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.PassageType#createPassage(java.lang.
-         * String)
-         */
+    SPEED {
         public Passage createPassage(String passage) throws NoSuchVerseException {
             if (passage == null || passage.length() == 0) {
                 return createEmptyPassage();
@@ -50,33 +41,15 @@
             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-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.PassageType#createPassage(java.lang.
-         * String)
-         */
+    WRITE_SPEED {
         public Passage createPassage(String passage) throws NoSuchVerseException {
             if (passage == null || passage.length() == 0) {
                 return createEmptyPassage();
@@ -84,33 +57,15 @@
             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-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.PassageType#createPassage(java.lang.
-         * String)
-         */
+    SIZE {
         public Passage createPassage(String passage) throws NoSuchVerseException {
             if (passage == null || passage.length() == 0) {
                 return createEmptyPassage();
@@ -118,11 +73,6 @@
             return new DistinctPassage(passage);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.crosswire.jsword.passage.PassageType#createEmptyPassage()
-         */
         public Passage createEmptyPassage() {
             return new DistinctPassage();
         }
@@ -131,20 +81,12 @@
          * Serialization ID
          */
         private static final long serialVersionUID = -1959355535575121168L;
-    };
+    },
 
     /**
      * Optimize the Passage for a mix
      */
-    public static final PassageType MIX = new PassageType("MIX")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.PassageType#createPassage(java.lang.
-         * String)
-         */
+    MIX {
         public Passage createPassage(String passage) throws NoSuchVerseException {
             if (passage == null || passage.length() == 0) {
                 return createEmptyPassage();
@@ -152,33 +94,15 @@
             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-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.PassageType#createPassage(java.lang.
-         * String)
-         */
+    TALLY {
         public Passage createPassage(String passage) throws NoSuchVerseException {
             if (passage == null || passage.length() == 0) {
                 return createEmptyPassage();
@@ -186,29 +110,12 @@
             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
@@ -229,12 +136,12 @@
      * 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;
+        for (PassageType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
@@ -244,76 +151,20 @@
      * 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;
+        for (PassageType v : values()) {
+            if (v.ordinal() == i) {
+                return v;
+            }
         }
-        return VALUES[i];
+
+        // on error return SPEED
+        return SPEED;
     }
 
     /**
      * 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
+        return type.ordinal();
     }
-
-    /**
-     * 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,
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 1678142015407980515L;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2010-12-06 21:42:24 UTC (rev 2046)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RestrictionType.java	2010-12-07 03:49:58 UTC (rev 2047)
@@ -21,8 +21,6 @@
  */
 package org.crosswire.jsword.passage;
 
-import java.io.Serializable;
-
 import org.crosswire.jsword.versification.BibleInfo;
 
 /**
@@ -33,56 +31,27 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public abstract class RestrictionType implements Serializable {
+public enum RestrictionType {
     /**
      * There is no restriction on blurring.
      */
-    public static final RestrictionType NONE = new RestrictionType("NONE")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#isSameScope(org.crosswire
-         * .jsword.passage.Verse, org.crosswire.jsword.passage.Verse)
-         */
+    NONE {
         public boolean isSameScope(Verse start, Verse end) {
             return true;
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword
-         * .passage.VerseRange, int, int)
-         */
         public VerseRange blur(VerseRange range, int blurDown, int blurUp) {
             Verse start = range.getStart().subtract(blurDown);
             Verse end = range.getEnd().add(blurUp);
             return new VerseRange(start, end);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword
-         * .passage.Verse, int, int)
-         */
         public VerseRange blur(Verse verse, int blurDown, int blurUp) {
             Verse start = verse.subtract(blurDown);
             Verse end = verse.add(blurUp);
             return new VerseRange(start, end);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword
-         * .passage.Verse, int, int)
-         */
         public VerseRange toRange(Verse verse, int count) {
             Verse end = verse;
             if (count > 1) {
@@ -90,38 +59,16 @@
             }
             return new VerseRange(verse, end);
         }
+    },
 
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3905246714754643248L;
-    };
-
     /**
      * Blurring is restricted to the chapter
      */
-    // Note: FindBugs wrongly reports an initialization circularity.
-    // Turns out that it is the exception handling that causes it.
-    public static final RestrictionType CHAPTER = new RestrictionType("CHAPTER")
-    {
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#isSameScope(org.crosswire
-         * .jsword.passage.Verse, org.crosswire.jsword.passage.Verse)
-         */
+    CHAPTER {
         public boolean isSameScope(Verse start, Verse end) {
             return start.isSameChapter(end);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword
-         * .passage.VerseRange, int, int)
-         */
         public VerseRange blur(VerseRange range, int blurDown, int blurUp) {
             try {
                 Verse start = range.getStart();
@@ -146,13 +93,6 @@
             }
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword
-         * .passage.Verse, int, int)
-         */
         public VerseRange blur(Verse verse, int blurDown, int blurUp) {
             try {
                 int verseNumber = verse.getVerse();
@@ -179,22 +119,10 @@
             }
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see
-         * org.crosswire.jsword.passage.RestrictionType#toRange(org.crosswire
-         * .jsword.passage.Verse, int)
-         */
         public VerseRange toRange(Verse verse, int count) {
             Verse end = verse.add(count - 1);
             return new VerseRange(verse, end);
         }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257284751327768626L;
     };
 
     /**
@@ -240,36 +168,22 @@
     public abstract VerseRange toRange(Verse verse, int count);
 
     /**
-     * Simple ctor
-     */
-    public RestrictionType(String name) {
-        this.name = name;
-    }
-
-    /**
      * Get an integer representation for this RestrictionType
      */
     public int toInteger() {
-        for (int i = 0; i < VALUES.length; i++) {
-            if (equals(VALUES[i])) {
-                return i;
-            }
-        }
-        // cannot get here
-        assert false;
-        return -1;
+        return ordinal();
     }
 
     /**
      * Lookup method to convert from a String
      */
     public static RestrictionType fromString(String name) {
-        for (int i = 0; i < VALUES.length; i++) {
-            RestrictionType o = VALUES[i];
-            if (o.name.equalsIgnoreCase(name)) {
-                return o;
+        for (RestrictionType v : values()) {
+            if (v.name().equalsIgnoreCase(name)) {
+                return v;
             }
         }
+
         // cannot get here
         assert false;
         return null;
@@ -279,39 +193,18 @@
      * Lookup method to convert from an integer
      */
     public static RestrictionType fromInteger(int i) {
-        return VALUES[i];
-    }
+        for (RestrictionType v : values()) {
+            if (v.ordinal() == i) {
+                return v;
+            }
+        }
 
-    /**
-     * 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);
+        // cannot get here
+        assert false;
+        return null;
     }
 
     /**
-     * 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 default Blur settings. This is used by config to set a default.
      * 
      * @param value
@@ -344,26 +237,4 @@
      * A default restriction type for blurring.
      */
     private static RestrictionType defaultBlurRestriction = RestrictionType.NONE;
-
-    /**
-     * The name of the RestrictionType
-     */
-    private String name;
-
-    // Support for serialization
-    private static int nextObj;
-    private final int obj = nextObj++;
-
-    Object readResolve() {
-        return VALUES[obj];
-    }
-
-    private static final RestrictionType[] VALUES = {
-            NONE, CHAPTER
-    };
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 5511668815596963817L;
 }


Property changes on: trunk/jsword/tools
___________________________________________________________________
Added: svn:ignore
   + ivy





More information about the jsword-svn mailing list