[jsword-svn] r1941 - trunk/jsword/src/main/java/org/crosswire/jsword/book/sword

dmsmith at crosswire.org dmsmith at crosswire.org
Mon Mar 23 05:31:38 MST 2009


Author: dmsmith
Date: 2009-03-23 05:31:37 -0700 (Mon, 23 Mar 2009)
New Revision: 1941

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
Log:
Fixed a bug in the saving of the conf, where language changed from code to localized name.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java	2009-03-23 12:01:01 UTC (rev 1940)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java	2009-03-23 12:31:37 UTC (rev 1941)
@@ -26,6 +26,7 @@
 import java.util.List;
 
 import org.crosswire.common.util.Histogram;
+import org.crosswire.common.util.Language;
 import org.crosswire.common.util.Logger;
 import org.crosswire.common.util.StringUtil;
 import org.crosswire.common.xml.XMLUtil;
@@ -389,7 +390,7 @@
             buf.append('=');
             if (allowsContinuation())
             {
-                String text = value.toString();
+                String text = getConfValue(value);
                 String [] lines = StringUtil.splitAll(text, '\n');
                 for (int i = 0; i < lines.length; i++)
                 {
@@ -403,7 +404,7 @@
             }
             else
             {
-                buf.append(value.toString());
+                buf.append(getConfValue(value));
                 buf.append('\n');
             }
         }
@@ -437,10 +438,9 @@
                 Iterator iter = values.iterator();
                 while (iter.hasNext())
                 {
-                    String text = (String) iter.next();
                     buf.append(getName());
                     buf.append('=');
-                    buf.append(text);
+                    buf.append(getConfValue(iter.next()));
                     buf.append('\n');
                 }
             }
@@ -448,6 +448,24 @@
         return buf.toString();
     }
 
+    /**
+     * The conf value is the internal representation of the string. For Language, this is the code, not the localized name. Add others as needed.
+     * @param aValue either value or values[i]
+     * @return the conf value.
+     */
+    private String getConfValue(Object aValue)
+    {
+        if (aValue != null)
+        {
+            if (aValue instanceof Language)
+            {
+                return ((Language) value).getCode();
+            }
+            return aValue.toString();
+        }
+        return null;
+    }
+
     private String handleRTF(String aValue)
     {
         String copy = aValue;




More information about the jsword-svn mailing list