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

dmsmith at crosswire.org dmsmith at crosswire.org
Tue Aug 1 17:55:56 MST 2006


Author: dmsmith
Date: 2006-08-01 17:55:48 -0700 (Tue, 01 Aug 2006)
New Revision: 1115

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
Log:
cleanup of checkstyle problem reports

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java	2006-08-01 13:34:41 UTC (rev 1114)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java	2006-08-02 00:55:48 UTC (rev 1115)
@@ -38,7 +38,6 @@
 import org.crosswire.common.util.StringUtil;
 import org.crosswire.jsword.book.BookCategory;
 import org.crosswire.jsword.book.BookException;
-import org.crosswire.jsword.book.BookMetaData;
 import org.crosswire.jsword.book.DataPolice;
 import org.crosswire.jsword.passage.DefaultKeyList;
 import org.crosswire.jsword.passage.DefaultLeafKeyList;

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java	2006-08-01 13:34:41 UTC (rev 1114)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java	2006-08-02 00:55:48 UTC (rev 1115)
@@ -138,7 +138,7 @@
     }
 
     /**
-     * Uncompress a block of GZIP compressed data
+     * Uncompress a block of (G)ZIP compressed data
      * @param compressed The data to uncompress
      * @param endsize The expected resultant data size
      * @return The uncompressed data
@@ -160,21 +160,22 @@
 
         return uncompressed;
     }
+
     /**
-     * Uncompress a block of GZIP compressed data
+     * Uncompress a block of (G)ZIP compressed data,
+     * when the resulting size is not known.
+     * 
      * @param compressed The data to uncompress
-     * @param endsize The expected resultant data size
      * @return The uncompressed data
      * @throws IOException 
      */
     public static byte[] uncompress(byte[] compressed) throws IOException
     {
-        final int BUFFER = 2048;
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        BufferedOutputStream out = new BufferedOutputStream(bos, BUFFER);
+        BufferedOutputStream out = new BufferedOutputStream(bos, ZBUF_SIZE);
         ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
-        InflaterInputStream in = new InflaterInputStream(bis, new Inflater(), BUFFER);
-        byte[] buf = new byte[BUFFER];
+        InflaterInputStream in = new InflaterInputStream(bis, new Inflater(), ZBUF_SIZE);
+        byte[] buf = new byte[ZBUF_SIZE];
         int count;
         while ((count = in.read(buf)) != -1)
         {
@@ -240,4 +241,9 @@
      * The log stream
      */
     private static final Logger log = Logger.getLogger(SwordUtil.class);
+
+    /**
+     * The size to read/write when unzipping a compressed byte array of unknown size.
+     */
+    final static int ZBUF_SIZE = 2048;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2006-08-01 13:34:41 UTC (rev 1114)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java	2006-08-02 00:55:48 UTC (rev 1115)
@@ -22,7 +22,6 @@
 package org.crosswire.jsword.book.sword;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.text.DateFormat;
@@ -39,9 +38,7 @@
 import org.crosswire.common.util.StringUtil;
 import org.crosswire.jsword.book.BookCategory;
 import org.crosswire.jsword.book.BookException;
-import org.crosswire.jsword.book.BookMetaData;
 import org.crosswire.jsword.book.DataPolice;
-import org.crosswire.jsword.book.sword.RawLDBackend.IndexKey;
 import org.crosswire.jsword.passage.DefaultKeyList;
 import org.crosswire.jsword.passage.DefaultLeafKeyList;
 import org.crosswire.jsword.passage.Key;
@@ -84,7 +81,7 @@
      * The compressed index.
      */
     private File zdxFile;
- 
+
     /**
      * The compressed text.
      */
@@ -97,8 +94,8 @@
     private boolean active;
     private Key keys;
     private int lastBlockNum = -1;
-    private static final byte[] emptyBytes = new byte[0];
-    private byte[] lastUncompressed = emptyBytes;
+    private static final byte[] EMPTY_BYTES = new byte[0];
+    private byte[] lastUncompressed = EMPTY_BYTES;
 
     /**
      * Simple ctor
@@ -337,9 +334,9 @@
                 int blockSize = SwordUtil.decodeLittleEndian32(temp, 4);
 
                 temp = SwordUtil.readRAF(zdtRaf, blockStart, blockSize);
-                
+
                 decipher(temp);
-                
+
                 uncompressed = SwordUtil.uncompress(temp);
 
                 // cache the uncompressed data for next time
@@ -353,13 +350,13 @@
             {
                 return ""; //$NON-NLS-1$
             }
-            int entryOffset = BLOCK_ENTRY_COUNT + (BLOCK_ENTRY_SIZE*entry);
+            int entryOffset = BLOCK_ENTRY_COUNT + (BLOCK_ENTRY_SIZE * entry);
             int entryStart = SwordUtil.decodeLittleEndian32(uncompressed, entryOffset);
             // Note: the actual entry is '\0' terminated
             int entrySize = SwordUtil.decodeLittleEndian32(uncompressed, entryOffset + 4);
             byte[] entryBytes = new byte[entrySize];
             System.arraycopy(uncompressed, entryStart, entryBytes, 0, entrySize);
-            
+
             String ret = SwordUtil.decode(key, entryBytes, charset).trim();
             return ret;
         }



More information about the jsword-svn mailing list