org.h2.tools
Class CompressTool

java.lang.Object
  extended by org.h2.tools.CompressTool

public class CompressTool
extends java.lang.Object

A tool to losslessly compress data, and expand the compressed data again.


Method Summary
 int compress(byte[] in, int len, Compressor compress, byte[] out)
          INTERNAL
 byte[] compress(byte[] in, java.lang.String algorithm)
          Compressed the data using the specified algorithm.
 byte[] expand(byte[] in)
          Expands the compressed data.
 void expand(byte[] in, byte[] out, int outPos)
          INTERNAL
 int getCompressAlgorithm(java.lang.String algorithm)
          INTERNAL
static CompressTool getInstance()
          Get a new instance.
static java.io.InputStream wrapInputStream(java.io.InputStream in, java.lang.String compressionAlgorithm, java.lang.String entryName)
          INTERNAL
static java.io.OutputStream wrapOutputStream(java.io.OutputStream out, java.lang.String compressionAlgorithm, java.lang.String entryName)
          INTERNAL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CompressTool getInstance()
Get a new instance. Each instance uses a separate buffer, so multiple instances can be used concurrently. However each instance alone is not multithreading safe.

Returns:
a new instance

compress

public byte[] compress(byte[] in,
                       java.lang.String algorithm)
Compressed the data using the specified algorithm. If no algorithm is supplied, LZF is used

Parameters:
in - the byte array with the original data
algorithm - the algorithm (LZF, DEFLATE)
Returns:
the compressed data
Throws:
SQLException - if a error occurs

compress

public int compress(byte[] in,
                    int len,
                    Compressor compress,
                    byte[] out)
INTERNAL


expand

public byte[] expand(byte[] in)
Expands the compressed data.

Parameters:
in - the byte array with the compressed data
Returns:
the uncompressed data
Throws:
SQLException - if a error occurs

expand

public void expand(byte[] in,
                   byte[] out,
                   int outPos)
INTERNAL


getCompressAlgorithm

public int getCompressAlgorithm(java.lang.String algorithm)
INTERNAL


wrapOutputStream

public static java.io.OutputStream wrapOutputStream(java.io.OutputStream out,
                                                    java.lang.String compressionAlgorithm,
                                                    java.lang.String entryName)
INTERNAL


wrapInputStream

public static java.io.InputStream wrapInputStream(java.io.InputStream in,
                                                  java.lang.String compressionAlgorithm,
                                                  java.lang.String entryName)
INTERNAL