// 
// Decompiled by Procyon v0.6.0
// 

package com.github.luben.zstd;

import com.github.luben.zstd.util.Native;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.io.Closeable;

public class ZstdDirectBufferDecompressingStream implements Closeable
{
    private ZstdDirectBufferDecompressingStreamNoFinalizer inner;
    private boolean finalize;
    
    protected ByteBuffer refill(final ByteBuffer byteBuffer) {
        return byteBuffer;
    }
    
    public ZstdDirectBufferDecompressingStream(final ByteBuffer byteBuffer) {
        this.finalize = true;
        this.inner = new ZstdDirectBufferDecompressingStreamNoFinalizer(byteBuffer) {
            @Override
            protected ByteBuffer refill(final ByteBuffer byteBuffer) {
                return ZstdDirectBufferDecompressingStream.this.refill(byteBuffer);
            }
        };
    }
    
    public void setFinalize(final boolean finalize) {
        this.finalize = finalize;
    }
    
    public synchronized boolean hasRemaining() {
        return this.inner.hasRemaining();
    }
    
    public static int recommendedTargetBufferSize() {
        return ZstdDirectBufferDecompressingStreamNoFinalizer.recommendedTargetBufferSize();
    }
    
    public synchronized ZstdDirectBufferDecompressingStream setDict(final byte[] dict) throws IOException {
        this.inner.setDict(dict);
        return this;
    }
    
    public synchronized ZstdDirectBufferDecompressingStream setDict(final ZstdDictDecompress dict) throws IOException {
        this.inner.setDict(dict);
        return this;
    }
    
    public ZstdDirectBufferDecompressingStream setLongMax(final int longMax) throws IOException {
        this.inner.setLongMax(longMax);
        return this;
    }
    
    public synchronized int read(final ByteBuffer byteBuffer) throws IOException {
        return this.inner.read(byteBuffer);
    }
    
    @Override
    public synchronized void close() throws IOException {
        this.inner.close();
    }
    
    @Override
    protected void finalize() throws Throwable {
        if (this.finalize) {
            this.close();
        }
    }
    
    static {
        Native.load();
    }
}
