[jsword-svn] r1605 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic common/src/main/java/org/crosswire/common/util common-swing/src/main/java/org/crosswire/common/swing jsword/src/main/java/org/crosswire/jsword/book jsword/src/main/java/org/crosswire/jsword/book/basic jsword/src/main/java/org/crosswire/jsword/book/readings jsword/src/main/java/org/crosswire/jsword/book/sword jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Fri Aug 3 14:34:47 MST 2007


Author: dmsmith
Date: 2007-08-03 14:34:46 -0700 (Fri, 03 Aug 2007)
New Revision: 1605

Added:
   trunk/common/src/main/java/org/crosswire/common/util/Language.java
Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.properties
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/Msg.properties
   trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.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
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java
Log:
Initial work for per Language and per module font settings.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -50,7 +50,7 @@
             Iterator iter = group.iterator();
             while (iter.hasNext())
             {
-                String value = (String) iter.next();
+                Object value = iter.next();
                 BookSet subBooks = books.filter(key, value);
                 add(new BookNode(value, subBooks, level + 1, grouping));
             }

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -49,6 +49,7 @@
     static final Msg UNLOCK_BOOK = new Msg("SitePane.UnlockBook"); //$NON-NLS-1$
     static final Msg CONFIRM_UNINSTALL_TITLE = new Msg("SitePane.ConfirmUninstallTitle"); //$NON-NLS-1$
     static final Msg CONFIRM_UNINSTALL_BOOK = new Msg("SitePane.ConfirmUninstallBook"); //$NON-NLS-1$
+    static final Msg FONT_CHOOSER = new Msg("SitePane.FontChooser"); //$NON-NLS-1$
 
     static final Msg EDIT_SITE_TITLE = new Msg("EditSitePane.EditSitesTitle"); //$NON-NLS-1$
     static final Msg MISSING_SITE = new Msg("EditSitePane.MissingSite"); //$NON-NLS-1$

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties	2007-08-03 21:34:46 UTC (rev 1605)
@@ -26,6 +26,7 @@
 SitePane.UnlockBook=<html>Please enter the unlock key for:<br> {0}?
 SitePane.ConfirmUninstallTitle=Remove Index for Book
 SitePane.ConfirmUninstallBook=Are you sure you want to remove the index for {0}?
+SitePane.FontChooser=Choose Font
 
 EditSitePane.EditSitesTitle=Edit Update Sites
 EditSitePane.MissingSite=Missing site name

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -23,6 +23,8 @@
 
 import java.awt.BorderLayout;
 import java.awt.Component;
+import java.awt.Font;
+import java.awt.GridLayout;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 
@@ -48,6 +50,8 @@
 import org.crosswire.common.swing.ActionFactory;
 import org.crosswire.common.swing.CWScrollPane;
 import org.crosswire.common.swing.FixedSplitPane;
+import org.crosswire.common.swing.FontChooser;
+import org.crosswire.common.util.Language;
 import org.crosswire.common.util.Reporter;
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.BookCategory;
@@ -242,20 +246,17 @@
     {
         // return new BooksTreeModel(books);
         BookSet bmds = new BookSet(books.getBooks());
-        TreeNode bookRoot = new BookNode("root", bmds, 0, new Object[] {BookMetaData.KEY_CATEGORY, BookMetaData.KEY_LANGUAGE}); //$NON-NLS-1$
+        TreeNode bookRoot = new BookNode("root", bmds, 0, new Object[] {BookMetaData.KEY_CATEGORY, BookMetaData.KEY_XML_LANG}); //$NON-NLS-1$
         return new DefaultTreeModel(bookRoot);
     }
 
-    // provide for backward compatibility
     private Book getBook(Object anObj)
     {
         Object obj = anObj;
-        // new way
         if (obj instanceof DefaultMutableTreeNode)
         {
             obj = ((DefaultMutableTreeNode) obj).getUserObject();
         }
-        // Old way
         if (obj instanceof Book)
         {
             return (Book) obj;
@@ -263,6 +264,20 @@
         return null;
     }
 
+    private Language getLanguage(Object anObj)
+    {
+        Object obj = anObj;
+        if (obj instanceof DefaultMutableTreeNode)
+        {
+            obj = ((DefaultMutableTreeNode) obj).getUserObject();
+        }
+        if (obj instanceof Language)
+        {
+            return (Language) obj;
+        }
+        return null;
+    }
+
     /**
      *
      */
@@ -271,6 +286,7 @@
         JPanel panel = new JPanel();
         if (installer != null)
         {
+            panel.setLayout(new GridLayout(1, 2, 3, 3));
             panel.add(new JButton(actions.getAction(INSTALL)));
             // LATER(DMS): Put back when this works
             //panel.add(new JButton(actions.getAction(INSTALL_SEARCH)));
@@ -278,9 +294,11 @@
         }
         else
         {
+            panel.setLayout(new GridLayout(2, 2, 3, 3));
             panel.add(new JButton(actions.getAction(DELETE)));
+            panel.add(new JButton(actions.getAction(UNINDEX)));
+            panel.add(new JButton(actions.getAction(CHOOSE_FONT)));
             panel.add(new JButton(actions.getAction(UNLOCK)));
-            panel.add(new JButton(actions.getAction(UNINDEX)));
         }
         return panel;
     }
