diff options
Diffstat (limited to 'src/com/isode/stroke/compress/ZLibCompressor.java')
-rw-r--r-- | src/com/isode/stroke/compress/ZLibCompressor.java | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/com/isode/stroke/compress/ZLibCompressor.java b/src/com/isode/stroke/compress/ZLibCompressor.java index f5276c8..de22bee 100644 --- a/src/com/isode/stroke/compress/ZLibCompressor.java +++ b/src/com/isode/stroke/compress/ZLibCompressor.java @@ -1,33 +1,27 @@ /* + * Copyright (c) 2010 Remko Tron¨on + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ +/* * Copyright (c) 2011, Isode Limited, London, England. * All rights reserved. */ package com.isode.stroke.compress; -import com.isode.stroke.base.ByteArray; -import java.util.zip.Deflater; +import com.jcraft.jzlib.JZlib; -/** - * - * @author Kev - */ -public class ZLibCompressor { +public class ZLibCompressor extends ZLibCodecompressor { private static final int COMPRESSION_LEVEL = 9; + + + public ZLibCompressor() { + int result = stream_.deflateInit(COMPRESSION_LEVEL); + assert (result == JZlib.Z_OK); + } - public ByteArray process(ByteArray data) throws ZLibException { - Deflater compressor = new Deflater(COMPRESSION_LEVEL); - compressor.setStrategy(Deflater.DEFAULT_STRATEGY); - compressor.setInput(data.getData()); - compressor.finish(); - byte[] output = new byte[100]; - ByteArray result = new ByteArray(); - while (!compressor.finished()) { - int size = compressor.deflate(output); - for (int i = 0; i < size; i++) { - result.append(output[i]); /* TODO: Terribly slow */ - } - } - return result; + protected int processZStream() { + return stream_.deflate(JZlib.Z_SYNC_FLUSH); } } |