1 /*******************************************************************************
2 * Copyright (c) 2007, 2012 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.compressions.impl;
15 import java.io.FileInputStream;
16 import java.io.FileNotFoundException;
17 import java.io.IOException;
18 import java.io.InputStream;
19 import java.nio.ByteBuffer;
20 import java.nio.channels.ReadableByteChannel;
22 import org.simantics.compressions.CompressionCodec;
25 * @author Tuukka Lehtonen
27 public class DecompressingCodecInputStream extends DecompressingInputStream {
29 protected CompressionCodec codec;
31 public DecompressingCodecInputStream(CompressionCodec codec, File file) throws FileNotFoundException {
32 this(codec, new FileInputStream(file));
35 public DecompressingCodecInputStream(CompressionCodec codec, FileInputStream stream) {
36 this(codec, stream, stream.getChannel());
39 public DecompressingCodecInputStream(CompressionCodec codec, InputStream stream, ReadableByteChannel channel) {
40 super(stream, channel);
44 public void decompress(ByteBuffer compressed, int compressedOffset, int compressedSize,
45 ByteBuffer uncompressed, int uncompressedOffset, int uncompressedSize) throws IOException {
46 codec.decompressBuffer(compressed, compressedOffset, compressedSize, uncompressed, uncompressedOffset, uncompressedSize);