[jsword-svn] r1657 - in trunk/jsword/src/main/java/org/crosswire/jsword/book: . basic sword

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Tue Aug 7 11:55:15 MST 2007


Author: dmsmith
Date: 2007-08-07 11:55:15 -0700 (Tue, 07 Aug 2007)
New Revision: 1657

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java
Log:
Finished internationalizing BookCategory

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java	2007-08-07 18:08:28 UTC (rev 1656)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookCategory.java	2007-08-07 18:55:15 UTC (rev 1657)
@@ -31,54 +31,62 @@
  * @author Joe Walker [joe at eireneh dot com]
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
+/**
+ *
+ *
+ * @see gnu.lgpl.License for license details.<br>
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
 public final class BookCategory implements Serializable, Comparable
 {
     /**
      * Books that are Bibles
      */
-    public static final BookCategory BIBLE = new BookCategory(Msg.BIBLE);
+    public static final BookCategory BIBLE = new BookCategory("Bible", Msg.BIBLE); //$NON-NLS-1$
 
     /**
      * Books that are Dictionaries
      */
-    public static final BookCategory DICTIONARY = new BookCategory(Msg.DICTIONARY);
+    public static final BookCategory DICTIONARY = new BookCategory("Dictionary", Msg.DICTIONARY); //$NON-NLS-1$
 
     /**
      * Books that are Commentaries
      */
-    public static final BookCategory COMMENTARY = new BookCategory(Msg.COMMENTARY);
+    public static final BookCategory COMMENTARY = new BookCategory("Commentary", Msg.COMMENTARY); //$NON-NLS-1$
 
     /**
      * Books that are indexed by day. AKA, Daily Devotions
      */
-    public static final BookCategory DAILY_DEVOTIONS = new BookCategory(Msg.READINGS);
+    public static final BookCategory DAILY_DEVOTIONS = new BookCategory("Daily Devotional", Msg.READINGS); //$NON-NLS-1$
 
     /**
      * Books that map words from one language to another.
      */
-    public static final BookCategory GLOSSARY = new BookCategory(Msg.GLOSSARIES);
+    public static final BookCategory GLOSSARY = new BookCategory("Glossaries", Msg.GLOSSARIES); //$NON-NLS-1$
 
     /**
      * Books that are questionable.
      */
-    public static final BookCategory QUESTIONABLE = new BookCategory(Msg.UNORTHODOX);
+    public static final BookCategory QUESTIONABLE = new BookCategory("Cults / Unorthodox / Questionable Material", Msg.UNORTHODOX); //$NON-NLS-1$
 
     /**
      * Books that are not any of the above
      */
-    public static final BookCategory GENERAL_BOOK = new BookCategory(Msg.GENERAL);
+    public static final BookCategory GENERAL_BOOK = new BookCategory("General Books", Msg.GENERAL); //$NON-NLS-1$
 
     /**
      * Books that are not any of the above
      */
-    public static final BookCategory OTHER = new BookCategory(Msg.OTHER);
+    public static final BookCategory OTHER = new BookCategory("Other", Msg.OTHER); //$NON-NLS-1$
 
     /**
      * @param name The name of the BookCategory
      */
-    private BookCategory(Msg name)
+    private BookCategory(String name, Msg externalName)
     {
         this.name = name;
+        this.externalName = externalName;
     }
 
     /**
@@ -89,7 +97,7 @@
         for (int i = 0; i < VALUES.length; i++)
         {
             BookCategory o = VALUES[i];
-            if (o.name.toString().equalsIgnoreCase(name))
+            if (o.name.equalsIgnoreCase(name))
             {
                 return o;
             }
@@ -98,6 +106,22 @@
     }
 
     /**
+     * Lookup method to convert from a String
+     */
+    public static BookCategory fromExternalString(String name)
+    {
+        for (int i = 0; i < VALUES.length; i++)
+        {
+            BookCategory o = VALUES[i];
+            if (o.externalName.toString().equalsIgnoreCase(name))
+            {
+                return o;
+            }
+        }
+        return OTHER;
+    }
+
+    /**
      * Lookup method to convert from an integer
      */
     public static BookCategory fromInteger(int i)
@@ -111,7 +135,7 @@
     public int compareTo(Object o)
     {
         BookCategory that = (BookCategory) o;
-        return this.name.toString().compareTo(that.name.toString());
+        return this.name.compareTo(that.name);
     }
 
     /* (non-Javadoc)
@@ -130,18 +154,27 @@
         return super.hashCode();
     }
 
+    /**
+     * @return the internal name.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */
     public String toString()
     {
-        return name.toString();
+        return externalName.toString();
     }
 
     /**
-     * The name of the BookCategory
+     * The names of the BookCategory
      */
-    private Msg name;
+    private String name;
+    private Msg externalName;
 
     // Support for serialization
     private static int nextObj;

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java	2007-08-07 18:08:28 UTC (rev 1656)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java	2007-08-07 18:55:15 UTC (rev 1657)
@@ -183,7 +183,7 @@
         }
         type = t;
 
-        putProperty(KEY_CATEGORY, type.toString());
+        putProperty(KEY_CATEGORY, type);
     }
 
     /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java	2007-08-07 18:08:28 UTC (rev 1656)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java	2007-08-07 18:55:15 UTC (rev 1657)
@@ -704,7 +704,7 @@
     {
         // The book type represents the underlying category of book.
         // Fine tune it here.
-        BookCategory focusedCategory = BookCategory.fromString(getValue(ConfigEntryType.CATEGORY).toString());
+        BookCategory focusedCategory = (BookCategory) getValue(ConfigEntryType.CATEGORY);
         questionable = focusedCategory == BookCategory.QUESTIONABLE;
 
         // From the config map, extract the important bean properties
@@ -738,7 +738,7 @@
             focusedCategory = getBookType().getBookCategory();
         }
 
-        add(ConfigEntryType.CATEGORY, focusedCategory.toString());
+        add(ConfigEntryType.CATEGORY, focusedCategory.getName());
     }
 
     private void adjustName()

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java	2007-08-07 18:08:28 UTC (rev 1656)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java	2007-08-07 18:55:15 UTC (rev 1657)
@@ -29,6 +29,7 @@
 import java.util.regex.Pattern;
 
 import org.crosswire.common.util.Language;
+import org.crosswire.jsword.book.BookCategory;
 
 
 /**
@@ -240,9 +241,17 @@
          */
         public Object getDefault()
         {
-            return "Other"; //$NON-NLS-1$
+            return BookCategory.OTHER;
         }
 
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            return BookCategory.fromString(input);
+        }
+
         /**
          * The set of choices.
          */

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java	2007-08-07 18:08:28 UTC (rev 1656)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java	2007-08-07 18:55:15 UTC (rev 1657)
@@ -222,7 +222,7 @@
     {
         if (type == null)
         {
-            type = BookCategory.fromString((String) getProperty(ConfigEntryType.CATEGORY));
+            type = (BookCategory) getProperty(ConfigEntryType.CATEGORY);
             if (type == BookCategory.OTHER)
             {
                 type = getBookType().getBookCategory();




More information about the jsword-svn mailing list