]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.compressions/src/org/simantics/compressions/impl/DecompressingCodecInputStream.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.compressions / src / org / simantics / compressions / impl / DecompressingCodecInputStream.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2012 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.compressions.impl;
13
14 import java.io.File;
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;
21
22 import org.simantics.compressions.CompressionCodec;
23
24 /**
25  * @author Tuukka Lehtonen
26  */
27 public class DecompressingCodecInputStream extends DecompressingInputStream {
28
29     protected CompressionCodec codec;
30
31     public DecompressingCodecInputStream(CompressionCodec codec, File file) throws FileNotFoundException {
32         this(codec, new FileInputStream(file));
33     }
34
35     public DecompressingCodecInputStream(CompressionCodec codec, FileInputStream stream) {
36         this(codec, stream, stream.getChannel());
37     }
38
39     public DecompressingCodecInputStream(CompressionCodec codec, InputStream stream, ReadableByteChannel channel) {
40         super(stream, channel);
41         this.codec = codec;
42     }
43
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);
47     }
48
49 }