1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.fastlz.impl;
15 import java.io.FileNotFoundException;
16 import java.io.FileOutputStream;
17 import java.io.OutputStream;
18 import java.nio.ByteBuffer;
19 import java.nio.channels.WritableByteChannel;
21 import org.simantics.compressions.impl.CompressingOutputStream;
22 import org.simantics.fastlz.FastLZ;
26 * @author Hannu Niemistö
28 public class FastLZOutputStream extends CompressingOutputStream {
30 public FastLZOutputStream(File file) throws FileNotFoundException {
34 public FastLZOutputStream(FileOutputStream stream) {
38 public FastLZOutputStream(OutputStream stream) {
42 public FastLZOutputStream(OutputStream stream, WritableByteChannel channel) {
43 super(stream, channel);
47 protected int compressBound(int inputSize) {
48 return FastLZ.compressBound(inputSize);
52 protected int compress(ByteBuffer uncompressed, int uncompressedOffset, int uncompressedSize,
53 ByteBuffer compressed, int compressedOffset) {
54 return FastLZ.compressBuffer(uncompressed, uncompressedOffset, uncompressedSize, compressed, compressedOffset);
57 protected ByteBuffer allocateBuffer(int capacity) {
58 return ByteBuffer.allocateDirect(capacity);