[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Mon Jan 24 17:02:34 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv22965/java/jsword/org/crosswire/jsword/book/sword

Modified Files:
	SwordBookMetaData.java 
Removed Files:
	iso639.properties 
Log Message:
Added language to the book installer tree.

--- iso639.properties DELETED ---

Index: SwordBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookMetaData.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** SwordBookMetaData.java	16 Oct 2004 09:07:43 -0000	1.34
--- SwordBookMetaData.java	25 Jan 2005 00:02:32 -0000	1.35
***************
*** 16,34 ****
  import java.util.Locale;
  import java.util.Map;
- import java.util.MissingResourceException;
- import java.util.ResourceBundle;
  import java.util.Set;
  import java.util.TreeMap;
  
- import org.crosswire.common.util.CWClassLoader;
  import org.crosswire.common.util.Histogram;
  import org.crosswire.common.util.Logger;
  import org.crosswire.common.util.NetUtil;
  import org.crosswire.common.util.StringUtil;
- import org.crosswire.jsword.book.Book;
- import org.crosswire.jsword.book.BookDriver;
- import org.crosswire.jsword.book.BookMetaData;
  import org.crosswire.jsword.book.BookType;
- import org.crosswire.jsword.book.IndexStatus;
  import org.crosswire.jsword.book.basic.AbstractBookMetaData;
  import org.crosswire.jsword.book.filter.Filter;
--- 16,27 ----
***************
*** 90,94 ****
      public SwordBookMetaData(Reader in, String internal) throws IOException
      {
!         this.book = null;
          this.internal = internal;
          this.supported = true;
--- 83,87 ----
      public SwordBookMetaData(Reader in, String internal) throws IOException
      {
!         setBook(null);
          this.internal = internal;
          this.supported = true;
***************
*** 149,157 ****
              }
  
!             prop.put(key, combined.toString());
          }
  
          // set the key property file entries
!         prop.put(KEY_INITIALS, initials);
  
          validate();
--- 142,150 ----
              }
  
!             putProperty(key, combined.toString());
          }
  
          // set the key property file entries
!         putProperty(KEY_INITIALS, initials);
  
          validate();
***************
*** 180,184 ****
  
          String lang = getProperty(ConfigEntry.LANG);
