Class FlateCodec

java.lang.Object
com.helger.base.codec.impl.FlateCodec
All Implemented Interfaces:
IByteArrayCodec, IByteArrayDecoder, IByteArrayEncoder, IByteArrayStreamDecoder, IByteArrayStreamEncoder, ICodec<byte[]>, IDecoder<byte[],byte[]>, IEncoder<byte[],byte[]>

public class FlateCodec extends Object implements IByteArrayCodec
Encoder and decoder for flate compression
Author:
Philip Helger
  • Constructor Details

    • FlateCodec

      public FlateCodec()
      Constructor.
  • Method Details

    • isZlibHead

      public static boolean isZlibHead(byte @NonNull [] buf, @Nonnegative int nOfs, @Nonnegative int nLen)
      Check if the passed byte buffer starts with a valid zlib header.
      Parameters:
      buf - The byte buffer to check. May not be null.
      nOfs - The offset to start checking from.
      nLen - The number of available bytes.
      Returns:
      true if the buffer starts with a valid zlib header, false otherwise.
    • decode

      public void decode(byte @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull OutputStream aOS)
      Decode the passed flate compressed buffer and write the decoded bytes to the output stream.
      Specified by:
      decode in interface IByteArrayStreamDecoder
      Parameters:
      aEncodedBuffer - The flate compressed buffer to be decoded. May be null.
      nOfs - The offset in the buffer to start decoding from.
      nLen - The number of bytes to decode.
      aOS - The output stream to write the decoded data to. May not be null.
    • encode

      public void encode(byte @Nullable [] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull OutputStream aOS)
      Encode the passed buffer using flate compression and write it to the output stream.
      Specified by:
      encode in interface IByteArrayStreamEncoder
      Parameters:
      aDecodedBuffer - The buffer to be encoded. May be null.
      nOfs - The offset in the buffer to start encoding from.
      nLen - The number of bytes to encode.
      aOS - The output stream to write the encoded data to. May not be null.