// 
// 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.Flushable;
import java.io.Closeable;

public class ZstdDirectBufferCompressingStream implements Closeable, Flushable
{
    ZstdDirectBufferCompressingStreamNoFinalizer inner;
    private boolean finalize;
    
    protected ByteBuffer flushBuffer(final ByteBuffer byteBuffer) throws IOException {
        return byteBuffer;
    }
    
    public ZstdDirectBufferCompressingStream(final ByteBuffer byteBuffer, final int n) throws IOException {
        this.inner = new ZstdDirectBufferCompressingStreamNoFinalizer(byteBuffer, n) {
            @Override
            protected ByteBuffer flushBuffer(final ByteBuffer byteBuffer) throws IOException {
                return ZstdDirectBufferCompressingStream.this.flushBuffer(byteBuffer);
            }
        };
    }
    
    public static int recommendedOutputBufferSize() {
        return ZstdDirectBufferCompressingStreamNoFinalizer.recommendedOutputBufferSize();
    }
    
    public synchronized ZstdDirectBufferCompressingStream setDict(final byte[] dict) throws IOException {
        this.inner.setDict(dict);
        return this;
    }
    
    public synchronized ZstdDirectBufferCompressingStream setDict(final ZstdDictCompress dict) throws IOException {
        this.inner.setDict(dict);
        return this;
    }
    
    public void setFinalize(final boolean finalize) {
        this.finalize = finalize;
    }
    
    public synchronized void compress(final ByteBuffer byteBuffer) throws IOException {
        this.inner.compress(byteBuffer);
    }
    
    @Override
    public synchronized void flush() throws IOException {
        this.inner.flush();
    }
    
    @Override
    public synchronized void close() throws IOException {
        this.inner.close();
    }
    
    @Override
    protected void finalize() throws Throwable {
        if (this.finalize) {
            this.close();
        }
    }
    
    static {
        Native.load();
    }
}
