diff --git a/src/java/net/jpountz/lz4/LZ4BlockInputStream.java b/src/java/net/jpountz/lz4/LZ4BlockInputStream.java
index 23fd5e34..eff16421 100644
--- a/src/java/net/jpountz/lz4/LZ4BlockInputStream.java
+++ b/src/java/net/jpountz/lz4/LZ4BlockInputStream.java
@@ -43,7 +43,8 @@
*/
public class LZ4BlockInputStream extends FilterInputStream {
- private final LZ4FastDecompressor decompressor;
+ private final LZ4FastDecompressor fastDecompressor;
+ private final LZ4SafeDecompressor safeDecompressor;
private final Checksum checksum;
private final boolean stopOnEmptyBlock;
private byte[] buffer;
@@ -56,52 +57,51 @@ public class LZ4BlockInputStream extends FilterInputStream {
* Creates a new LZ4 input stream to read from the specified underlying InputStream.
*
* @param in the {@link InputStream} to poll
- * @param decompressor the {@link LZ4FastDecompressor decompressor} instance to
+ * @param fastDecompressor the {@link LZ4FastDecompressor} instance to
* use
* @param checksum the {@link Checksum} instance to use, must be
* equivalent to the instance which has been used to
* write the stream
* @param stopOnEmptyBlock whether read is stopped on an empty block
+ * @deprecated Use {@link #newBuilder()} instead.
*/
- public LZ4BlockInputStream(InputStream in, LZ4FastDecompressor decompressor, Checksum checksum, boolean stopOnEmptyBlock) {
- super(in);
- this.decompressor = decompressor;
- this.checksum = checksum;
- this.stopOnEmptyBlock = stopOnEmptyBlock;
- this.buffer = new byte[0];
- this.compressedBuffer = new byte[HEADER_LENGTH];
- o = originalLen = 0;
- finished = false;
+ @Deprecated
+ public LZ4BlockInputStream(InputStream in, LZ4FastDecompressor fastDecompressor, Checksum checksum, boolean stopOnEmptyBlock) {
+ this(in, fastDecompressor, null, checksum, stopOnEmptyBlock);
}
/**
* Creates a new LZ4 input stream to read from the specified underlying InputStream.
*
* @param in the {@link InputStream} to poll
- * @param decompressor the {@link LZ4FastDecompressor decompressor} instance to
+ * @param fastDecompressor the {@link LZ4FastDecompressor} instance to
* use
* @param checksum the {@link Checksum} instance to use, must be
* equivalent to the instance which has been used to
* write the stream
*
* @see #LZ4BlockInputStream(InputStream, LZ4FastDecompressor, Checksum, boolean)
+ * @deprecated Use {@link #newBuilder()} instead.
*/
- public LZ4BlockInputStream(InputStream in, LZ4FastDecompressor decompressor, Checksum checksum) {
- this(in, decompressor, checksum, true);
+ @Deprecated
+ public LZ4BlockInputStream(InputStream in, LZ4FastDecompressor fastDecompressor, Checksum checksum) {
+ this(in, fastDecompressor, checksum, true);
}
/**
* Creates a new LZ4 input stream to read from the specified underlying InputStream, using {@link XXHash32} for checksuming.
*
* @param in the {@link InputStream} to poll
- * @param decompressor the {@link LZ4FastDecompressor decompressor} instance to
+ * @param fastDecompressor the {@link LZ4FastDecompressor} instance to
* use
*
* @see #LZ4BlockInputStream(InputStream, LZ4FastDecompressor, Checksum, boolean)
* @see StreamingXXHash32#asChecksum()
+ * @deprecated Use {@link #newBuilder()} instead.
*/
- public LZ4BlockInputStream(InputStream in, LZ4FastDecompressor decompressor) {
- this(in, decompressor, XXHashFactory.fastestInstance().newStreamingHash32(DEFAULT_SEED).asChecksum(), true);
+ @Deprecated
+ public LZ4BlockInputStream(InputStream in, LZ4FastDecompressor fastDecompressor) {
+ this(in, fastDecompressor, XXHashFactory.fastestInstance().newStreamingHash32(DEFAULT_SEED).asChecksum(), true);
}
/**
@@ -113,7 +113,9 @@ public LZ4BlockInputStream(InputStream in, LZ4FastDecompressor decompressor) {
* @see #LZ4BlockInputStream(InputStream, LZ4FastDecompressor, Checksum, boolean)
* @see LZ4Factory#fastestInstance()
* @see StreamingXXHash32#asChecksum()
+ * @deprecated Use {@link #newBuilder()} instead.
*/
+ @Deprecated
public LZ4BlockInputStream(InputStream in, boolean stopOnEmptyBlock) {
this(in, LZ4Factory.fastestInstance().fastDecompressor(), XXHashFactory.fastestInstance().newStreamingHash32(DEFAULT_SEED).asChecksum(), stopOnEmptyBlock);
}
@@ -125,11 +127,54 @@ public LZ4BlockInputStream(InputStream in, boolean stopOnEmptyBlock) {
*
* @see #LZ4BlockInputStream(InputStream, LZ4FastDecompressor)
* @see LZ4Factory#fastestInstance()
+ * @deprecated Use {@link #newBuilder()} instead.
*/
+ @Deprecated
public LZ4BlockInputStream(InputStream in) {
this(in, LZ4Factory.fastestInstance().fastDecompressor());
}
+ /**
+ * Creates a new LZ4 input stream to read from the specified underlying InputStream.
+ *
+ * @param in the {@link InputStream} to poll
+ * @param fastDecompressor the {@link LZ4FastDecompressor} instance to
+ * use
+ * @param safeDecompressor the {@link LZ4SafeDecompressor} instance to
+ * use (if both fastDecompressor and safeDecompressor are
+ * specified then the fastDecompressor gets used)
+ * @param checksum the {@link Checksum} instance to use, must be
+ * equivalent to the instance which has been used to
+ * write the stream
+ * @param stopOnEmptyBlock whether read is stopped on an empty block
+ */
+ private LZ4BlockInputStream(InputStream in, LZ4FastDecompressor fastDecompressor, LZ4SafeDecompressor safeDecompressor,
+ Checksum checksum, boolean stopOnEmptyBlock) {
+ super(in);
+
+ this.fastDecompressor = fastDecompressor;
+ this.safeDecompressor = safeDecompressor;
+ this.checksum = checksum;
+ this.stopOnEmptyBlock = stopOnEmptyBlock;
+ this.buffer = new byte[0];
+ this.compressedBuffer = new byte[HEADER_LENGTH];
+ o = originalLen = 0;
+ finished = false;
+ }
+
+ /**
+ * Creates a new LZ4 block input stream builder. The following are defaults:
+ *