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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Fri Mar 18 18:56:49 MST 2005


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

Modified Files:
	SwordBookDriver.java SwordBook.java Msg.java ModuleType.java 
	Msg.properties SwordBookMetaData.java 
Log Message:
Made Book the primary interface to a module and put BookMetaData within it. All of BookMetaData is accessible through the Book interface.

Index: SwordBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookMetaData.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** SwordBookMetaData.java	6 Mar 2005 20:21:47 -0000	1.37
--- SwordBookMetaData.java	19 Mar 2005 01:56:47 -0000	1.38
***************
*** 71,76 ****
      public SwordBookMetaData(Reader in, String internal) throws IOException
      {
-         setBook(null);
- 
          cet = new ConfigEntryTable(in, internal);
  //        Element ele = cet.toOSIS();
--- 71,74 ----
***************
*** 133,141 ****
  
      /**
!      * @return Returns the name of this module as it is used for directory and filenames.
       */
!     public String getDiskName()
      {
!         return getInitials().toLowerCase();
      }
  
--- 131,157 ----
  
      /**
!      * @return Returns the relative path of the module's conf.
       */
!     public String getConfPath()
      {
!         return SwordConstants.DIR_CONF + '/' + getInitials().toLowerCase() + SwordConstants.EXTENSION_CONF;
!     }
! 
!     /**
!      * @return the relative path of the module.
!      */
!     public String getModulePath()
!     {
!         // The path begins with ./
!         String dataPath = getProperty(ConfigEntryType.DATA_PATH).substring(2);
!         // Dictionaries and Daily Devotionals end with the prefix of the data
!         // files name, not a directory name.
!         // Lots of paths end with '/'
!         if (getType() == BookType.DICTIONARY ||
!             dataPath.charAt(dataPath.length() - 1) == '/')
!         {
!             dataPath = dataPath.substring(0, dataPath.lastIndexOf('/'));
!         }
!         return dataPath;
      }
  

Index: ModuleType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/ModuleType.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** ModuleType.java	5 Mar 2005 17:53:10 -0000	1.15
--- ModuleType.java	19 Mar 2005 01:56:47 -0000	1.16
***************
*** 324,328 ****
          Backend backend = getBackend(sbmd, progdir);
          Book book = getBook(sbmd, backend);
-         sbmd.setBook(book);
          return book;
      }
--- 324,327 ----

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/Msg.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Msg.java	13 Jun 2004 22:12:32 -0000	1.14
--- Msg.java	19 Mar 2005 01:56:47 -0000	1.15
***************
*** 37,40 ****
--- 37,41 ----
      static final Msg COMPRESSION_UNSUPPORTED = new Msg("ModuleType.CompressionUnsupported"); //$NON-NLS-1$
      static final Msg TYPE_UNSUPPORTED = new Msg("SwordBookDriver.TypeUnsuported"); //$NON-NLS-1$
+     static final Msg DELETE_FAILED = new Msg("SwordBookDriver.DeleteFailed"); //$NON-NLS-1$
      static final Msg TYPE_UNKNOWN = new Msg("RawLDBackend.TypeUnknown"); //$NON-NLS-1$
      static final Msg MISSING_BACKEND = new Msg("SwordDictionary.MissingBackend"); //$NON-NLS-1$

Index: SwordBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookDriver.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** SwordBookDriver.java	28 Feb 2005 02:21:40 -0000	1.36
--- SwordBookDriver.java	19 Mar 2005 01:56:47 -0000	1.37
***************
*** 10,18 ****
  import java.util.Properties;
  
  import org.crosswire.common.util.Logger;
  import org.crosswire.jsword.book.Book;
  import org.crosswire.jsword.book.BookDriver;
  import org.crosswire.jsword.book.BookException;
- import org.crosswire.jsword.book.BookMetaData;
  import org.crosswire.jsword.book.Books;
  import org.crosswire.jsword.book.IndexStatus;
--- 10,18 ----
  import java.util.Properties;
  
+ import org.crosswire.common.util.FileUtil;
  import org.crosswire.common.util.Logger;
  import org.crosswire.jsword.book.Book;
  import org.crosswire.jsword.book.BookDriver;
  import org.crosswire.jsword.book.BookException;
  import org.crosswire.jsword.book.Books;
  import org.crosswire.jsword.book.IndexStatus;
***************
*** 60,64 ****
       * @see org.crosswire.jsword.book.BookDriver#getBooks()
       */