!         prop.put(KEY_LANGUAGE, getLanguage(lang));
          if (lang != null) //$NON-NLS-1$
          {
--- 173,177 ----
  
          String lang = getProperty(ConfigEntry.LANG);
!         putProperty(KEY_LANGUAGE, getLanguage(internal, lang));
          if (lang != null) //$NON-NLS-1$
          {
***************
*** 205,209 ****
          {
              BookType type = mtype.getBookType();
!             prop.put(KEY_TYPE, type != null ? type.toString() : ""); //$NON-NLS-1$
          }
  
--- 198,202 ----
          {
              BookType type = mtype.getBookType();
!             putProperty(KEY_TYPE, type != null ? type.toString() : ""); //$NON-NLS-1$
          }
  
***************
*** 213,256 ****
  
      /**
-      * Get the language name from the language code. Note, this code does not support dialects.
-      * @param iso639Code
-      * @return the name of the language
-      */
-     private String getLanguage(String iso639Code)
-     {
-         String lookup = iso639Code;
-         if (lookup == null || lookup.length() == 0)
-         {
-             log.warn("Book " + internal + " named " + getName() + " has no language specified. Assuming English."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-             return getLanguage(DEFAULT_LANG_CODE);
-         }
- 
-         if (lookup.indexOf('_') != -1)
-         {
-             String[] locale = StringUtil.split(lookup, '_');
-             return getLanguage(locale[0]);
-         }
- 
-         char firstLangChar = lookup.charAt(0);
-         // If the language begins w/ an x then it is "Undetermined"
-         // Also if it is not a 2 or 3 character code then it is not a valid
-         // iso639 code.
-         if (firstLangChar == 'x' || firstLangChar == 'X' || lookup.length() > 3)
-         {
-             return getLanguage(UNKNOWN_LANG_CODE);
-         }
- 
-         try
-         {
-             return languages.getString(lookup);
-         }
-         catch (MissingResourceException e)
-         {
-             log.error("Not a valid language code:" + iso639Code + " in book " + internal); //$NON-NLS-1$ //$NON-NLS-2$
-             return getLanguage(UNKNOWN_LANG_CODE);
-         }
-     }
- 
-     /**
       * Save this config file to a URL
       * @param dest The URL to save the data to
--- 206,209 ----
***************
*** 322,327 ****
          organize(orderedMap, COPYRIGHT_INFO);
          // add everything else in sorted order
!         orderedMap.putAll(new TreeMap(prop));
!         prop = orderedMap;
      }
  
--- 275,280 ----
          organize(orderedMap, COPYRIGHT_INFO);
          // add everything else in sorted order
!         orderedMap.putAll(new TreeMap(getProperties()));
!         setProperties(orderedMap);
      }
  
***************
*** 334,338 ****
          {
              String key = category[i].toString();
!             Object value = prop.remove(key);
              if (value != null)
              {
--- 287,291 ----
          {
              String key = category[i].toString();
!             Object value = getProperties().remove(key);
              if (value != null)
              {
***************
*** 685,689 ****
          table.put(key, list);
  
!         prop.put(key, value);
      }
  
--- 638,642 ----
          table.put(key, list);
  
!         putProperty(key, value);
      }
  
***************
*** 707,734 ****
  
      /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getBook()
-      */
-     public Book getBook()
-     {
-         return book;
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getDriver()
-      */
-     public BookDriver getDriver()
-     {
-         return driver;
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getLanguage()
-      */
-     public String getLanguage()
-     {
-         return getProperty(KEY_LANGUAGE);
-     }
- 
-     /* (non-Javadoc)
       * @see org.crosswire.jsword.book.BookMetaData#getInitials()
       */
--- 660,663 ----
***************
*** 738,768 ****
      }
  
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getProperties()
-      */
-     public Map getProperties()
-     {
-         return prop;
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getIndexStatus()
-      */
-     public IndexStatus getIndexStatus()
-     {
-         return indexStatus;
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#setIndexStatus(java.lang.String)
-      */
-     public void setIndexStatus(IndexStatus newValue)
-     {
-         IndexStatus oldValue = this.indexStatus;
-         this.indexStatus = newValue;
-         prop.put(KEY_INDEXSTATUS, newValue);
-         firePropertyChange(KEY_INDEXSTATUS, oldValue, newValue);
-     }
- 
      /**
       * Get the string value for the property or null if it is not defined.
--- 667,670 ----
***************
*** 773,777 ****
      public String getProperty(Object entry)
      {
!         String result = (String) prop.get(entry.toString());
  
          if (result == null)
--- 675,679 ----
      public String getProperty(Object entry)
      {
!         String result = (String) getProperty(entry.toString());
  
          if (result == null)
***************
*** 791,795 ****
              else
              {
!                 prop.put(entry.toString(), result);
              }
          }
--- 693,697 ----
              else
              {
!                 putProperty(entry.toString(), result);
              }
          }
***************
*** 798,849 ****
  
      /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getFullName()
-      */
-     public String getFullName()
-     {
-         if (fullName == null)
-         {
-             fullName = computeFullName();
-         }
-         return fullName;
-     }
- 
-     /**
-      * 
-      */
-     private String computeFullName()
-     {
-         StringBuffer buf = new StringBuffer(getName());
- 
-         if (driver != null)
-         {
-             buf.append(" (").append(getDriverName()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
-         }
- 
-         return buf.toString();
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getFullName()
-      */
-     public String getOsisID()
-     {
-         return getType().toString() + '.' + getInitials();
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getDriverName()
-      */
-     public String getDriverName()
-     {
-         if (driver == null)
-         {
-             return null;
-         }
- 
-         return driver.getDriverName();
-     }
- 
-     /* (non-Javadoc)
       * @see org.crosswire.jsword.book.BookMetaData#lsLeftToRight()
       */
--- 700,703 ----
***************
*** 854,935 ****
      }
  
-     /**
-      * @param book The book to set.
-      */
-     protected void setBook(Book book)
-     {
-         this.book = book;
-     }
- 
-     /**
-      * This setter is public because access is needed from *SwordInstallers as
-      * well as the normal sword drivers. Where is C++ friend when you need it!
-      * @param driver The driver to set.
-      */
-     public void setDriver(BookDriver driver)
-     {
-         this.driver = driver;
-     }
- 
-     /* (non-Javadoc)
-      * @see java.lang.Object#equals(java.lang.Object)
-      */
-     public boolean equals(Object obj)
-     {
-         // Since this can not be null
-         if (obj == null)
-         {
-             return false;
-         }
- 
-         // We might consider checking for equality against all BookMetaDatas?
-         // However currently we dont.
- 
-         // Check that that is the same as this
-         // Don't use instanceof since that breaks inheritance
-         if (!obj.getClass().equals(this.getClass()))
-         {
-             return false;
-         }
- 
-         // The real bit ...
-         BookMetaData that = (BookMetaData) obj;
- 
-         return getName().equals(that.getName());
-     }
- 
-     /* (non-Javadoc)
-      * @see java.lang.Object#hashCode()
-      */
-     public int hashCode()
-     {
-         return getName().hashCode();
-     }
- 
-     /* (non-Javadoc)
-      * @see java.lang.Object#toString()
-      */
-     public String toString()
-     {
-         if (displayName == null)
-         {
-             StringBuffer buf = new StringBuffer("["); //$NON-NLS-1$
-             buf.append(getInitials());
-             buf.append("] - "); //$NON-NLS-1$
-             buf.append(getFullName());
-             displayName = buf.toString();
-         }
-         return displayName;
-     }
- 
-     /* (non-Javadoc)
-      * @see java.lang.Comparable#compareTo(java.lang.Object)
-      */
-     public int compareTo(Object obj)
-     {
-         BookMetaData that = (BookMetaData) obj;
-         return this.getName().compareTo(that.getName());
-     }
- 
      public static void dumpStatistics()
      {
--- 708,711 ----
***************
*** 937,943 ****
      }
  
-     private static final String DEFAULT_LANG_CODE = "en"; //$NON-NLS-1$
-     private static final String UNKNOWN_LANG_CODE = "und"; //$NON-NLS-1$
- 
      /**
       * The log stream
--- 713,716 ----
***************
*** 945,961 ****
      private static final Logger log = Logger.getLogger(SwordBookMetaData.class);
  
-     private static/*final*/ResourceBundle languages;
-     static
-     {
-         try
-         {
-             languages = ResourceBundle.getBundle("iso639", Locale.getDefault(), new CWClassLoader()); //$NON-NLS-1$;
-         }
-         catch (MissingResourceException e)
-         {
-             assert false;
-         }
-     }
- 
      private static final Object[] BASIC_INFO =
      {
--- 718,721 ----
***************
*** 1074,1082 ****
  
      /**
-      * The single key version of the input file
-      */
-     private Map prop = new LinkedHashMap();
- 
-     /**
       * The original name of this config file from mods.d.
       * This is only used for reporting
--- 834,837 ----
***************
*** 1085,1092 ****
  
      private ModuleType mtype;
-     private Book book;
-     private BookDriver driver;
-     private String fullName;
-     private String displayName;
      private String initials = ""; //$NON-NLS-1$
      private boolean supported;
--- 840,843 ----
***************
*** 1095,1098 ****
      private static Histogram histogram = new Histogram();
      private List warnings = new ArrayList();
-     private IndexStatus indexStatus = IndexStatus.UNDONE;
  }
--- 846,848 ----



More information about the jsword-svn mailing list