org.mule.util.compression
Class GZipCompression

java.lang.Object
  extended by org.mule.util.compression.GZipCompression
All Implemented Interfaces:
CompressionStrategy

public class GZipCompression
extends Object
implements CompressionStrategy

GZipCompression is a CompressionStrategy implementation using the GZip library included in the JDK java.util.zip. This is the default CompressionStrategy used by the CompressionHelper discovery when no other implementation is discovered.


Field Summary
static int DEFAULT_BUFFER_SIZE
           
 
Fields inherited from interface org.mule.util.compression.CompressionStrategy
COMPRESSION_DEFAULT, SERVICE_ID
 
Constructor Summary
GZipCompression()
           
 
Method Summary
 byte[] compressByteArray(byte[] bytes)
          Used for compressing a byte array into a new byte array using GZIP
 InputStream compressInputStream(InputStream is)
          Compresses an InputStream.
 boolean isCompressed(byte[] bytes)
          Determines if a byte array is compressed.
 byte[] uncompressByteArray(byte[] bytes)
          Used for uncompressing a byte array into a uncompressed byte array using GZIP
 InputStream uncompressInputStream(InputStream is)
          Uncompresses a compressed InputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

GZipCompression

public GZipCompression()
Method Detail

isCompressed

public boolean isCompressed(byte[] bytes)
                     throws IOException
Determines if a byte array is compressed. The java.util.zip GZip implementaiton does not expose the GZip header so it is difficult to determine if a string is compressed.

Specified by:
isCompressed in interface CompressionStrategy
Parameters:
bytes - an array of bytes
Returns:
true if the array is compressed or false otherwise
Throws:
IOException - if the byte array couldn't be read

compressByteArray

public byte[] compressByteArray(byte[] bytes)
                         throws IOException
Used for compressing a byte array into a new byte array using GZIP

Specified by:
compressByteArray in interface CompressionStrategy
Parameters:
bytes - An array of bytes to compress
Returns:
a compressed byte array
Throws:
IOException - if it fails to write to a GZIPOutputStream
See Also:
GZIPOutputStream

compressInputStream

public InputStream compressInputStream(InputStream is)
                                throws IOException
Description copied from interface: CompressionStrategy
Compresses an InputStream.

Specified by:
compressInputStream in interface CompressionStrategy
Parameters:
is - The InputStream to compress.
Returns:
The compressed InputStream.
Throws:
IOException - If an I/O error has occurred.

uncompressByteArray

public byte[] uncompressByteArray(byte[] bytes)
                           throws IOException
Used for uncompressing a byte array into a uncompressed byte array using GZIP

Specified by:
uncompressByteArray in interface CompressionStrategy
Parameters:
bytes - An array of bytes to uncompress
Returns:
an uncompressed byte array
Throws:
IOException - if it fails to read from a GZIPInputStream
See Also:
GZIPInputStream

uncompressInputStream

public InputStream uncompressInputStream(InputStream is)
                                  throws IOException
Description copied from interface: CompressionStrategy
Uncompresses a compressed InputStream.

Specified by:
uncompressInputStream in interface CompressionStrategy
Parameters:
is - The compressed InputStream.
Returns:
The uncompressed InputStream.
Throws:
IOException - If an I/O error has occurred.


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.