!     public BookMetaData[] getBookMetaDatas()
      {
          ConfigEntry.resetStatistics();
--- 60,64 ----
       * @see org.crosswire.jsword.book.BookDriver#getBooks()
       */
!     public Book[] getBooks()
      {
          ConfigEntry.resetStatistics();
***************
*** 93,97 ****
                          {
                              Book book = createBook(sbmd, dirs[j]);
!                             valid.add(book.getBookMetaData());
  
                              IndexManager imanager = IndexManagerFactory.getIndexManager();
--- 93,97 ----
                          {
                              Book book = createBook(sbmd, dirs[j]);
!                             valid.add(book);
  
                              IndexManager imanager = IndexManagerFactory.getIndexManager();
***************
*** 125,129 ****
          ConfigEntry.dumpStatistics();
  
!         return (BookMetaData[]) valid.toArray(new BookMetaData[valid.size()]);
      }
  
--- 125,179 ----
          ConfigEntry.dumpStatistics();
  
!         return (Book[]) valid.toArray(new Book[valid.size()]);
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookDriver#isDeletable(org.crosswire.jsword.book.BookMetaData)
!      */
!     public boolean isDeletable(Book dead)
!     {
!         SwordBookMetaData sbmd = (SwordBookMetaData) dead.getBookMetaData();
!         File downloadDir = SwordBookDriver.getDownloadDir();
!         File confFile = new File(downloadDir, sbmd.getConfPath());
!         
!         // We can only uninstall what we download into our download dir.
!         return confFile.exists();
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookDriver#delete(org.crosswire.jsword.book.BookMetaData)
!      */
!     public void delete(Book dead) throws BookException
!     {
!         SwordBookMetaData sbmd = (SwordBookMetaData) dead.getBookMetaData();
!         File downloadDir = SwordBookDriver.getDownloadDir();
!         File confFile = new File(downloadDir, sbmd.getConfPath());
!         
!         // We can only uninstall what we download into our download dir.
!         if (!confFile.exists())
!         {
!             throw new BookException(Msg.DELETE_FAILED, new Object [] {confFile});
!         }
! 
!         File moduleDir = new File(downloadDir, sbmd.getModulePath());
!     
!         // Delete the conf
!         List failures = FileUtil.delete(confFile);
!         if (failures.size() == 0)
!         {
!             // If the conf is gone, then we cannot get to the module
!             // and then we can download it again.
!             // But if the conf is present and the module is gone,
!             // then we get errors.
!             // Delete the download module's dir
!             failures = FileUtil.delete(moduleDir);
!             Books.installed().removeBook(dead);
!         }
! 
!         // TODO(DM): list all that failed
!         if (failures.size() > 0)
!         {
!             throw new BookException(Msg.DELETE_FAILED, new Object [] {failures.get(0)});
!         }
      }
  
***************
*** 174,178 ****
                  SwordBookDriver sdriver = (SwordBookDriver) drivers[i];
                  Book book = sdriver.createBook(sbmd, bookpath);
!                 Books.installed().addBook(book.getBookMetaData());
              }
          }
--- 224,228 ----
                  SwordBookDriver sdriver = (SwordBookDriver) drivers[i];
                  Book book = sdriver.createBook(sbmd, bookpath);
!                 Books.installed().addBook(book);
              }
          }

Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/Msg.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.properties	14 Jun 2004 05:27:22 -0000	1.1
--- Msg.properties	19 Mar 2005 01:56:47 -0000	1.2
***************
*** 14,17 ****
--- 14,18 ----
  ModuleType.CompressionUnsupported=Unsupported compression type
  SwordBookDriver.TypeUnsuported=Unsupported type: {0} when reading {1}
+ SwordBookDriver.DeleteFailed=Unable to delete: {0}
  RawLDBackend.TypeUnknown=Unknown type: {0} when reading {1}
  SwordDictionary.MissingBackend=Configuration error: Missing backend engine.

Index: SwordBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBook.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** SwordBook.java	4 Mar 2005 04:04:47 -0000	1.15
--- SwordBook.java	19 Mar 2005 01:56:47 -0000	1.16
***************
*** 43,47 ****
       * Simple ctor
       */
!     protected SwordBook(SwordBookMetaData sbmd, Backend backend)
      {
          setBookMetaData(sbmd);
--- 43,47 ----
       * Simple ctor
       */
!     public SwordBook(SwordBookMetaData sbmd, Backend backend)
      {
          setBookMetaData(sbmd);
***************
*** 77,80 ****
--- 77,85 ----
      protected String getText(Key key) throws BookException
      {
+         if (backend == null)
+         {
+             return ""; //$NON-NLS-1$
+         }
+ 
          String result = backend.getRawText(key);
  



More information about the jsword-svn mailing list