@@ -469,38 +487,47 @@
     }
 
     /**
+     * Get a font for the current selection
+     */
+    public void doChooseFont()
+    {
+        TreePath path = treAvailable.getSelectionPath();
+        if (path == null)
+        {
+            return;
+        }
+
+        Object last = path.getLastPathComponent();
+        //Book book = getBook(last);
+
+        Font picked = FontChooser.showDialog(this, Msg.FONT_CHOOSER.toString(), null);
+        
+    }
+
+    /**
      * Something has been (un)selected in the tree
      */
     protected void selected()
     {
         TreePath path = treAvailable.getSelectionPath();
 
-        boolean bookSelected = false;
         Book book = null;
+        Language lang = null;
         if (path != null)
         {
             Object last = path.getLastPathComponent();
             book = getBook(last);
-            if (book != null)
-            {
-                bookSelected = true;
-            }
+            lang = getLanguage(last);
         }
 
         display.setBook(book);
 
-        if (book == null)
-        {
-            return;
-        }
-
-        boolean canInstall = bookSelected && book.isSupported();
-        IndexManager imanager = IndexManagerFactory.getIndexManager();
-        actions.getAction(DELETE).setEnabled(bookSelected && book.getDriver().isDeletable(book));
-        actions.getAction(UNLOCK).setEnabled(bookSelected && book.isEnciphered());
-        actions.getAction(UNINDEX).setEnabled(bookSelected && imanager.isIndexed(book));
-        actions.getAction(INSTALL).setEnabled(canInstall);
-        actions.getAction(INSTALL_SEARCH).setEnabled(canInstall && book.getBookCategory() == BookCategory.BIBLE);
+        actions.getAction(DELETE).setEnabled(book != null && book.getDriver().isDeletable(book));
+        actions.getAction(UNLOCK).setEnabled(book != null && book.isEnciphered());
+        actions.getAction(UNINDEX).setEnabled(book != null && IndexManagerFactory.getIndexManager().isIndexed(book));
+        actions.getAction(INSTALL).setEnabled(book != null && book.isSupported());
+        actions.getAction(INSTALL_SEARCH).setEnabled(book != null && book.isSupported() && book.getBookCategory() == BookCategory.BIBLE);
+        actions.getAction(CHOOSE_FONT).setEnabled(book != null || lang != null);
     }
 
     public void setTreeModel(BookList books)
