public class

GZIPHelper

extends Object
java.lang.Object
   ↳ com.microstrategy.utils.GZIPHelper

Class Overview

GZIPHelper is a utility class to compress/decompress data using GZIP alorithm (aka LZ77 algorithm). It also provide functions to encode the result of compression into a String or decode it into a byte array using Base64 algorithm.

Summary

Constants
int ESTIMATE_XML_STATUS_COMPRESS_RATIO The estimate compress ratio for XML status.
int ESTIMATE_XML_STATUS_COMPRESS_RATIO_DELTA The estimate variation value of the compression ration.
String MAGIC_HEADER The magic header for Ziped and Base64ed string.
Public Constructors
GZIPHelper()
Public Methods
String base64AndDecompress(String fromString, int estimateRatio)
De-transform a String data using Base64 algorithm and then de-compress the result into another String.
void compress(OutputStream toStream, String fromString, int estimateRatio)
Compress data from a String to an OutputStream.
byte[] compress(String fromString, int estimateRatio)
Compress data from an String and returns a byte array for the result.
String compressAndBase64(String fromString, int estimateRatio)
Compress a String data and then transform the result into another String using Base64 algorithm.
String decompress(InputStream fromStream, int bufferSize)
De-compress data from an InputStream and returns the result as a String.
String decompress(byte[] fromData, int estimateRatio)
De-compress a byte array of data and returns the result as a String.
static GZIPHelper getInstance()
Sigleton entry.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ESTIMATE_XML_STATUS_COMPRESS_RATIO

The estimate compress ratio for XML status.

Constant Value: 10 (0x0000000a)

public static final int ESTIMATE_XML_STATUS_COMPRESS_RATIO_DELTA

The estimate variation value of the compression ration.

Constant Value: 6 (0x00000006)

public static final String MAGIC_HEADER

The magic header for Ziped and Base64ed string.

Constant Value: "H4sI"

Public Constructors

public GZIPHelper ()

Public Methods

public String base64AndDecompress (String fromString, int estimateRatio)

De-transform a String data using Base64 algorithm and then de-compress the result into another String. It is the reverse process of compressAndBase64(String, int) method.

Parameters
fromString The String data to be transformed and de-compressed.
estimateRatio The estimated ratio of the compression operation.
Returns
  • a String data holding the result of de-transformation and de-compression.

public void compress (OutputStream toStream, String fromString, int estimateRatio)

Compress data from a String to an OutputStream.

Parameters
toStream The target OutputStream.
fromString The String data to be compressed.
estimateRatio The estimated ratio of this compression operation.

public byte[] compress (String fromString, int estimateRatio)

Compress data from an String and returns a byte array for the result.

Parameters
fromString The String data to be compressed.
estimateRatio The estimated ratio of this compression operation.
Returns
  • a byte array holding the compressed result.

public String compressAndBase64 (String fromString, int estimateRatio)

Compress a String data and then transform the result into another String using Base64 algorithm.

Parameters
fromString The String data to be compressed and transformed.
estimateRatio The estimated ratio of the compression operation.
Returns
  • a String holding the result of compression and transformation.

public String decompress (InputStream fromStream, int bufferSize)

De-compress data from an InputStream and returns the result as a String.

Parameters
fromStream The InputStream to be de-compressed.
bufferSize The estimate size of the StringBuffer to be allocated to hold the result.
Returns
  • a String holding the result of de-compression.

public String decompress (byte[] fromData, int estimateRatio)

De-compress a byte array of data and returns the result as a String.

Parameters
fromData The byte array of data to be de-compressed.
estimateRatio The estimated ratio of the compression operation.
Returns
  • a String holding the result of de-compression.

public static GZIPHelper getInstance ()

Sigleton entry.

Returns
  • GZIPHelper The GZIPHelper instance.