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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Tue Oct 5 15:03:11 MST 2004


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

Modified Files:
	BookFilters.java BookMetaData.java Defaults.java 
Log Message:
Improvments on reading SwordBookMetaData

Index: Defaults.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Defaults.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** Defaults.java	8 Sep 2004 19:55:07 -0000	1.22
--- Defaults.java	5 Oct 2004 22:03:09 -0000	1.23
***************
*** 48,57 ****
  
      /**
-      * Has the default Bible been manually set or are we picking the fastest
-      * as the default?
-      */
-     private static boolean autobdeft = true;
- 
-     /**
       * The default Bible
       */
--- 48,51 ----
***************
*** 59,68 ****
  
      /**
-      * Has the default Commentary been manually set or are we picking the fastest
-      * as the default?
-      */
-     private static boolean autocdeft = true;
- 
-     /**
       * The default Commentary
       */
--- 53,56 ----
***************
*** 70,79 ****
  
      /**
-      * Has the default Dictionary been manually set or are we picking the fastest
-      * as the default?
-      */
-     private static boolean autoddeft = true;
- 
-     /**
       * The default Dictionary
       */
--- 58,61 ----
***************
*** 88,92 ****
      public static void setBibleMetaData(BookMetaData bmd)
      {
-         autobdeft = false;
          bdeft = bmd;
      }