@@ -509,7 +536,7 @@
     }
 
     /**
-     * When new books are added we need to relfect the change in this tree.
+     * When new books are added we need to reflect the change in this tree.
      */
     final class CustomBooksListener implements BooksListener
     {
@@ -555,6 +582,7 @@
     private static final String INSTALL_SEARCH = "InstallSearch"; //$NON-NLS-1$
     private static final String DELETE = "Delete"; //$NON-NLS-1$
     private static final String UNLOCK = "Unlock"; //$NON-NLS-1$
+    private static final String CHOOSE_FONT = "ChooseFont"; //$NON-NLS-1$
     private static final String UNINDEX = "Unindex"; //$NON-NLS-1$
 
     /**

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.properties
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.properties	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.properties	2007-08-03 21:34:46 UTC (rev 1605)
@@ -15,7 +15,7 @@
 AvailableBooksLabel.LongDescription=Show books that are available.
 AvailableBooksLabel.SmallIcon=
 AvailableBooksLabel.LargeIcon=
-AvailableBooksLabel.MnemonicKey=B
+AvailableBooksLabel.MnemonicKey=A
 AvailableBooksLabel.AcceleratorKey=
 AvailableBooksLabel.AcceleratorKey.Modifiers=
 
@@ -45,8 +45,14 @@
 Unlock.Name=Unlock
 Unlock.ShortDescription=Unlock a book.
 Unlock.LongDescription=Unlock the selected book
-Unlock.MnemonicKey=U
+Unlock.MnemonicKey=L
 
+ChooseFont.Enabled=false
+ChooseFont.Name=Font...
+ChooseFont.ShortDescription=Choose Font.
+ChooseFont.LongDescription=Choose a Font for the Language or Book
+ChooseFont.MnemonicKey=F
+
 Install.Enabled=false
 Install.Name=Install
 Install.ShortDescription=Install a book.
@@ -65,6 +71,6 @@
 Refresh.LongDescription=Download a current listing of books.
 Refresh.SmallIcon=
 Refresh.LargeIcon=
-Refresh.MnemonicKey=R
+Refresh.MnemonicKey=U
 Refresh.AcceleratorKey=
 Refresh.AcceleratorKey.Modifiers=

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -49,7 +49,6 @@
 import org.crosswire.common.swing.GuiUtil;
 import org.crosswire.common.util.NetUtil;
 import org.crosswire.common.util.Reporter;
-import org.crosswire.common.util.StringUtil;
 import org.crosswire.common.xml.Converter;
 import org.crosswire.common.xml.FormatType;
 import org.crosswire.common.xml.PrettySerializingContentHandler;
@@ -96,7 +95,7 @@
 
             BookMetaData bmd = book.getBookMetaData();
 
-            String fontName = bmd.getProperty(BookMetaData.KEY_FONT);
+            String fontName = (String) bmd.getProperty(BookMetaData.KEY_FONT);
             String fontSpec = XSLTProperty.FONT.getStringState();
             if (fontName != null)
             {

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -152,7 +152,7 @@
         boolean direction = bmd.isLeftToRight();
         txtView.applyComponentOrientation(direction ? ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT);
 
-        String fontName = bmd.getProperty(BookMetaData.KEY_FONT);
+        String fontName = (String) bmd.getProperty(BookMetaData.KEY_FONT);
         // normalize to a consistent way
         String fontSpec = XSLTProperty.FONT.getStringState();
         if (fontName != null)

Added: trunk/common/src/main/java/org/crosswire/common/util/Language.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/Language.java	                        (rev 0)
+++ trunk/common/src/main/java/org/crosswire/common/util/Language.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -0,0 +1,128 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2007
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: Languages.java 1462 2007-07-02 02:32:23Z dmsmith $
+ */
+package org.crosswire.common.util;
+
+/**
+ * A single language, paring an ISO-639 code to a localized representation of the language.
+ *
+ * @see gnu.lgpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class Language implements Comparable
+{
+    /**
+     * A single language defined by an ISO-639 code.
+     * If the code is null or empty then it is considered to be DEFAULT_LANG_CODE (that is, English).
+     * 
+     * @param iso639Code the particular language
+     */
+    public Language(String iso639Code)
+    {
+        this.code = iso639Code;
+        if (iso639Code == null || iso639Code.length() == 0)
+        {
+            this.code = Languages.DEFAULT_LANG_CODE;
+        }
+    }
+    /**
+     * Determine whether this language is valid.
+     * The code is valid if it is in iso639.properties.
+     *
+     * @return true if the language is valid.
+     */
+    public boolean isValidLanguage()
+    {
+        return Languages.isValidLanguage(code);
+    }
+
+    /**
+     * Get the language code.
+     *
+     * @return the code for the language
+     */
+    public String getCode()
+    {
+        return code;
+    }
+
+    /**
+     * Get the language name.
+     *
+     * @return the name of the language
+     */
+    public String getName()
+    {
+        if (name == null)
+        {
+            name = Languages.getLanguage(code);
+        }
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        return code.hashCode();
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object obj)
+    {
+        if (this == obj)
+        {
+            return true;
+        }
+
+        if (obj == null || getClass() != obj.getClass())
+        {
+            return false;
+        }
+
+        final Language other = (Language) obj;
+
+        return code.equals(other.code);
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return getName();
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Comparable#compareTo(java.lang.Object)
+     */
+    public int compareTo(Object o)
+    {
+        return getName().compareTo(o.toString());
+    }
+
+    private String code;
+    private String name;
+}

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -111,15 +111,11 @@
         Component root = SwingUtilities.getRoot(parent);
         final FontChooser fontc = new FontChooser();
 
-        // JDK14: For some reason we can't do this in the version of Swing that we are on
-        // it is only available in the JDK1.2.2 implementation
-        // fontc.dialog = (root instanceof JFrame)
-        //              ? new JDialog((JFrame) root, title, true)
-        //              : new JDialog((JDialog) root, title, true);
-        fontc.dialog = new JDialog((JFrame) root, title, true);
+        fontc.dialog = (root instanceof JFrame)
+                      ? new JDialog((JFrame) root, title, true)
+                      : new JDialog((JDialog) root, title, true);
 
-        // Not sure if this is the right thing to do?
-        fontc.name.setSelectedItem(initial);
+        fontc.name.setSelectedItem(initial != null ? initial : DEFAULT_FONT.getFont());
 
         buttons.setLayout(new FlowLayout());
         buttons.add(ok);
@@ -311,16 +307,17 @@
         /* @Override */
         public Component getListCellRendererComponent(JList listbox, Object value, int index, boolean selected, boolean focus)
         {
+            Font defaultFont = DEFAULT_FONT.getFont();
             if (value == null)
             {
                 setText("<null>"); //$NON-NLS-1$
-                setFont(DEFAULT_FONT.getFont());
+                setFont(defaultFont);
             }
             else
             {
                 Font afont = (Font) value;
                 setText(afont.getFamily());
-                setFont(DEFAULT_FONT.getFont()); // afont); // Some fonts cannot display their own name.
+                setFont(defaultFont); // afont); // Some fonts cannot display their own name.
             }
 
             return this;

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/Msg.properties
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/Msg.properties	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/Msg.properties	2007-08-03 21:34:46 UTC (rev 1605)
@@ -5,7 +5,7 @@
 # The MessageName should be mixed case, with a leading capital.
 # It should have no spaces or other punctuation (e.g. _, -, ', ...)
 
-ExceptionPane.ErrorOccurred=An error has occured:
+ExceptionPane.ErrorOccurred=An error has occurred:
 ExceptionPane.OK=OK
 ExceptionPane.Details=Details
 ExceptionPane.NoFile=No File
@@ -16,7 +16,7 @@
 ExceptionPane.SourceFound=Error on line {0} in file {1}
 ExceptionPane.SourceAttempt=Tried: {0}\n
 FontChooser.Cancel=Cancel
-FontChooser.Select Font=Select Font
+FontChooser.SelectFont=Select Font
 FontChooser.Bold=Bold
 FontChooser.Italic=Italic
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -25,6 +25,7 @@
 import java.util.Map;
 
 import org.crosswire.common.activate.Activatable;
+import org.crosswire.common.util.Language;
 import org.crosswire.jsword.index.IndexStatus;
 import org.crosswire.jsword.index.IndexStatusListener;
 import org.crosswire.jsword.index.search.SearchRequest;
@@ -57,7 +58,7 @@
     /**
      * Return an iterator that returns each key's OSIS in turn.
      *
-     * $param key the Items to locate
+     * @param key the Items to locate
      * @param allowEmpty indicates whether empty keys should be present.
      */
     Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException;
@@ -157,10 +158,10 @@
     BookDriver getDriver();
 
     /**
-     * The language of the book is the common name for the iso639 code.
+     * The language of the book.
      * @return the common name for the language
      */
-    String getLanguage();
+    Language getLanguage();
 
     /**
      * The initials of this book - how people familiar with this book will know
@@ -254,7 +255,7 @@
     /**
      * Return the orientation of the language of the Book. If a book contains more than one language,
      * it refers to the dominate language of the book. This will be used to present
-     * Arabic and Hebrew in their propper orientation.
+     * Arabic and Hebrew in their proper orientation.
      * @return true if the orientation for the dominate language is LeftToRight.
      */
     boolean isLeftToRight();
@@ -275,13 +276,13 @@
      * @param key the key of the property.
      * @return the value of the property
      */
-    String getProperty(String key);
+    Object getProperty(String key);
 
     /**
      * @param key the key of the property.
      * @param value the value of the property
       */
-    void putProperty(String key, String value);
+    void putProperty(String key, Object value);
 
     /**
      * Has anyone generated a search index for this Book?

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -26,6 +26,7 @@
 
 import org.crosswire.common.diff.Diff;
 import org.crosswire.common.diff.DiffCleanup;
+import org.crosswire.common.util.Language;
 import org.crosswire.common.xml.JDOMSAXEventProvider;
 import org.crosswire.common.xml.SAXEventProvider;
 import org.crosswire.jsword.passage.Key;
@@ -210,14 +211,16 @@
                         buf.append(book.getInitials());
 
                         cell.addContent(OSISUtil.factory().createText(buf.toString()));
-                        cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, prevBook.getProperty(BookMetaData.KEY_XML_LANG), Namespace.XML_NAMESPACE);
+                        Language prevLang = (Language) book.getProperty(BookMetaData.KEY_XML_LANG);
+                        cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, prevLang.getCode(), Namespace.XML_NAMESPACE);
                         row.addContent(cell);
                         cell = OSISUtil.factory().createHeaderCell();
                     }
                 }
 
                 cell.addContent(OSISUtil.factory().createText(book.getInitials()));
-                cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, book.getProperty(BookMetaData.KEY_XML_LANG), Namespace.XML_NAMESPACE);
+                Language lang = (Language) book.getProperty(BookMetaData.KEY_XML_LANG);
+                cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, lang.getCode(), Namespace.XML_NAMESPACE);
                 row.addContent(cell);
 
                 iters[i] = book.getOsisIterator(key, true);

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -24,6 +24,7 @@
 import java.net.URI;
 import java.util.Map;
 
+import org.crosswire.common.util.Language;
 import org.crosswire.jsword.index.IndexStatus;
 import org.jdom.Document;
 
@@ -71,10 +72,10 @@
     BookDriver getDriver();
 
     /**
-     * The language of the book is the common name for the iso639 code.
-     * @return the common name for the language
+     * The language of the book.
+     * @return the book's language
      */
-    String getLanguage();
+    Language getLanguage();
 
     /**
      * The initials of this book - how people familiar with this book will know
@@ -208,13 +209,13 @@
      * @param key the key of the property.
      * @return the value of the property
      */
-    String getProperty(String key);
+    Object getProperty(String key);
 
     /**
      * @param key the key of the property to set
      * @param value the value of the property
      */
-    void putProperty(String key, String value);
+    void putProperty(String key, Object value);
 
     /**
      * Has anyone generated a search index for this Book?
@@ -255,17 +256,12 @@
     String KEY_NAME = "Description"; //$NON-NLS-1$
 
     /**
-     * The key for the name in the properties map
+     * The key for the language in the properties map
      */
-    String KEY_LANGUAGE = "Language"; //$NON-NLS-1$
-
-    /**
-     * The key for the name in the properties map
-     */
     String KEY_XML_LANG = "Lang"; //$NON-NLS-1$
 
     /**
-     * The key for the name in the properties map
+     * The key for the font in the properties map
      */
     String KEY_FONT = "Font"; //$NON-NLS-1$
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -43,7 +43,7 @@
 {
     public BookSet()
     {
-     }
+    }
 
     public BookSet(Collection books)
     {
@@ -86,14 +86,16 @@
         while (iter.hasNext())
         {
             Book book = (Book) iter.next();
-            String property = book.getProperty(key);
-            String propertyValue = property == null ? Msg.BOOK_METADATA_SET_OTHER.toString() : property;
-            results.add(propertyValue);
+            Object property = book.getProperty(key);
+            if (property != null)
+            {
+                results.add(property);
+            }
         }
         return results;
     }
 
-    public BookSet filter(String key, String value)
+    public BookSet filter(String key, Object value)
     {
         return filter(new GroupFilter(key, value));
     }
@@ -187,7 +189,7 @@
      */
     private static final class GroupFilter implements Filter
     {
-        public GroupFilter(String aKey, String aValue)
+        public GroupFilter(String aKey, Object aValue)
         {
             key = aKey;
             value = aValue;
@@ -196,11 +198,11 @@
         public boolean test(Object obj)
         {
             Book book = (Book) obj;
-            String property = book.getProperty(key);
+            Object property = book.getProperty(key);
             return property != null && property.equals(value);
         }
         private String key;
-        private String value;
+        private Object value;
     }
 
     /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -26,6 +26,7 @@
 import javax.swing.event.EventListenerList;
 
 import org.crosswire.common.activate.Lock;
+import org.crosswire.common.util.Language;
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.BookCategory;
 import org.crosswire.jsword.book.BookDriver;
@@ -205,7 +206,7 @@
     /* (non-Javadoc)
      * @see org.crosswire.jsword.book.BookMetaData#getLanguage()
      */
-    public String getLanguage()
+    public Language getLanguage()
     {
         return bmd.getLanguage();
     }
@@ -237,7 +238,7 @@
     /* (non-Javadoc)
      * @see org.crosswire.jsword.book.Book#getProperty(java.lang.String)
      */
-    public String getProperty(String key)
+    public Object getProperty(String key)
     {
         return bmd.getProperty(key);
     }
@@ -245,7 +246,7 @@
     /* (non-Javadoc)
      * @see org.crosswire.jsword.book.Book#putProperty(java.lang.String, java.lang.String)
      */
-    public void putProperty(String key, String value)
+    public void putProperty(String key, Object value)
     {
         bmd.putProperty(key, value);
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -27,6 +27,7 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import org.crosswire.common.util.Language;
 import org.crosswire.jsword.book.BookDriver;
 import org.crosswire.jsword.book.BookMetaData;
 import org.crosswire.jsword.book.FeatureType;
@@ -34,7 +35,7 @@
 import org.jdom.Document;
 
 /**
- * An implementaion of the Propery Change methods from BookMetaData.
+ * An implementation of the Property Change methods from BookMetaData.
  *
  * @see gnu.lgpl.License for license details.
  *      The copyright to this program is held by it's authors.
@@ -130,11 +131,19 @@
     /* (non-Javadoc)
      * @see org.crosswire.jsword.book.BookMetaData#getLanguage()
      */
-    public String getLanguage()
+    public Language getLanguage()
     {
-        return getProperty(KEY_LANGUAGE);
+        return lang;
     }
 
+    /**
+     * @param language The language to set.
+     */
+    public void setLanguage(Language language)
+    {
+        lang = language;
+    }
+
     /* (non-Javadoc)
      * @see org.crosswire.jsword.book.BookMetaData#getLibrary()
      */
@@ -143,7 +152,7 @@
         URI uri = null;
         try
         {
-            String loc = getProperty(KEY_LIBRARY_URI);
+            String loc = (String) getProperty(KEY_LIBRARY_URI);
             if (loc != null)
             {
                 uri = new URI(loc);
@@ -180,7 +189,7 @@
         URI uri = null;
         try
         {
-            String loc = getProperty(KEY_LOCATION_URI);
+            String loc = (String) getProperty(KEY_LOCATION_URI);
             if (loc != null)
             {
                 uri = new URI(loc);
@@ -212,15 +221,15 @@
     /* (non-Javadoc)
      * @see org.crosswire.jsword.book.BookMetaData#getProperty(java.lang.String)
      */
-    public String getProperty(String key)
+    public Object getProperty(String key)
     {
-        return (String) prop.get(key);
+        return prop.get(key);
     }
 
     /* (non-Javadoc)
-     * @see org.crosswire.jsword.book.BookMetaData#putProperty(java.lang.String, java.lang.String)
+     * @see org.crosswire.jsword.book.BookMetaData#putProperty(java.lang.String, java.lang.Object)
      */
-    public void putProperty(String key, String value)
+    public void putProperty(String key, Object value)
     {
         prop.put(key, value);
     }
@@ -270,7 +279,7 @@
         }
 
         // We might consider checking for equality against all BookMetaDatas?
-        // However currently we dont.
+        // However currently we don't.
 
         // Check that that is the same as this
         // Don't use instanceof since that breaks inheritance
@@ -318,6 +327,7 @@
      * The single key version of the properties
      */
     private Map prop = new LinkedHashMap();
+    private Language lang;
 
     private BookDriver driver;
     private IndexStatus indexStatus = IndexStatus.UNDONE;

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-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -25,7 +25,7 @@
 import java.util.Locale;
 import java.util.Map;
 
-import org.crosswire.common.util.Languages;
+import org.crosswire.common.util.Language;
 import org.crosswire.common.util.StringUtil;
 import org.crosswire.common.xml.XMLUtil;
 import org.crosswire.jsword.book.Book;
@@ -63,9 +63,8 @@
         setProperties(prop);
         setName((String) prop.get(BookMetaData.KEY_NAME));
         setType((String) prop.get(BookMetaData.KEY_CATEGORY));
-        String lang = (String) prop.get(BookMetaData.KEY_LANGUAGE);
-        putProperty(BookMetaData.KEY_XML_LANG, lang);
-        setLanguage(lang);
+        String lang = (String) prop.get(BookMetaData.KEY_XML_LANG);
+        setLanguage(new Language(lang));
 
         IndexManager imanager = IndexManagerFactory.getIndexManager();
         if (imanager.isIndexed(book))
@@ -87,7 +86,7 @@
         setDriver(driver);
         setName(name);
         setBookCategory(type);
-        setLanguage(null); // Default language
+        setLanguage(new Language(null)); // Default language
     }
 
     /* (non-Javadoc)
@@ -119,7 +118,7 @@
      */
     public boolean isLeftToRight()
     {
-        String lang = getProperty(BookMetaData.KEY_XML_LANG);
+        String lang = getLanguage().getName();
 
         // Java does not know that the following languages are right to left
         if ("fa".equals(lang) || "syr".equals(lang))  //$NON-NLS-1$ //$NON-NLS-2$
@@ -131,15 +130,6 @@
     }
 
     /**
-     * @param language The language to set.
-     */
-    public void setLanguage(String language)
-    {
-        putProperty(BookMetaData.KEY_XML_LANG, language);
-        putProperty(KEY_LANGUAGE, Languages.getLanguage(language));
-    }
-
-    /**
      * See note on setName() for side effect on setInitials(). If a value of
      * null is used then the initials are defaulted using the name
      * @see DefaultBookMetaData#setName(String)
@@ -221,7 +211,7 @@
         addRow(ele, "Initials", getInitials()); //$NON-NLS-1$
         addRow(ele, "Description", getName()); //$NON-NLS-1$
         addRow(ele, "Key", getBookCategory().toString()); //$NON-NLS-1$
-        addRow(ele, "Language", getLanguage()); //$NON-NLS-1$
+        addRow(ele, "Language", getLanguage().getName()); //$NON-NLS-1$
         return new Document(ele);
     }
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -32,6 +32,7 @@
 import java.util.TreeMap;
 
 import org.crosswire.common.util.CWClassLoader;
+import org.crosswire.common.util.Language;
 import org.crosswire.common.util.Logger;
 import org.crosswire.jsword.book.BookCategory;
 import org.crosswire.jsword.book.BookException;
@@ -84,7 +85,7 @@
 
         DefaultBookMetaData bmd = new DefaultBookMetaData(driver, name, type);
         bmd.setInitials(setname);
-        bmd.setLanguage(Locale.getDefault().getLanguage());
+        bmd.setLanguage(new Language(Locale.getDefault().getLanguage()));
         setBookMetaData(bmd);
 
         // Go through the current year

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -63,7 +63,7 @@
      */
     public void decipher(byte[] data)
     {
-        String cipherKeyString = getBookMetaData().getProperty(ConfigEntryType.CIPHER_KEY);
+        String cipherKeyString = (String) getBookMetaData().getProperty(ConfigEntryType.CIPHER_KEY);
         if (cipherKeyString != null)
         {
             Sapphire cipherEngine = new Sapphire(cipherKeyString.getBytes());
@@ -76,7 +76,7 @@
 
     public String getExpandedDataPath() throws BookException
     {
-        URI loc = NetUtil.lengthenURI(bmd.getLibrary(), bmd.getProperty(ConfigEntryType.DATA_PATH));
+        URI loc = NetUtil.lengthenURI(bmd.getLibrary(), (String) bmd.getProperty(ConfigEntryType.DATA_PATH));
 
         if (loc == null)
         {

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	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -70,7 +70,7 @@
 
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException
         {
-            BlockType blockType = BlockType.fromString(sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
+            BlockType blockType = BlockType.fromString((String)sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
             return new ZVerseBackend(sbmd, blockType);
         }
 
@@ -130,7 +130,7 @@
 
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException
         {
-            BlockType blockType = BlockType.fromString(sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
+            BlockType blockType = BlockType.fromString((String)sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
             return new ZVerseBackend(sbmd, blockType);
         }
 

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	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -256,7 +256,7 @@
                     log.info(report("Ignoring unknown config value for", confEntryName, aValue)); //$NON-NLS-1$
                     return;
                 }
-                value = aValue;
+                value = type.convert(aValue);
             }
         }
     }
@@ -280,7 +280,7 @@
 
         if (value != null)
         {
-            String text = value;
+            String text = value.toString();
             if (allowsRTF())
             {
                 text = handleRTF(text);
@@ -386,7 +386,8 @@
             buf.append('=');
             if (allowsContinuation())
             {
-                String [] lines = StringUtil.splitAll(value, '\n');
+                String text = value.toString();
+                String [] lines = StringUtil.splitAll(text, '\n');
                 for (int i = 0; i < lines.length; i++)
                 {
                     if (i > 0)
@@ -399,7 +400,7 @@
             }
             else
             {
-                buf.append(value);
+                buf.append(value.toString());
                 buf.append('\n');
             }
         }
@@ -521,5 +522,5 @@
     private String internal;
     private String name;
     private List values;
-    private String value;
+    private Object value;
 }

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-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -36,6 +36,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.crosswire.common.util.Language;
 import org.crosswire.common.util.Languages;
 import org.crosswire.common.util.Logger;
 import org.crosswire.common.util.Reporter;
@@ -582,8 +583,9 @@
         }
     }
 
-    private boolean isLeftToRight(String lang)
+    private boolean isLeftToRight(Language language)
     {
+        String lang = language.getCode();
         // Java does not know that the following languages are right to left
         if ("fa".equals(lang) || "syr".equals(lang))  //$NON-NLS-1$ //$NON-NLS-2$
         {
@@ -599,48 +601,44 @@
         String dir = (String) getValue(ConfigEntryType.DIRECTION);
         String newDir = dir == null ? (String) ConfigEntryType.DIRECTION.getDefault() : dir;
 
-        String langEntry = (String) getValue(ConfigEntryType.LANG);
-        String langFromEntry = (String) getValue(ConfigEntryType.GLOSSARY_FROM);
-        String langToEntry = (String) getValue(ConfigEntryType.GLOSSARY_TO);
-
+        Language lang = (Language) getValue(ConfigEntryType.LANG);
+        Language langFrom = (Language) getValue(ConfigEntryType.GLOSSARY_FROM);
+        Language langTo = (Language) getValue(ConfigEntryType.GLOSSARY_TO);
+        testLanguage(internal, lang);
+        testLanguage(internal, langFrom);
+        testLanguage(internal, langTo);
+        
         // The LANG field should match the GLOSSARY_FROM field
-        if (langFromEntry != null && !langFromEntry.equals(langEntry))
+        if (langFrom != null && !langFrom.equals(lang))
         {
-            langEntry = langFromEntry;
+            lang = langFrom;
         }
 
-        String lang = getLanguage(internal, langEntry);
-        add(ConfigEntryType.LANGUAGE, lang);
-
         // This returns Left to Right if
         // it does not know what it is.
-        boolean leftToRight = isLeftToRight(langEntry);
+        boolean leftToRight = isLeftToRight(lang);
 
-        if (langFromEntry != null || langToEntry != null)
+        if (langFrom != null || langTo != null)
         {
-            String langFrom = getLanguage(internal, langFromEntry);
-            add(ConfigEntryType.LANGUAGE_FROM, langFrom);
-            String langTo = getLanguage(internal, langToEntry);
-            add(ConfigEntryType.LANGUAGE_TO, langTo);
             boolean fromLeftToRight = true;
             boolean toLeftToRight = true;
 
-            if (langFromEntry == null)
+            if (langFrom == null)
             {
                 log.warn("Missing data for " + internal + ". Assuming " + ConfigEntryType.GLOSSARY_FROM.getName() + '=' + Languages.DEFAULT_LANG_CODE);  //$NON-NLS-1$ //$NON-NLS-2$
             }
             else
             {
-                fromLeftToRight = isLeftToRight(langFromEntry);
+                fromLeftToRight = isLeftToRight(langFrom);
             }
 
-            if (langToEntry == null)
+            if (langTo == null)
             {
                 log.warn("Missing data for " + internal + ". Assuming " + ConfigEntryType.GLOSSARY_TO.getName() + '=' + Languages.DEFAULT_LANG_CODE);  //$NON-NLS-1$ //$NON-NLS-2$
             }
             else
             {
-                toLeftToRight = isLeftToRight(langToEntry);
+                toLeftToRight = isLeftToRight(langTo);
             }
 
             // At least one of the two languages should match the lang entry
@@ -767,13 +765,12 @@
 //        }
     }
 
-    private String getLanguage(String initials, String iso639Code)
+    private void testLanguage(String initials, Language lang)
     {
-        if (!Languages.isValidLanguage(iso639Code))
+        if (lang != null && !lang.isValidLanguage())
         {
-            log.warn("Unknown language " + iso639Code + " in book " + initials); //$NON-NLS-1$ //$NON-NLS-2$
+            log.warn("Unknown language " + lang.getCode() + " in book " + initials); //$NON-NLS-1$ //$NON-NLS-2$
         }
-        return Languages.getLanguage(iso639Code);
     }
 
     /**
@@ -839,7 +836,6 @@
         return buf.toString();
     }
 
-
    /**
      * Sword only recognizes two encodings for its modules: UTF-8 and LATIN1
      * Sword uses MS Windows cp1252 for Latin 1 not the standard. Arrgh!
@@ -876,11 +872,8 @@
 
     private static final ConfigEntryType[] LANG_INFO =
     {
-        ConfigEntryType.LANGUAGE,
         ConfigEntryType.LANG,
-        ConfigEntryType.LANGUAGE_FROM,
         ConfigEntryType.GLOSSARY_FROM,
-        ConfigEntryType.LANGUAGE_TO,
         ConfigEntryType.GLOSSARY_TO,
     };
 

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-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -28,7 +28,7 @@
 import java.util.Set;
 import java.util.regex.Pattern;
 
-import org.crosswire.common.util.Languages;
+import org.crosswire.common.util.Language;
 
 
 /**
@@ -47,7 +47,7 @@
  *     // will be the result of several constants ORed. See the
  *     // DISTRIBUTION_LICENSE* constants in SwordConstants. It appears some
  *     // versions do not stick to this convention, because of this, there is an
- *     // additional menber distributionLicenseAdditionInfo, to store additional
+ *     // additional member distributionLicenseAdditionInfo, to store additional
  *     // information.
  *     private int distributionLicense;
  *     private String distributionLicenseAdditionalInfo = "";
@@ -131,6 +131,21 @@
         }
 
         /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            try
+            {
+                return new Integer(input);
+            }
+            catch (NumberFormatException e)
+            {
+                return defaultValue;
+            }
+        }
+
+        /* (non-Javadoc)
          * @see org.crosswire.jsword.book.sword.ConfigEntryType#getDefault()
          */
         public Object getDefault()
@@ -559,6 +574,21 @@
             }
         }
 
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            try
+            {
+                return new Integer(input);
+            }
+            catch (NumberFormatException e)
+            {
+                return null;
+            }
+        }
+
         /**
          * Serialization ID
          */
@@ -762,13 +792,42 @@
     /**
      * Books with a Feature of Glossary are used to map words FROM one language TO another.
      */
-    public static final ConfigEntryType GLOSSARY_FROM = new ConfigEntryType("GlossaryFrom"); //$NON-NLS-1$
+    public static final ConfigEntryType GLOSSARY_FROM = new ConfigEntryType("GlossaryFrom") //$NON-NLS-1$
+    {
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = 6619179970516935818L;
 
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            return new Language(input);
+        }
+
+    };
+
     /**
      * Books with a Feature of Glossary are used to map words FROM one language TO another.
      */
-    public static final ConfigEntryType GLOSSARY_TO = new ConfigEntryType("GlossaryTo"); //$NON-NLS-1$
+    public static final ConfigEntryType GLOSSARY_TO = new ConfigEntryType("GlossaryTo") //$NON-NLS-1$
+    {
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            return new Language(input);
+        }
 
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = 3273532519245386866L;
+    };
+
     /**
      * multiple values starting with History, some sort of change-log.
      * In the conf these are of the form History_x.y. We strip off the x.y and prefix the value with it.
@@ -819,6 +878,21 @@
             }
         }
 
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            try
+            {
+                return new Integer(input);
+            }
+            catch (NumberFormatException e)
+            {
+                return null;
+            }
+        }
+
         /**
          * Serialization ID
          */
@@ -893,9 +967,19 @@
          */
         public Object getDefault()
         {
-            return Languages.DEFAULT_LANG_CODE;
+            return defaultLanguage;
         }
 
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            return new Language(input);
+        }
+
+        private Language defaultLanguage = new Language(null);
+
         /**
          * Serialization ID
          */
@@ -1157,6 +1241,14 @@
         }
 
         /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.sword.ConfigEntryType#convert(java.lang.String)
+         */
+        public Object convert(String input)
+        {
+            return Boolean.valueOf(input);
+        }
+
+        /* (non-Javadoc)
          * @see org.crosswire.jsword.book.sword.ConfigEntryType#getDefault()
          */
         public Object getDefault()
@@ -1213,65 +1305,6 @@
     };
 
     /**
-     * single value string, unknown use
-     * While Lang is an IS0-639 or ethnolog value, this is a friendly representation
-     * of the same.
-     */
-    public static final ConfigEntryType LANGUAGE = new ConfigEntryType("Language") //$NON-NLS-1$
-    {
-        /* (non-Javadoc)
-         * @see org.crosswire.jsword.book.sword.ConfigEntryType#isSynthetic()
-         */
-        public boolean isSynthetic()
-        {
-            return true;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3834029147533226546L;
-    };
-
-    /**
-     * For a GLOSSARY_FROM, this is the friendly version of the same.
-     */
-    public static final ConfigEntryType LANGUAGE_FROM = new ConfigEntryType("LanguageFrom") //$NON-NLS-1$
-    {
-        /* (non-Javadoc)
-         * @see org.crosswire.jsword.book.sword.ConfigEntryType#isSynthetic()
-         */
-        public boolean isSynthetic()
-        {
-            return true;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3905243407495214134L;
-    };
-
-    /**
-     * For a GLOSSARY_TO, this is the friendly version of the same.
-     */
-    public static final ConfigEntryType LANGUAGE_TO = new ConfigEntryType("LanguageTo") //$NON-NLS-1$
-    {
-        /* (non-Javadoc)
-         * @see org.crosswire.jsword.book.sword.ConfigEntryType#isSynthetic()
-         */
-        public boolean isSynthetic()
-        {
-            return true;
-        }
-
-        /**
-         * Serialization ID
-         */
-        private static final long serialVersionUID = 3257850961078007856L;
-    };
-
-    /**
      * A one line promo statement, required by Lockman for NASB
      */
     public static final ConfigEntryType SHORT_PROMO = new ConfigEntryType("ShortPromo"); //$NON-NLS-1$
@@ -1426,6 +1459,16 @@
     }
 
     /**
+     * Convert the string value from the conf into the representation
+     * of this ConfigEntryType.
+     * @return the converted object
+     */
+    public Object convert(String input)
+    {
+        return input;
+    }
+
+    /**
      * Lookup method to convert from a String
      */
     public static ConfigEntryType fromString(String name)
@@ -1556,9 +1599,6 @@
         OSIS_Q_TO_TICK,
         OSIS_VERSION,
         INITIALS,
-        LANGUAGE,
-        LANGUAGE_FROM,
-        LANGUAGE_TO,
         SHORT_PROMO,
         SHORT_COPYRIGHT,
         LOCATION_URL,

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-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -145,7 +145,7 @@
      */
     public String getName()
     {
-        return getProperty(ConfigEntryType.DESCRIPTION);
+        return (String) getProperty(ConfigEntryType.DESCRIPTION);
     }
 
     /**
@@ -170,7 +170,7 @@
      */
     public Filter getFilter()
     {
-        String sourcetype = getProperty(ConfigEntryType.SOURCE_TYPE);
+        String sourcetype = (String) getProperty(ConfigEntryType.SOURCE_TYPE);
         return FilterFactory.getFilter(sourcetype);
     }
 
@@ -197,7 +197,7 @@
         super.setLibrary(library);
 
         // Currently all DATA_PATH entries end in / to indicate dirs or not to indicate file prefixes
-        String datapath = getProperty(ConfigEntryType.DATA_PATH);
+        String datapath = (String) getProperty(ConfigEntryType.DATA_PATH);
 
         int lastSlash = datapath.lastIndexOf('/');
 
@@ -222,7 +222,7 @@
     {
         if (type == null)
         {
-            type = BookCategory.fromString(getProperty(ConfigEntryType.CATEGORY));
+            type = BookCategory.fromString((String) getProperty(ConfigEntryType.CATEGORY));
             if (type == BookCategory.OTHER)
             {
                 type = getBookType().getBookCategory();
@@ -245,7 +245,7 @@
      */
     public String getInitials()
     {
-        return getProperty(ConfigEntryType.INITIALS);
+        return (String) getProperty(ConfigEntryType.INITIALS);
     }
 
     /**
@@ -254,11 +254,9 @@
      * @param entry the ConfigEntryType
      * @return the property or null
      */
-    public String getProperty(ConfigEntryType entry)
+    public Object getProperty(ConfigEntryType entry)
     {
-        Object obj = cet.getValue(entry);
-
-        return obj != null ? obj.toString() : null;
+        return cet.getValue(entry);
     }
 
     /* (non-Javadoc)
@@ -266,7 +264,7 @@
      */
     public boolean isLeftToRight()
     {
-        String dir = getProperty(ConfigEntryType.DIRECTION);
+        String dir = (String) getProperty(ConfigEntryType.DIRECTION);
         return dir == null || dir.equals(ConfigEntryType.DIRECTION.getDefault());
     }
 
@@ -283,7 +281,7 @@
         // Many "features" are GlobalOptionFilters, which in the Sword C++ API
         // indicate a class to use for filtering.
         // These mostly have the source type prepended to the feature
-        StringBuffer buffer = new StringBuffer(getProperty(ConfigEntryType.SOURCE_TYPE));
+        StringBuffer buffer = new StringBuffer((String) getProperty(ConfigEntryType.SOURCE_TYPE));
         buffer.append(feature);
         if (cet.match(ConfigEntryType.GLOBAL_OPTION_FILTER, buffer.toString()))
         {
@@ -326,7 +324,7 @@
                 value = combined.toString();
             }
 
-            putProperty(key.toString(), value.toString());
+            putProperty(key.toString(), value);
         }
 //        Element ele = cet.toOSIS();
 //        SAXEventProvider sep = new JDOMSAXEventProvider(new Document(ele));

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -235,7 +235,7 @@
 
     private String getExpandedDataPath() throws BookException
     {
-        URI loc = NetUtil.lengthenURI(bmd.getLibrary(), bmd.getProperty(ConfigEntryType.DATA_PATH));
+        URI loc = NetUtil.lengthenURI(bmd.getLibrary(), (String) bmd.getProperty(ConfigEntryType.DATA_PATH));
 
         if (loc == null)
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -295,7 +295,7 @@
 
         SwordBookMetaData sbmd = getBookMetaData();
         String charset = sbmd.getBookCharset();
-        String compressType = sbmd.getProperty(ConfigEntryType.COMPRESS_TYPE);
+        String compressType = (String) sbmd.getProperty(ConfigEntryType.COMPRESS_TYPE);
 
         if (!(key instanceof IndexKey))
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -229,7 +229,7 @@
 
         SwordBookMetaData sbmd = getBookMetaData();
         String charset = sbmd.getBookCharset();
-        String compressType = sbmd.getProperty(ConfigEntryType.COMPRESS_TYPE);
+        String compressType = (String) sbmd.getProperty(ConfigEntryType.COMPRESS_TYPE);
 
         Verse verse = KeyUtil.getVerse(key);
 

Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java	2007-08-03 16:12:08 UTC (rev 1604)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java	2007-08-03 21:34:46 UTC (rev 1605)
@@ -68,7 +68,7 @@
         while (true)
         {
             String property = "JdbcDriver" + driver_attempt; //$NON-NLS-1$
-            String drivername = getProperty(property);
+            String drivername = getProperty(property).toString();
 
             try
             {
@@ -86,26 +86,26 @@
         try
         {
             // Actually connect to the database
-            String text_url = getProperty("TextURL"); //$NON-NLS-1$
+            String text_url = getProperty("TextURL").toString(); //$NON-NLS-1$
             textCon = DriverManager.getConnection(text_url);
 
-            String concord_url = getProperty("ConcordURL"); //$NON-NLS-1$
+            String concord_url = getProperty("ConcordURL").toString(); //$NON-NLS-1$
             concCon = DriverManager.getConnection(concord_url);
 
             // SQL statements
-            String doc_query = getProperty("DocQuery"); //$NON-NLS-1$
+            String doc_query = getProperty("DocQuery").toString(); //$NON-NLS-1$
             docStmt = textCon.prepareStatement(doc_query);
 
-            String ref_query = getProperty("RefQuery"); //$NON-NLS-1$
+            String ref_query = getProperty("RefQuery").toString(); //$NON-NLS-1$
             refStmt = concCon.prepareStatement(ref_query);
 
             //String verse_query = getProperty("VerseQuery");
             //verse_stmt = textcnx.prepareStatement(verse_query);
 
-            String start_query = getProperty("StartQuery"); //$NON-NLS-1$
+            String start_query = getProperty("StartQuery").toString(); //$NON-NLS-1$
             startStmt = concCon.prepareStatement(start_query);
 
-            wordsQuery = getProperty("WordsQuery"); //$NON-NLS-1$
+            wordsQuery = getProperty("WordsQuery").toString(); //$NON-NLS-1$
         }
         catch (SQLException ex)
         {




More information about the jsword-svn mailing list