[jsword-svn] r1596 - trunk/jsword/src/main/java/org/crosswire/jsword/book/sword

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Tue Jul 31 17:26:47 MST 2007


Author: dmsmith
Date: 2007-07-31 17:26:46 -0700 (Tue, 31 Jul 2007)
New Revision: 1596

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
Log:
Submission from Doug Rintoul providing a larger "chapter" size to commentaries.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java	2007-07-31 22:21:59 UTC (rev 1595)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/BookType.java	2007-08-01 00:26:46 UTC (rev 1596)
@@ -49,7 +49,7 @@
 
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException
         {
-            return new RawBackend(sbmd);
+            return new RawBackend(sbmd, 2);
         }
 
         /**
@@ -92,7 +92,7 @@
 
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException
         {
-            return new RawBackend(sbmd);
+            return new RawBackend(sbmd, 2);
         }
 
         /**
@@ -101,6 +101,23 @@
         private static final long serialVersionUID = 3258129141898294837L;
     };
 
+    public static final BookType RAW_COM4 = new BookType("RawCom4", BookCategory.COMMENTARY) //$NON-NLS-1$
+    {
+        protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend)
+        {
+            return new SwordBook(sbmd, backend);
+        }
+
+        protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException
+        {
+            return new RawBackend(sbmd, 4);
+        }
+
+        /**
+         * Serialization ID
+         */
+        private static final long serialVersionUID = 3258129141898294838L;
+    };
     /**
      * Compressed Commentaries
      */
@@ -135,7 +152,7 @@
 
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException
         {
-            return new RawBackend(sbmd);
+            return new RawBackend(sbmd, 2);
         }
 
         /**
@@ -156,7 +173,7 @@
 
         protected AbstractBackend getBackend(SwordBookMetaData sbmd) throws BookException
         {
-            return new RawBackend(sbmd);
+            return new RawBackend(sbmd, 2);
         }
 
         /**
@@ -394,6 +411,7 @@
         RAW_TEXT,
         Z_TEXT,
         RAW_COM,
+        RAW_COM4,
         Z_COM,
         RAW_COM,
         HREF_COM,

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java	2007-07-31 22:21:59 UTC (rev 1595)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryType.java	2007-08-01 00:26:46 UTC (rev 1596)
@@ -937,6 +937,7 @@
             "RawText",  //$NON-NLS-1$
             "zText",  //$NON-NLS-1$
             "RawCom", //$NON-NLS-1$
+            "RawCom4", //$NON-NLS-1$
             "zCom", //$NON-NLS-1$
             "HREFCom", //$NON-NLS-1$
             "RawFiles", //$NON-NLS-1$

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java	2007-07-31 22:21:59 UTC (rev 1595)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java	2007-08-01 00:26:46 UTC (rev 1596)
@@ -48,10 +48,16 @@
     /**
      * Simple ctor
      */
-    public RawBackend(SwordBookMetaData sbmd) throws BookException
+    public RawBackend(SwordBookMetaData sbmd, int datasize) throws BookException
     {
         super(sbmd);
+        this.datasize = datasize;
 
+        if (datasize != 2 && datasize != 4)
+        {
+            throw new BookException(Msg.TYPE_UNKNOWN);
+        }
+
         String path = getExpandedDataPath();
 
         idxFile[SwordConstants.TESTAMENT_OLD] = new File(path + File.separator + SwordConstants.FILE_OT + SwordConstants.EXTENSION_VSS);
@@ -158,8 +164,10 @@
                 return ""; //$NON-NLS-1$
             }
 
-            // Read the next ENTRY_SIZE byes.
-            byte[] read = SwordUtil.readRAF(idxRaf[testament], index * ENTRY_SIZE, ENTRY_SIZE);
+            int entrysize = datasize + OFFSETSIZE;
+            
+            // Read the next entrysize byes.
+            byte[] read = SwordUtil.readRAF(idxRaf[testament], index * entrysize, entrysize);
             if (read == null || read.length == 0)
             {
                 return ""; //$NON-NLS-1$
@@ -167,7 +175,18 @@
 
             // The data is little endian - extract the start and size
             long start = SwordUtil.decodeLittleEndian32(read, 0);
-            int size = SwordUtil.decodeLittleEndian16(read, 4);
+            int size = -1;
+            switch (datasize)
+            {
+            case 2:
+                size = SwordUtil.decodeLittleEndian16(read, 4);
+                break;
+            case 4:
+                size = SwordUtil.decodeLittleEndian32(read, 4);
+                break;
+            default:
+                assert false : datasize;
+            }
 
             if (size < 0)
             {
@@ -241,7 +260,12 @@
     private File[] txtFile = new File[3];
 
     /**
-     * How many bytes in an index?
+     * How many bytes in the offset pointers in the index
      */
-    private static final int ENTRY_SIZE = 6;
+    private static final int OFFSETSIZE = 4;
+
+    /**
+     * How many bytes in the size count in the index
+     */
+    private int datasize = -1;   
 }




More information about the jsword-svn mailing list