[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/basic 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/basic
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jsword/org/crosswire/jsword/book/basic

Modified Files:
	DefaultBookMetaData.java 
Log Message:
Improvments on reading SwordBookMetaData

Index: DefaultBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/DefaultBookMetaData.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** DefaultBookMetaData.java	21 Sep 2004 17:46:23 -0000	1.12
--- DefaultBookMetaData.java	5 Oct 2004 22:03:09 -0000	1.13
***************
*** 1,8 ****
  package org.crosswire.jsword.book.basic;
  
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.text.ParseException;
- import java.util.Date;
  import java.util.LinkedHashMap;
  import java.util.Map;
--- 1,4 ----
***************
*** 14,18 ****
  import org.crosswire.jsword.book.BookMetaData;
  import org.crosswire.jsword.book.BookType;
- import org.crosswire.jsword.book.Openness;
  
  /**
--- 10,13 ----
***************
*** 50,54 ****
       * A call to setBook() is still required after this ctor is called
       */
!     public DefaultBookMetaData(BookDriver driver, Book book, Properties prop) throws MalformedURLException, ParseException
      {
          this.driver = driver;
--- 45,49 ----
       * A call to setBook() is still required after this ctor is called
       */
!     public DefaultBookMetaData(BookDriver driver, Book book, Properties prop)
      {
          this.driver = driver;
***************
*** 59,69 ****
          setName(prop.getProperty(BookMetaData.KEY_NAME));
          setType(prop.getProperty(BookMetaData.KEY_TYPE));
-         setSpeed(Integer.parseInt(prop.getProperty(BookMetaData.KEY_SPEED)));
  
          setLanguage(prop.getProperty(BookMetaData.KEY_LANGUAGE));
-         setEdition(prop.getProperty(BookMetaData.KEY_EDITION));
-         setOpenness(prop.getProperty(BookMetaData.KEY_OPENNESS));
-         setLicence(prop.getProperty(BookMetaData.KEY_LICENCE));
-         setFirstPublished(prop.getProperty(BookMetaData.KEY_FIRSTPUB));
      }
  
--- 54,59 ----
***************
*** 72,109 ****
       * A call to setBook() is still required after this ctor is called
       */
!     public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type, int speed)
!     {
!         this.driver = driver;
!         this.book = book;
! 
!         setName(name);
!         setType(type);
!         setSpeed(speed);
!     }
! 
!     /**
!      * Ctor with all important values.
!      * A call to setBook() is still required after this ctor is called
!      */
!     public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type, int speed, String edition, Openness openness, URL licence, Date firstPublished)
!     {
!         this.driver = driver;
!         this.book = book;
! 
!         setName(name);
!         setType(type);
!         setSpeed(speed);
! 
!         setEdition(edition);
!         setOpenness(openness);
!         setLicence(licence);
!         setFirstPublished(firstPublished);
!     }
! 
!     /**
!      * Ctor with all important values.
!      * A call to setBook() is still required after this ctor is called
!      */
!     public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type, int speed, String edition, String openstr, String licencestr, String pubstr) throws MalformedURLException, ParseException, NumberFormatException
      {
          this.driver = driver;
--- 62,66 ----
       * A call to setBook() is still required after this ctor is called
       */
!     public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type)
      {
          this.driver = driver;
***************
*** 112,121 ****
          setName(name);
          setType(type);
-         setSpeed(speed);
- 
-         setEdition(edition);
-         setOpenness(openstr);
-         setLicence(licencestr);
-         setFirstPublished(pubstr);
      }
  
--- 69,72 ----
***************
*** 161,172 ****
  
      /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getEdition()
-      */
-     public String getEdition()
-     {
-         return edition;
-     }
- 
-     /* (non-Javadoc)
       * @see org.crosswire.jsword.book.BookMetaData#getInitials()
       */
--- 112,115 ----
***************
*** 177,212 ****
  
      /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getSpeed()
