/** * Sets the dictionary to be used for compression by this {@code Deflater}. * This method can only be called if this {@code Deflater} supports the writing * of ZLIB headers. This is the default, but can be overridden * using {@link #Deflater(int, boolean)}. */ public void setDictionary(byte[] dictionary) { setDictionary(dictionary, 0, dictionary.length); }
/** * Creates a new zlib encoder with the specified {@code compressionLevel} * and the specified preset dictionary. The wrapper is always * {@link ZlibWrapper#ZLIB} because it is the only format that supports * the preset dictionary. * * @param compressionLevel * {@code 1} yields the fastest compression and {@code 9} yields the * best compression. {@code 0} means no compression. The default * compression level is {@code 6}. * @param dictionary the preset dictionary * * @throws CompressionException if failed to initialize zlib */ public JdkZlibEncoder(int compressionLevel, byte[] dictionary) { if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } if (dictionary == null) { throw new NullPointerException("dictionary"); } wrapper = ZlibWrapper.ZLIB; deflater = new Deflater(compressionLevel); deflater.setDictionary(dictionary); }
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
/** * Creates a new zlib encoder with the specified {@code compressionLevel} * and the specified preset dictionary. The wrapper is always * {@link ZlibWrapper#ZLIB} because it is the only format that supports * the preset dictionary. * * @param compressionLevel * {@code 1} yields the fastest compression and {@code 9} yields the * best compression. {@code 0} means no compression. The default * compression level is {@code 6}. * @param dictionary the preset dictionary * * @throws CompressionException if failed to initialize zlib */ public JdkZlibEncoder(int compressionLevel, byte[] dictionary) { if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } if (dictionary == null) { throw new NullPointerException("dictionary"); } wrapper = ZlibWrapper.ZLIB; deflater = new Deflater(compressionLevel); deflater.setDictionary(dictionary); }
/** * Creates a new zlib encoder with the specified {@code compressionLevel} * and the specified preset dictionary. The wrapper is always * {@link ZlibWrapper#ZLIB} because it is the only format that supports * the preset dictionary. * * @param compressionLevel * {@code 1} yields the fastest compression and {@code 9} yields the * best compression. {@code 0} means no compression. The default * compression level is {@code 6}. * @param dictionary the preset dictionary * * @throws CompressionException if failed to initialize zlib */ public JdkZlibEncoder(int compressionLevel, byte[] dictionary) { if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } if (dictionary == null) { throw new NullPointerException("dictionary"); } wrapper = ZlibWrapper.ZLIB; deflater = new Deflater(compressionLevel); deflater.setDictionary(dictionary); }
/** * Creates a new zlib encoder with the specified {@code compressionLevel} * and the specified preset dictionary. The wrapper is always * {@link ZlibWrapper#ZLIB} because it is the only format that supports * the preset dictionary. * * @param compressionLevel * {@code 1} yields the fastest compression and {@code 9} yields the * best compression. {@code 0} means no compression. The default * compression level is {@code 6}. * @param dictionary the preset dictionary * * @throws CompressionException if failed to initialize zlib */ public JdkZlibEncoder(int compressionLevel, byte[] dictionary) { if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } if (dictionary == null) { throw new NullPointerException("dictionary"); } wrapper = ZlibWrapper.ZLIB; crc = null; deflater = new Deflater(compressionLevel); deflater.setDictionary(dictionary); }
/** * Sets the dictionary to be used for compression by this {@code Deflater}. * This method can only be called if this {@code Deflater} supports the writing * of ZLIB headers. This is the default, but can be overridden * using {@link #Deflater(int, boolean)}. */ public void setDictionary(byte[] dictionary) { setDictionary(dictionary, 0, dictionary.length); }
public class MyGZIPOutputStream extends GZIPOutputStream { public MyGZIPOutputStream(final OutputStream out) throws IOException { super(out); } public void setDictionary(byte[] b) { def.setDictionary(b); } }
/** * Sets the dictionary to be used for compression by this {@code Deflater}. * This method can only be called if this {@code Deflater} supports the writing * of ZLIB headers. This is the default, but can be overridden * using {@link #Deflater(int, boolean)}. */ public void setDictionary(byte[] dictionary) { setDictionary(dictionary, 0, dictionary.length); }
@Override protected Deflater initialValue() { final Deflater def = new Deflater(compressionLevel); if (dictionary.length > 0) { def.setDictionary(dictionary); } return def; } };
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
SpdyHeaderBlockZlibEncoder(SpdyVersion spdyVersion, int compressionLevel) { super(spdyVersion); if (compressionLevel < 0 || compressionLevel > 9) { throw new IllegalArgumentException( "compressionLevel: " + compressionLevel + " (expected: 0-9)"); } compressor = new Deflater(compressionLevel); compressor.setDictionary(SPDY_DICT); }
@Override public InputStream createCompressingInputStream(final InputStream uncompressed) throws IOException { final Deflater compressor = new Deflater(compressionLevel); if (dictionary.length > 0) { compressor.setDictionary(dictionary); } return new DeflaterInputStream(uncompressed, compressor); }
Writer(BufferedSink sink, boolean client) { this.sink = sink; this.client = client; Deflater deflater = new Deflater(); deflater.setDictionary(DICTIONARY); headerBlockBuffer = new Buffer(); headerBlockOut = Okio.buffer(new DeflaterSink(headerBlockBuffer, deflater)); }
SpdyWriter(OutputStream out) { this.out = new DataOutputStream(out); Deflater deflater = new Deflater(); deflater.setDictionary(SpdyReader.DICTIONARY); nameValueBlockBuffer = new ByteArrayOutputStream(); nameValueBlockOut = new DataOutputStream( Platform.get().newDeflaterOutputStream(nameValueBlockBuffer, deflater, true)); }