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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Thu Mar 3 21:04:49 MST 2005


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

Modified Files:
	GZIPBackend.java ConfigEntryTable.java Backend.java 
	ZLDBackend.java ConfigEntryType.java RawLDBackend.java 
	CompressionType.java SwordDictionary.java SwordBook.java 
	LZSSBackend.java RawBackend.java ModuleType.java 
Log Message:
Added Sapphire to decrypt NASB.
Modified lots of code to use it.
Changed OSIS seg to hi for italic, bold and underline.

Index: ModuleType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/ModuleType.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ModuleType.java	28 Feb 2005 02:21:40 -0000	1.13
--- ModuleType.java	4 Mar 2005 04:04:47 -0000	1.14
***************
*** 45,51 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new RawBackend(path);
          }
  
--- 45,51 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new RawBackend(sbmd, rootPath);
          }
  
***************
*** 66,72 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return getCompressedBackend(sbmd, path);
          }
  
--- 66,72 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return getCompressedBackend(sbmd, rootPath);
          }
  
***************
*** 92,98 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new RawBackend(path);
          }
  
--- 92,98 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new RawBackend(sbmd, rootPath);
          }
  
***************
*** 113,119 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return getCompressedBackend(sbmd, path);
          }
  
--- 113,119 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return getCompressedBackend(sbmd, rootPath);
          }
  
***************
*** 139,145 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new RawBackend(path);
          }
  
--- 139,145 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new RawBackend(sbmd, rootPath);
          }
  
***************
*** 160,166 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new RawBackend(path);
          }
  
--- 160,166 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new RawBackend(sbmd, rootPath);
          }
  
***************
*** 181,187 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new RawLDBackend(sbmd, path, 2);
          }
  
--- 181,187 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new RawLDBackend(sbmd, rootPath, 2);
          }
  
***************
*** 202,208 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new RawLDBackend(sbmd, path, 4);
          }
  
--- 202,208 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new RawLDBackend(sbmd, rootPath, 4);
          }
  
***************
*** 223,229 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new ZLDBackend(sbmd);
          }
  
--- 223,229 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new ZLDBackend(sbmd, rootPath);
          }
  
***************
*** 244,250 ****
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new RawBackend(path);
          }
  
--- 244,250 ----
          }
  
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new RawBackend(sbmd, rootPath);
          }
  
