[jsword-svn] r1356 - trunk/common/src/main/java/org/crosswire/common/compress

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Tue May 29 14:21:19 MST 2007


Author: dmsmith
Date: 2007-05-29 14:21:19 -0700 (Tue, 29 May 2007)
New Revision: 1356

Modified:
   trunk/common/src/main/java/org/crosswire/common/compress/LZSS.java
Log:
more lzss changes, making it more like gzip's interface.

Modified: trunk/common/src/main/java/org/crosswire/common/compress/LZSS.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/compress/LZSS.java	2007-05-29 21:10:51 UTC (rev 1355)
+++ trunk/common/src/main/java/org/crosswire/common/compress/LZSS.java	2007-05-29 21:21:19 UTC (rev 1356)
@@ -84,16 +84,22 @@
  */
 public class LZSS
 {
-    public LZSS()
+    /**
+     * Create an LZSS that is capable of transforming the input.
+     * 
+     * @param input to compress or uncompress.
+     */
+    public LZSS(byte[] input)
     {
+        readBuffer = input;
     }
 
     /**
      * Encodes the input stream into the output stream.
-     * The GetChars() and SendChars() functions are used to separate
-     * this method from the actual i/o.
+     * 
+     * @return the encoded result
      */
-   public void encode()
+   public byte[] encode()
    {
        short i;                        // an iterator
        int r;                          // node number in the binary tree
@@ -152,7 +158,7 @@
        // Make sure there is something to be compressed.
        if (len == 0)
        {
-           return;
+           return new byte[0];
        }
 
        // Insert the MAX_STORE_LENGTH strings, each of which begins with one or more
@@ -312,14 +318,16 @@
            // code_buf_ptr is the number of characters.
            sendBytes(codeBuff, codeBufPos);
        }
+
+       return writeBuffer;
    }
 
    /**
     * Decode the input stream into the output stream.
-    * The GetChars() and SendChars() functions are used to separate
-    * this method from the actual i/o.
+    * 
+    * @return the decoded result
     */
-   public void decode()
+   public byte[] decode()
    {
        byte[] c = new byte[MAX_STORE_LENGTH];     // an array of chars
        byte flags;                               // 8 bits of flags
@@ -433,6 +441,7 @@
                }
            }
        }
+       return writeBuffer;
    }
 
    /**




More information about the jsword-svn mailing list