--- 70,73 ----
***************
*** 97,101 ****
      protected static void unsetBibleMetaData()
      {
-         autobdeft = true;
          bdeft = null;
  
--- 78,81 ----
***************
*** 170,174 ****
      public static void setCommentaryMetaData(BookMetaData cmd)
      {
-         autocdeft = false;
          cdeft = cmd;
      }
--- 150,153 ----
***************
*** 179,183 ****
      protected static void unsetCommentaryMetaData()
      {
-         autocdeft = true;
          cdeft = null;
  
--- 158,161 ----
***************
*** 254,258 ****
      public static void setDictionaryMetaData(BookMetaData dmd)
      {
-         autoddeft = false;
          ddeft = dmd;
      }
--- 232,235 ----
***************
*** 263,267 ****
      protected static void unsetDictionaryMetaData()
      {
-         autoddeft = true;
          ddeft = null;
  
--- 240,243 ----
***************
*** 345,349 ****
  
      /**
!      * Should this Bible become the default?
       */
      protected static void checkPreferable(BookMetaData bmd)
--- 321,326 ----
  
      /**
!      * Should this Book become the default?
!      * Only if there is not one.
       */
      protected static void checkPreferable(BookMetaData bmd)
***************
*** 351,395 ****
          assert bmd != null;
  
!         if (bmd.getType().equals(BookType.BIBLE))
          {
!             // Do we even think about replacing the default Bible?
!             if (autobdeft || bdeft == null)
!             {
!                 // If there is no default or this is faster
!                 if (bdeft == null || bmd.getSpeed() > bdeft.getSpeed())
!                 {
!                     bdeft = bmd;
!                     autobdeft = true;
!                     log.debug("setting as default bible since speed=" + bdeft.getSpeed()); //$NON-NLS-1$
!                 }
!             }
          }
!         else if (bmd.getType().equals(BookType.COMMENTARY))
          {
!             // Do we even think about replacing the default Bible?
!             if (autocdeft || cdeft == null)
!             {
!                 // If there is no default or this is faster
!                 if (cdeft == null || bmd.getSpeed() > cdeft.getSpeed())
!                 {
!                     cdeft = bmd;
!                     autocdeft = true;
!                     log.debug("setting as default commentary since speed=" + cdeft.getSpeed()); //$NON-NLS-1$
!                 }
!             }
          }
!         else if (bmd.getType().equals(BookType.DICTIONARY))
          {
!             // Do we even think about replacing the default Bible?
!             if (autoddeft || ddeft == null)
!             {
!                 // If there is no default or this is faster
!                 if (ddeft == null || bmd.getSpeed() > ddeft.getSpeed())
!                 {
!                     ddeft = bmd;
!                     autoddeft = true;
!                     log.debug("setting as default dictionary since speed=" + ddeft.getSpeed()); //$NON-NLS-1$
!                 }
!             }
          }
      }
--- 328,342 ----
          assert bmd != null;
  
!         if (bmd.getType().equals(BookType.BIBLE) && bdeft == null)
          {
!             bdeft = bmd;
          }
!         else if (bmd.getType().equals(BookType.COMMENTARY) && cdeft == null)
          {
!             cdeft = bmd;
          }
!         else if (bmd.getType().equals(BookType.DICTIONARY) && ddeft == null)
          {
!             ddeft = bmd;
          }
      }

Index: BookFilters.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookFilters.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BookFilters.java	19 Nov 2003 22:48:15 -0000	1.6
--- BookFilters.java	5 Oct 2004 22:03:09 -0000	1.7
***************
*** 132,150 ****
  
      /**
!      * A filter that accepts everything faster that a set minimum.
!      */
!     public static BookFilter getFaster(final int slowest)
!     {
!         return new BookFilter()
!         {
!             public boolean test(BookMetaData bmd)
!             {
!                 return bmd.getSpeed() > slowest;
!             }
!         };
!     }
! 
!     /**
!      * A filter that accepts everything faster that a set minimum.
       */
      public static BookFilter both(final BookFilter b1, final BookFilter b2)
--- 132,136 ----
  
      /**
!      * A filter that accepts Books that match two criteria.
       */
      public static BookFilter both(final BookFilter b1, final BookFilter b2)
***************
*** 160,164 ****
  
      /**
!      * A filter that accepts everything faster that a set minimum.
       */
      public static BookFilter either(final BookFilter b1, final BookFilter b2)
--- 146,150 ----
  
      /**
!      * A filter that accepts Books that match either of two criteria.
       */
      public static BookFilter either(final BookFilter b1, final BookFilter b2)

Index: BookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookMetaData.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** BookMetaData.java	10 Sep 2004 14:14:15 -0000	1.20
--- BookMetaData.java	5 Oct 2004 22:03:09 -0000	1.21
***************
*** 1,8 ****
  package org.crosswire.jsword.book;
  
- import java.net.URL;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
  import java.util.Map;
  
--- 1,4 ----
***************
*** 86,100 ****
  
      /**
-      * The edition of this book, for example "Anglicised" (NIV),
-      * "Stephanus" (Greek).
-      * For 2 books to be equal both the name and the edition must be equal.
-      * In general the text returned by this method should not include the word
-      * "Edition". It is valid for an edition to be a blank string but not for it
-      * to be null.
-      * @return The name of the edition
-      */
-     public String getEdition();
- 
-     /**
       * The initials of this book - how people familiar with this book will know
       * it, for example "NIV", "KJV".
--- 82,85 ----
***************
*** 104,146 ****
  
      /**
-      * The expected speed at which this implementation gets correct answers.
-      * This value is used by Books to decide the fastest implementation for a
-      * given job.
-      * <p>The valid values are defined in the Books class.
-      * @see Books
-      * @return a speed value between -1 and 10
-      */
-     public int getSpeed();
- 
-     /**
-      * The date of first publishing.
-      * This does not need to be accurate and 2 books can be considered equal
-      * even if they have different first publishing dates for that reason.
-      * In general "1 Jan 1970" means published in 1970, and so on.
-      * <b>A null return from this method is entirely valid</b> if the date of
-      * first publishing is not known.
-      * If the date is required in string form it should be in the format
-      * YYYY-MM-DD so save US/UK confusion over MM/DD and DD/MM.
-      * @return The date of first publishing
-      */
-     public Date getFirstPublished();
- 
-     /**
-      * Is this book sold for commercial profit like the NIV, or kept
-      * open like the NET book.
-      * @return A STATUS_* constant
-      */
-     public Openness getOpenness();
- 
-     /**
-      * Not sure about this one - Do we need a way of getting at the dist.
-      * licence? Are we going to be able to tie it down to a single book
-      * policy like this? A null return is valid if the licence URL is not
-      * known.
-      * @return String detailing the users right to distribute this book
-      */
-     public URL getLicence();
- 
-     /**
       * Calculated field: Get an OSIS identifier for the OsisText.setOsisIDWork()
       * and the Work.setOsisWork() methods.
--- 89,92 ----
***************
*** 151,157 ****
  
      /**
!      * Calculated field: The full name including edition of the book, for example
!      * "New International Version, Anglicised (Ser)".
!      * The format is "name, edition (Driver)"
       * @return The full name of this book
       */
--- 97,102 ----
  
      /**
!      * Calculated field: The full name of the book, for example
!      * The format is "name, (Driver)"
       * @return The full name of this book
       */
***************
*** 159,169 ****
  
      /**
-      * Calculated method: Do the 2 books have matching names.
-      * @param book The book to compare to
-      * @return true if the names match
-      */
-     public boolean isSameFamily(BookMetaData book);
- 
-     /**
       * Calculated field: The name of the name, which could be helpful to
       * distinguish similar Books available through 2 BookDrivers.
--- 104,107 ----
***************
*** 191,260 ****
  
      /**
-      * The SPEED_* constants specify how fast a Book implementation is.
-      * 
-      * Important values include 5, were the remoting system will not remote
-      * Books where getSpeed() >= 5 (to save re-remoting already remote Books).
-      * 10 is also special - values > 10 indicate the data returned is likely to
-      * be wrong (i.e. test data) So we should probably not ship systems with
-      * BibleDrivers that return > 10.
-      */
-     public static final int SPEED_FASTEST = 10;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_FAST = 9;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_MEDIUM = 8;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_SLOW = 7;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_SLOWEST = 6;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_REMOTE_FASTEST = 5;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_REMOTE_FAST = 4;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_REMOTE_MEDIUM = 3;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_REMOTE_SLOW = 2;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_REMOTE_SLOWEST = 1;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_IGNORE = 0;
- 
-     /**
-      * @see BookMetaData#SPEED_FASTEST
-      */
-     public static final int SPEED_INACCURATE = -1;
- 
-     /**
       * The key for the type in the properties map
       */
--- 129,132 ----
***************
*** 274,278 ****
       * The key for the name in the properties map
       */
!     public static final String KEY_NAME = "Name"; //$NON-NLS-1$
  
      /**
--- 146,150 ----
       * The key for the name in the properties map
       */
!     public static final String KEY_NAME = "Description"; //$NON-NLS-1$
  
      /**
***************
*** 282,325 ****
  
      /**
-      * The key for the edition in the properties map
-      */
-     public static final String KEY_EDITION = "Edition"; //$NON-NLS-1$
- 
-     /**
       * The key for the initials in the properties map
       */
      public static final String KEY_INITIALS = "Initials"; //$NON-NLS-1$
  
-     /**
-      * The key for the speed in the properties map
-      */
-     public static final String KEY_SPEED = "Speed"; //$NON-NLS-1$
- 
-     /**
-      * The key for the first pub in the properties map
-      */
-     public static final String KEY_FIRSTPUB = "FirstPublished"; //$NON-NLS-1$
- 
-     /**
-      * The key for the openness in the properties map
-      */
-     public static final String KEY_OPENNESS = "Openness"; //$NON-NLS-1$
- 
-     /**
-      * The key for the licence in the properties map
-      */
-     public static final String KEY_LICENCE = "Licence"; //$NON-NLS-1$
- 
-     /**
-      * The default creation date.
-      * Using new Date(0) is the same as FIRSTPUB_FORMAT.parse("1970-01-01")
-      * but does not throw
-      */
-     public static final Date FIRSTPUB_DEFAULT = new Date(0L);
- 
-     /**
-      * The default way for format published dates when converting to and from
-      * strings
-      */
-     public static final DateFormat FIRSTPUB_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
  }
--- 154,160 ----



More information about the jsword-svn mailing list