***************
*** 317,324 ****
      public Book createBook(SwordBookMetaData sbmd, File progdir) throws BookException
      {
!         String dataPath = sbmd.getProperty(ConfigEntryType.DATA_PATH);
!         File baseurl = new File(progdir, dataPath);
!         String path = baseurl.getAbsolutePath();
!         Backend backend = getBackend(sbmd, path);
          Book book = getBook(sbmd, backend);
          sbmd.setBook(book);
--- 317,321 ----
      public Book createBook(SwordBookMetaData sbmd, File progdir) throws BookException
      {
!         Backend backend = getBackend(sbmd, progdir);
          Book book = getBook(sbmd, backend);
          sbmd.setBook(book);
***************
*** 334,348 ****
       * Create a the appropriate backend for this type of book
       */
!     protected abstract Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException;
  
      /**
       * 
       */
!     protected static Backend getCompressedBackend(SwordBookMetaData sbmd, String path) throws BookException
      {
          String cStr = sbmd.getProperty(ConfigEntryType.COMPRESS_TYPE);
          if (cStr != null)
          {
!             return CompressionType.fromString(cStr).getBackend(sbmd, path);
          }
          throw new BookException(Msg.COMPRESSION_UNSUPPORTED, new Object[] { cStr });
--- 331,345 ----
       * Create a the appropriate backend for this type of book
       */
!     protected abstract Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException;
  
      /**
       * 
       */
!     protected static Backend getCompressedBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
      {
          String cStr = sbmd.getProperty(ConfigEntryType.COMPRESS_TYPE);
          if (cStr != null)
          {
!             return CompressionType.fromString(cStr).getBackend(sbmd, rootPath);
          }
          throw new BookException(Msg.COMPRESSION_UNSUPPORTED, new Object[] { cStr });

Index: RawBackend.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/RawBackend.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** RawBackend.java	8 Sep 2004 19:55:07 -0000	1.19
--- RawBackend.java	4 Mar 2005 04:04:47 -0000	1.20
***************
*** 40,50 ****
   * @version $Id$
   */
! public class RawBackend implements Backend
  {
      /**
       * Simple ctor
       */
!     public RawBackend(String path) throws BookException
      {
          idxFile[SwordConstants.TESTAMENT_OLD] = new File(path + File.separator + SwordConstants.FILE_OT + SwordConstants.EXTENSION_VSS);
          txtFile[SwordConstants.TESTAMENT_OLD] = new File(path + File.separator + SwordConstants.FILE_OT);
--- 40,55 ----
   * @version $Id$
   */
! public class RawBackend extends Backend
  {
      /**
       * Simple ctor
       */
!     public RawBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
      {
+         super(sbmd, rootPath);
+         String dataPath = sbmd.getProperty(ConfigEntryType.DATA_PATH);
+         File baseurl = new File(rootPath, dataPath);
+         String path = baseurl.getAbsolutePath();
+        
          idxFile[SwordConstants.TESTAMENT_OLD] = new File(path + File.separator + SwordConstants.FILE_OT + SwordConstants.EXTENSION_VSS);
          txtFile[SwordConstants.TESTAMENT_OLD] = new File(path + File.separator + SwordConstants.FILE_OT);
***************
*** 118,124 ****
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key, String charset) throws BookException
      {
          checkActive();
  
          Verse verse = KeyUtil.getVerse(key);
--- 123,130 ----
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key) throws BookException
      {
          checkActive();
+         String charset = getBookMetaData().getModuleCharset();
  
          Verse verse = KeyUtil.getVerse(key);

Index: SwordDictionary.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordDictionary.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** SwordDictionary.java	29 Sep 2004 22:21:23 -0000	1.37
--- SwordDictionary.java	4 Mar 2005 04:04:47 -0000	1.38
***************
*** 120,124 ****
              text.addContent(div);
  
!             String txt = backend.getRawText(key, sbmd.getModuleCharset());
  
              List osisContent = sbmd.getFilter().toOSIS(txt);
--- 120,124 ----
              text.addContent(div);
  
!             String txt = backend.getRawText(key);
  
              List osisContent = sbmd.getFilter().toOSIS(txt);
***************
*** 146,150 ****
          try
          {
!             return backend.getRawText(key, sbmd.getModuleCharset());
          }
          catch (Exception ex)
--- 146,150 ----
          try
          {
!             return backend.getRawText(key);
          }
          catch (Exception ex)

Index: ConfigEntryTable.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/ConfigEntryTable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ConfigEntryTable.java	28 Feb 2005 02:21:40 -0000	1.1
--- ConfigEntryTable.java	4 Mar 2005 04:04:47 -0000	1.2
***************
*** 161,165 ****
              String key = line.substring(0, eqpos).trim();
              String value = line.substring(eqpos + 1).trim();
!             if (value.length() == 0)
              {
                  log.warn("Ignoring empty entry in " + internal + ": " + line); //$NON-NLS-1$ //$NON-NLS-2$
--- 161,166 ----
              String key = line.substring(0, eqpos).trim();
              String value = line.substring(eqpos + 1).trim();
!             // Only CIPHER_KEYS that are empty are not ignored
!             if (value.length() == 0 && !ConfigEntryType.CIPHER_KEY.getName().equals(key))
              {
                  log.warn("Ignoring empty entry in " + internal + ": " + line); //$NON-NLS-1$ //$NON-NLS-2$
***************
*** 502,510 ****
      private void validate()
      {
!         // Locked modules are described but don't exist.
!         if (getValue(ConfigEntryType.CIPHER_KEY) != null)
          {
!             // Don't need to say we don't support locked modules. We already know that!
!             //log.debug("Book not supported: " + internal + " because it is locked."); //$NON-NLS-1$ //$NON-NLS-2$
              supported = false;
              return;
--- 503,511 ----
      private void validate()
      {
!         // Only locked modules that have a key can be used.
!         String cipher = (String) getValue(ConfigEntryType.CIPHER_KEY);
!         if (cipher != null && cipher.length() == 0)
          {
!             log.debug("Book not supported: " + internal + " because it is locked and there is no key."); //$NON-NLS-1$ //$NON-NLS-2$
              supported = false;
              return;
***************
*** 581,587 ****
--- 582,590 ----
      {
          ConfigEntryType.ABOUT,
+         ConfigEntryType.SHORT_PROMO,
          ConfigEntryType.DISTRIBUTION_LICENSE,
          ConfigEntryType.DISTRIBUTION_NOTES,
          ConfigEntryType.DISTRIBUTION_SOURCE,
+         ConfigEntryType.SHORT_COPYRIGHT,
          ConfigEntryType.COPYRIGHT,
          ConfigEntryType.COPYRIGHT_DATE,

Index: Backend.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/Backend.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Backend.java	30 Aug 2004 09:27:07 -0000	1.11
--- Backend.java	4 Mar 2005 04:04:47 -0000	1.12
***************
*** 1,5 ****
--- 1,8 ----
  package org.crosswire.jsword.book.sword;
  
+ import java.io.File;
+ 
  import org.crosswire.common.activate.Activatable;
+ import org.crosswire.common.crypt.Sapphire;
  import org.crosswire.jsword.book.BookException;
  import org.crosswire.jsword.passage.Key;
***************
*** 29,48 ****
   * @version $Id$
   */
! public interface Backend extends Activatable
  {
      /**
       * Initialise a Backend before use. This method needs to call addKey() a
       * number of times on SwordDictionary
       */
!     public Key readIndex();
  
      /**
       * Get the bytes alotted for the given verse
       * @param key The key to fetch
-      * @param charset the Java standard charset to convert the text into
       * @return String The data for the verse in question
       * @throws BookException If the data can not be read.
       */
!     public String getRawText(Key key, String charset) throws BookException;
  
      /**
--- 32,95 ----
   * @version $Id$
   */
! abstract public class Backend implements Activatable
  {
      /**
+      * Construct a minimal backend
+      * @param sbmd
+      * @param location
+      */
+     public Backend(SwordBookMetaData sbmd, File location)
+     {
+         bmd = sbmd;
+         rootPath = location;
+     }
+ 
+     /**
+      * @return Returns the root path.
+      */
+     public File getRootPath()
+     {
+         return rootPath;
+     }
+ 
+     /**
+      * @return Returns the Sword BookMetaData.
+      */
+     public SwordBookMetaData getBookMetaData()
+     {
+         return bmd;
+     }
+ 
+     /**
+      * Decipher the data in place, if it is enciphered and there
+      * is a key to unlock it.
+      * @param data the data to unlock
+      */
+     public void decipher(byte[] data)
+     {
+         String cipherKeyString = getBookMetaData().getProperty(ConfigEntryType.CIPHER_KEY);
+         if (cipherKeyString != null)
+         {
+             Sapphire cipherEngine = new Sapphire(cipherKeyString.getBytes());
+             for (int i = 0; i < data.length; i++)
+             {
+                 data[i] = cipherEngine.cipher(data[i]);
+             }
+         }
+     }
+ 
+     /**
       * Initialise a Backend before use. This method needs to call addKey() a
       * number of times on SwordDictionary
       */
!     abstract public Key readIndex();
  
      /**
       * Get the bytes alotted for the given verse
       * @param key The key to fetch
       * @return String The data for the verse in question
       * @throws BookException If the data can not be read.
       */
!     abstract public String getRawText(Key key) throws BookException;
  
      /**
***************
*** 50,53 ****
       * @return true if this Backend is implemented.
       */
!     public boolean isSupported();
  }
--- 97,103 ----
       * @return true if this Backend is implemented.
       */
!     abstract public boolean isSupported();
!     
!     private SwordBookMetaData bmd;
!     private File rootPath;
  }

Index: ConfigEntryType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/ConfigEntryType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ConfigEntryType.java	28 Feb 2005 02:21:40 -0000	1.1
--- ConfigEntryType.java	4 Mar 2005 04:04:47 -0000	1.2
***************
*** 688,691 ****
--- 688,692 ----
              "OSISStrongs", //$NON-NLS-1$
              "OSISFootnotes", //$NON-NLS-1$
+             "OSISScripref", //$NON-NLS-1$
              "OSISMorph", //$NON-NLS-1$
              "OSISHeadings", //$NON-NLS-1$
***************
*** 1198,1201 ****
--- 1199,1212 ----
  
      /**
+      * A one line promo statement, required by Lockman for NASB
+      */
+     public static final ConfigEntryType SHORT_PROMO = new ConfigEntryType("ShortPromo"); //$NON-NLS-1$
+ 
+     /**
+      * A one line copyright statement, required by Lockman for NASB
+      */
+     public static final ConfigEntryType SHORT_COPYRIGHT = new ConfigEntryType("ShortCopyright"); //$NON-NLS-1$
+ 
+     /**
       * Simple ctor
       */
***************
*** 1426,1429 ****
--- 1437,1442 ----
                      LANGUAGE_FROM,
                      LANGUAGE_TO,
+                     SHORT_PROMO,
+                     SHORT_COPYRIGHT,
      };
  }

Index: ZLDBackend.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/ZLDBackend.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ZLDBackend.java	27 Jul 2004 21:42:33 -0000	1.7
--- ZLDBackend.java	4 Mar 2005 04:04:47 -0000	1.8
***************
*** 1,4 ****
--- 1,6 ----
  package org.crosswire.jsword.book.sword;
  
+ import java.io.File;
+ 
  import org.crosswire.common.activate.Lock;
  import org.crosswire.jsword.book.BookException;
***************
*** 31,42 ****
   * @version $Id$
   */
! public class ZLDBackend implements Backend
  {
      /**
       * Simple ctor
       */
!     public ZLDBackend(SwordBookMetaData sbmd)
      {
!         this.sbmd = sbmd;
      }
  
--- 33,44 ----
   * @version $Id$
   */
! public class ZLDBackend extends Backend
  {
      /**
       * Simple ctor
       */
!     public ZLDBackend(SwordBookMetaData sbmd, File rootPath)
      {
!         super(sbmd, rootPath);
      }
  
***************
*** 60,64 ****
      public Key readIndex()
      {
!         return new DefaultKeyList(null, sbmd.getName());
      }
  
--- 62,66 ----
      public Key readIndex()
      {
!         return new DefaultKeyList(null, getBookMetaData().getName());
      }
  
***************
*** 66,70 ****
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key, String charset) throws BookException
      {
          // LATER(joe): implement this
--- 68,72 ----
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key) throws BookException
      {
          // LATER(joe): implement this
***************
*** 79,86 ****
          return false;
      }
- 
-     /**
-      * The book driver that we are providing data for
-      */
-     private SwordBookMetaData sbmd;
  }
--- 81,83 ----

Index: SwordBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBook.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** SwordBook.java	29 Sep 2004 22:21:23 -0000	1.14
--- SwordBook.java	4 Mar 2005 04:04:47 -0000	1.15
***************
*** 77,81 ****
      protected String getText(Key key) throws BookException
      {
!         String result = backend.getRawText(key, sbmd.getModuleCharset());
  
          assert result != null;
--- 77,81 ----
      protected String getText(Key key) throws BookException
      {
!         String result = backend.getRawText(key);
  
          assert result != null;

Index: RawLDBackend.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/RawLDBackend.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** RawLDBackend.java	21 Sep 2004 17:46:23 -0000	1.12
--- RawLDBackend.java	4 Mar 2005 04:04:47 -0000	1.13
***************
*** 41,45 ****
   * @version $Id$
   */
! public class RawLDBackend implements Backend
  {
      /**
--- 41,45 ----
   * @version $Id$
   */
! public class RawLDBackend extends Backend
  {
      /**
***************
*** 47,53 ****
       * @param datasize We need to know how many bytes in the size portion of the index
       */
!     public RawLDBackend(SwordBookMetaData sbmd, String path, int datasize) throws BookException
      {
!         this.sbmd = sbmd;
          this.datasize = datasize;
  
--- 47,53 ----
       * @param datasize We need to know how many bytes in the size portion of the index
       */
!     public RawLDBackend(SwordBookMetaData sbmd, File rootPath, int datasize) throws BookException
      {
!         super(sbmd, rootPath);
          this.datasize = datasize;
  
***************
*** 57,60 ****
--- 57,64 ----
          }
  
+         String dataPath = sbmd.getProperty(ConfigEntryType.DATA_PATH);
+         File baseurl = new File(rootPath, dataPath);
+         String path = baseurl.getAbsolutePath();
+ 
          idxFile = new File(path + SwordConstants.EXTENSION_INDEX);
          datFile = new File(path + SwordConstants.EXTENSION_DATA);
***************
*** 121,125 ****
          checkActive();
  
!         Key reply = new DefaultKeyList(null, sbmd.getName());
  
          int entrysize = OFFSETSIZE + datasize;
--- 125,129 ----
          checkActive();
  
!         Key reply = new DefaultKeyList(null, getBookMetaData().getName());
  
          int entrysize = OFFSETSIZE + datasize;
***************
*** 192,199 ****
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key, String charset) throws BookException
      {
          checkActive();
  
          if (!(key instanceof IndexKey))
          {
--- 196,205 ----
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key) throws BookException
      {
          checkActive();
  
+         String charset = getBookMetaData().getModuleCharset();
+ 
          if (!(key instanceof IndexKey))
          {
***************
*** 290,298 ****
  
      /**
-      * The book driver that we are providing data for
-      */
-     private SwordBookMetaData sbmd;
- 
-     /**
       * A Key that knows where the data is in the real file.
       */
--- 296,299 ----

Index: CompressionType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/CompressionType.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CompressionType.java	28 Feb 2005 02:21:40 -0000	1.5
--- CompressionType.java	4 Mar 2005 04:04:47 -0000	1.6
***************
*** 1,4 ****
--- 1,5 ----
  package org.crosswire.jsword.book.sword;
  
+ import java.io.File;
  import java.io.Serializable;
  
***************
*** 41,48 ****
              return true;
          }
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
              BlockType blockType = BlockType.fromString(sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
!             return new GZIPBackend(path, blockType);
          }
  
--- 42,49 ----
              return true;
          }
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
              BlockType blockType = BlockType.fromString(sbmd.getProperty(ConfigEntryType.BLOCK_TYPE));
!             return new GZIPBackend(sbmd, rootPath, blockType);
          }
  
***************
*** 62,68 ****
              return false;
          }
!         protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
          {
!             return new LZSSBackend(sbmd);
          }
  
--- 63,69 ----
              return false;
          }
!         protected Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
          {
!             return new LZSSBackend(sbmd, rootPath);
          }
  
***************
*** 88,92 ****
      abstract boolean isSupported();
  
!     abstract Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException;
  
      /**
--- 89,93 ----
      abstract boolean isSupported();
  
!     abstract Backend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException;
  
      /**

Index: GZIPBackend.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/GZIPBackend.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** GZIPBackend.java	8 Sep 2004 19:55:07 -0000	1.28
--- GZIPBackend.java	4 Mar 2005 04:04:47 -0000	1.29
***************
*** 88,92 ****
   * @version $Id$
   */
! public class GZIPBackend implements Backend
  {
      private static final String SUFFIX_COMP = "v"; //$NON-NLS-1$
--- 88,92 ----
   * @version $Id$
   */
! public class GZIPBackend extends Backend
  {
      private static final String SUFFIX_COMP = "v"; //$NON-NLS-1$
***************
*** 98,103 ****
       * Simple ctor
       */
!     public GZIPBackend(String path, BlockType blockType) throws BookException
      {
          String allButLast = path + File.separator + SwordConstants.FILE_OT + '.' + blockType.getIndicator() + SUFFIX_PART1;
          idxFile[SwordConstants.TESTAMENT_OLD] = new File(allButLast + SUFFIX_INDEX);
--- 98,108 ----
       * Simple ctor
       */
!     public GZIPBackend(SwordBookMetaData sbmd, File rootPath, BlockType blockType) throws BookException
      {
+         super(sbmd, rootPath);
+ 
+         String dataPath = sbmd.getProperty(ConfigEntryType.DATA_PATH);
+         File baseurl = new File(rootPath, dataPath);
+         String path = baseurl.getAbsolutePath();
          String allButLast = path + File.separator + SwordConstants.FILE_OT + '.' + blockType.getIndicator() + SUFFIX_PART1;
          idxFile[SwordConstants.TESTAMENT_OLD] = new File(allButLast + SUFFIX_INDEX);
***************
*** 203,210 ****
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key, String charset) throws BookException
      {
          checkActive();
  
          Verse verse = KeyUtil.getVerse(key);
  
--- 208,217 ----
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key) throws BookException
      {
          checkActive();
  
+         String charset = getBookMetaData().getModuleCharset();
+ 
          Verse verse = KeyUtil.getVerse(key);
  
***************
*** 258,268 ****
                  byte[] data = SwordUtil.readRAF(textRaf[testament], blockStart, blockSize);
  
!                 // LATER(joe): implement encryption?
!                 // If the file is encrypted, then decryption yeilds the gzipped data.
!                 // Otherwise the data is gzipped.
!                 // if (data is encrypted)
!                 // {
!                 //     data = decrypt(data);
!                 // }
  
                  uncompressed = SwordUtil.uncompress(data, uncompressedSize);
--- 265,269 ----
                  byte[] data = SwordUtil.readRAF(textRaf[testament], blockStart, blockSize);
  
!                 decipher(data);
  
                  uncompressed = SwordUtil.uncompress(data, uncompressedSize);

Index: LZSSBackend.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/LZSSBackend.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** LZSSBackend.java	27 Jul 2004 21:42:33 -0000	1.11
--- LZSSBackend.java	4 Mar 2005 04:04:47 -0000	1.12
***************
*** 1,4 ****
--- 1,6 ----
  package org.crosswire.jsword.book.sword;
  
+ import java.io.File;
+ 
  import org.crosswire.common.activate.Lock;
  import org.crosswire.jsword.book.BookException;
***************
*** 29,40 ****
   * @version $Id$
   */
! public class LZSSBackend implements Backend
  {
      /**
       * Simple ctor
       */
!     public LZSSBackend(SwordBookMetaData sbmd)
      {
!         this.sbmd = sbmd;
      }
  
--- 31,42 ----
   * @version $Id$
   */
! public class LZSSBackend extends Backend
  {
      /**
       * Simple ctor
       */
!     public LZSSBackend(SwordBookMetaData sbmd, File rootPath)
      {
!         super(sbmd, rootPath);
      }
  
***************
*** 56,63 ****
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key, String charset) throws BookException
      {
          // LATER(joe): implement this
!         throw new BookException(Msg.COMPRESSION_UNSUPPORTED, new Object[] { sbmd.toString() });
      }
  
--- 58,65 ----
       * @see org.crosswire.jsword.book.sword.Backend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
       */
!     public String getRawText(Key key) throws BookException
      {
          // LATER(joe): implement this
!         throw new BookException(Msg.COMPRESSION_UNSUPPORTED, new Object[] { getBookMetaData().getName() });
      }
  
***************
*** 78,82 ****
          return false;
      }
- 
-     private SwordBookMetaData sbmd;
  }
--- 80,82 ----



More information about the jsword-svn mailing list