-      */
-     public int getSpeed()
-     {
-         return speed;
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getFirstPublished()
-      */
-     public Date getFirstPublished()
-     {
-         return firstPublished;
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getOpenness()
-      */
-     public Openness getOpenness()
-     {
-         return openness;
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#getLicence()
-      */
-     public URL getLicence()
-     {
-         return licence;
-     }
- 
-     /* (non-Javadoc)
       * @see org.crosswire.jsword.book.BookMetaData#getProperties()
       */
--- 120,123 ----
***************
*** 222,231 ****
      {
          StringBuffer buf = new StringBuffer(getName());
-         String ed = getEdition();
- 
-         if (!ed.equals("")) //$NON-NLS-1$
-         {
-             buf.append(", ").append(ed); //$NON-NLS-1$
-         }
  
          if (driver != null)
--- 133,136 ----
***************
*** 246,257 ****
  
      /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.BookMetaData#isSameFamily(org.crosswire.jsword.book.BookMetaData)
-      */
-     public boolean isSameFamily(BookMetaData version)
-     {
-         return getName().equals(version.getName());
-     }
- 
-     /* (non-Javadoc)
       * @see org.crosswire.jsword.book.BookMetaData#getDriverName()
       */
--- 151,154 ----
***************
*** 304,351 ****
  
      /**
-      * @param edition The edition to set.
-      */
-     public void setEdition(String edition)
-     {
-         if (edition == null)
-         {
-             this.edition = ""; //$NON-NLS-1$
-         }
-         else
-         {
-             this.edition = edition;
-         }
- 
-         map.put(KEY_EDITION, this.edition);
-     }
- 
-     /**
-      * @param firstPublished The firstPublished to set.
-      */
-     public void setFirstPublished(Date firstPublished)
-     {
-         if (firstPublished == null)
-         {
-             firstPublished = FIRSTPUB_DEFAULT;
-         }
-         this.firstPublished = firstPublished;
- 
-         map.put(KEY_FIRSTPUB, this.firstPublished.toString());
-     }
- 
-     /**
-      * Internal setter for the first published date
-      */
-     public void setFirstPublished(String pubstr) throws ParseException
-     {
-         Date newPublished = null;
-         if (pubstr != null && pubstr.trim().length() > 0)
-         {
-             newPublished = FIRSTPUB_FORMAT.parse(pubstr);
-         }
-         setFirstPublished(newPublished);
-     }
- 
-     /**
       * See note on setName() for side effect on setInitials(). If a value of
       * null is used then the initials are defaulted using the name
--- 201,204 ----
***************
*** 375,402 ****
  
      /**
-      * @param licence The licence to set.
-      */
-     public void setLicence(URL licence)
-     {
-         this.licence = licence;
- 
-         map.put(KEY_LICENCE, licence == null ? "" : this.licence.toString()); //$NON-NLS-1$
-     }
- 
-     /**
-      * Internal setter for the license
-      */
-     public void setLicence(String licencestr) throws MalformedURLException
-     {
-         URL newLicence = null;
-         if (licencestr != null)
-         {
-             newLicence = new URL(licencestr);
-         }
- 
-         setLicence(newLicence);
-     }
- 
-     /**
       * Setting the name also sets some default initials, so if you wish to set
       * some specific initials then it should be done after setting the name.
--- 228,231 ----
***************
*** 414,463 ****
  
      /**
-      * @param openness The openness to set.
-      */
-     public void setOpenness(Openness openness)
-     {
-         if (openness == null)
-         {
-             openness = Openness.UNKNOWN;
-         }
-         this.openness = openness;
- 
-         map.put(KEY_OPENNESS, this.openness.toString());
-     }
- 
-     /**
-      * @param openstr The string version of the openness to set.
-      */
-     public void setOpenness(String openstr)
-     {
-         Openness newOpenness = null;
-         if (openstr != null)
-         {
-             newOpenness = Openness.fromString(openstr);
-         }
- 
-         setOpenness(newOpenness);
-     }
- 
-     /**
-      * @param speed The speed to set.
-      */
-     public void setSpeed(int speed)
-     {
-         this.speed = speed;
- 
-         map.put(KEY_SPEED, Integer.toString(this.speed));
-     }
- 
-     /**
-      * @param speedstr The speed to set.
-      */
-     public void setSpeed(String speedstr) throws NumberFormatException
-     {
-         setSpeed(Integer.parseInt(speedstr));
-     }
- 
-     /**
       * @param type The type to set.
       */
--- 243,246 ----
***************
*** 508,528 ****
          }
  
-         // If super does equals ...
-         /* Commented out because super.equals() always equals false
-         if (!super.equals(obj))
-         {
-             return false;
-         }
-         */
- 
          // The real bit ...
          BookMetaData that = (BookMetaData) obj;
  
!         if (!getName().equals(that.getName()))
!         {
!             return false;
!         }
! 
!         return getEdition().equals(that.getEdition());
      }
  
--- 291,298 ----
          }
  
          // The real bit ...
          BookMetaData that = (BookMetaData) obj;
  
!         return getName().equals(that.getName());
      }
  
***************
*** 532,536 ****
      public int hashCode()
      {
!         return (getName() + getEdition()).hashCode();
      }
  
--- 302,306 ----
      public int hashCode()
      {
!         return getName().hashCode();
      }
  
***************
*** 553,564 ****
  
      /**
-      * Convert a published Date into the standard (String) format
-      */
-     public static String formatPublishedDate(Date pub)
-     {
-         return FIRSTPUB_FORMAT.format(pub);
-     }
- 
-     /**
       * 
       */
--- 323,326 ----
***************
*** 570,578 ****
      private String name = ""; //$NON-NLS-1$
      private String language = ""; //$NON-NLS-1$
-     private String edition = ""; //$NON-NLS-1$
      private String initials = ""; //$NON-NLS-1$
-     private int speed = BookMetaData.SPEED_SLOWEST;
-     private Date firstPublished = FIRSTPUB_DEFAULT;
-     private Openness openness = Openness.UNKNOWN;
-     private URL licence;
  }
--- 332,335 ----



More information about the jsword-svn mailing list