tigase.util

## Class ZLibWrapper

- java.lang.Object
- - tigase.util.ZLibWrapper

-     public class ZLibWrapper
      extends Object

  This is a warpper for java.util.zip package and Deflater/Inflater classes specifically. This implementation allows for easy interaction between Deflater/Inflater and java.nio API which operates on ByteBuffer data. It also does some tricky stuff to flush Deflater without reseting it and allow a better compression ration on the data.

  There are a few convenience methods allowing to directly compress String to ByteBuffer and other way around - from ByteBuffer to String decompression. For these methods data are assumed to be UTF-8 character String.

  Created: Jul 30, 2009 11:46:55 AM
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `COMPRESSED_BUFF_SIZE` Field description
    `static int` | `DECOMPRESSED_BUFF_SIZE` Field description

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ZLibWrapper()` Constructs ...
    `ZLibWrapper(int level)` Constructs ...
    `ZLibWrapper(int level, int comp_buff_size)` Constructs ...

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `float` | `averageCompressionRate()` Method description
    `float` | `averageDecompressionRate()` Method description
    `ByteBuffer` | `compress(ByteBuffer input)`
    `ByteBuffer` | `compress(String input)` Method description
    `ByteBuffer` | `decompress(ByteBuffer input)` Method description
    `String` | `decompressToString(ByteBuffer input)` Method description
    `void` | `end()` Method description
    `float` | `lastCompressionRate()` Method description
    `float` | `lastDecompressionRate()` Method description
    `static void` | `main(String[] args)` Method description
    `void` | `setIOListener(IOListener listener)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### COMPRESSED_BUFF_SIZE

          public static final int COMPRESSED_BUFF_SIZE

      Field description
      See Also:
        Constant Field Values

    - #### DECOMPRESSED_BUFF_SIZE

          public static final int DECOMPRESSED_BUFF_SIZE

      Field description
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ZLibWrapper

          public ZLibWrapper()

      Constructs ...

    - #### ZLibWrapper

          public ZLibWrapper(int level)

      Constructs ...
      Parameters:
        `level` -

    - #### ZLibWrapper

          public ZLibWrapper(int level,
                             int comp_buff_size)

      Constructs ...
      Parameters:
        `level` -
        `comp_buff_size` -

  - ### Method Detail

    - #### main

          public static void main(String[] args)
                           throws Exception

      Method description
      Parameters:
        `args` -
      Throws:
        `Exception`

    - #### averageCompressionRate

          public float averageCompressionRate()

      Method description
      Returns:

    - #### averageDecompressionRate

          public float averageDecompressionRate()

      Method description
      Returns:

    - #### compress

          public ByteBuffer compress(ByteBuffer input)

      Parameters:
        `input` -
      Returns:

    - #### compress

          public ByteBuffer compress(String input)
                              throws CharacterCodingException

      Method description
      Parameters:
        `input` -
      Returns:
      Throws:
        `CharacterCodingException`

    - #### decompress

          public ByteBuffer decompress(ByteBuffer input)
                                throws IOException

      Method description
      Parameters:
        `input` -
      Returns:
      Throws:
        `IOException`

    - #### decompressToString

          public String decompressToString(ByteBuffer input)
                                    throws CharacterCodingException,
                                           IOException

      Method description
      Parameters:
        `input` -
      Returns:
      Throws:
        `CharacterCodingException`
        `IOException`

    - #### end

          public void end()

      Method description

    - #### lastCompressionRate

          public float lastCompressionRate()

      Method description
      Returns:

    - #### lastDecompressionRate

          public float lastDecompressionRate()

      Method description
      Returns:

    - #### setIOListener

          public void setIOListener(IOListener listener)

Copyright © 2022 "Tigase, Inc.". All rights reserved.