X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.compressions%2Fsrc%2Forg%2Fsimantics%2Fcompressions%2FCompressionCodec.java;h=acbf9f13da722ae6af8dd096d40a0105eb498b5f;hb=c8112ea7b21b56ef632d80765a7f4d113a7d3468;hp=a34a9391020ea85bcb4a7a7b9a9267e27d56908b;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.compressions/src/org/simantics/compressions/CompressionCodec.java b/bundles/org.simantics.compressions/src/org/simantics/compressions/CompressionCodec.java index a34a93910..acbf9f13d 100644 --- a/bundles/org.simantics.compressions/src/org/simantics/compressions/CompressionCodec.java +++ b/bundles/org.simantics.compressions/src/org/simantics/compressions/CompressionCodec.java @@ -1,108 +1,108 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.compressions; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; - -/** - * @author Tuukka Lehtonen - */ -public interface CompressionCodec { - - /** - * @param inputSize size of uncompressed input data in bytes - * @return maximum amount of bytes needed for the compressed data - */ - int compressBound(int inputSize); - - int compress(byte[] uncompressedData, int i, int length, - byte[] compressedData, int j); - - /** - * Compress a block of data in the input buffer and returns the size of - * compressed block. The size of input buffer is specified by length. The - * minimum input buffer size is 16. - * - *
- * The output buffer size must be at least what is reported y - * {@link #compressBound(int)} for the input data size. - * - *
- * If the input is not compressible, the return value might be larger than - * length (input buffer size). - * - *
- * The input buffer and the output buffer can not overlap. - * - *
- * It is recommended to have both input buffers as direct or heap buffers, - * not mixed. Mixing different types of buffers will hurt performance a lot. - * If both buffers are direct byte buffers and native decompression is - * available, it will be employed. - */ - int compressBuffer(ByteBuffer input, int inputOffset, int length, - ByteBuffer output, int outputOffset); - - byte[] decompress(byte[] compressedData, int i, int uncompressedLength); - - /** - * Decompress a block of compressed data and returns the size of the - * decompressed block. If error occurs, e.g. the compressed data is - * corrupted or the output buffer is not large enough, then 0 (zero) will be - * returned instead. - * - *
- * The input buffer and the output buffer can not overlap. - * - *
- * Decompression is memory safe and guaranteed not to write the output - * buffer more than what is specified in maxout. - * - *
- * It is recommended to have both input buffers as direct or heap buffers, - * not mixed. Mixing different types of buffers will hurt performance a lot. - * If both buffers are direct byte buffers and native decompression is - * available, it will be employed. - */ - int decompressBuffer(ByteBuffer input, int inputOffset, int length, - ByteBuffer output, int outputOffset, int maxout); - - /** - * @param file - * the compressed file to read - * @return input stream that decompresses its output using the codec's - * algorithm - * @throws FileNotFoundException - * see {@link FileOutputStream#FileOutputStream(File)} for when - * this is thrown - */ - InputStream read(File file) throws FileNotFoundException; - - /** - * @param file - * the compressed file to write - * @return output stream that compresses its input using the codec's - * algorithm - * @throws FileNotFoundException - * see {@link FileOutputStream#FileOutputStream(File)} for when - * this is thrown - */ - OutputStream write(File file) throws FileNotFoundException; - - String getId(); - +/******************************************************************************* + * Copyright (c) 2007, 2012 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.compressions; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; + +/** + * @author Tuukka Lehtonen + */ +public interface CompressionCodec { + + /** + * @param inputSize size of uncompressed input data in bytes + * @return maximum amount of bytes needed for the compressed data + */ + int compressBound(int inputSize); + + int compress(byte[] uncompressedData, int i, int length, + byte[] compressedData, int j); + + /** + * Compress a block of data in the input buffer and returns the size of + * compressed block. The size of input buffer is specified by length. The + * minimum input buffer size is 16. + * + *
+ * The output buffer size must be at least what is reported y + * {@link #compressBound(int)} for the input data size. + * + *
+ * If the input is not compressible, the return value might be larger than + * length (input buffer size). + * + *
+ * The input buffer and the output buffer can not overlap. + * + *
+ * It is recommended to have both input buffers as direct or heap buffers, + * not mixed. Mixing different types of buffers will hurt performance a lot. + * If both buffers are direct byte buffers and native decompression is + * available, it will be employed. + */ + int compressBuffer(ByteBuffer input, int inputOffset, int length, + ByteBuffer output, int outputOffset); + + byte[] decompress(byte[] compressedData, int i, int uncompressedLength); + + /** + * Decompress a block of compressed data and returns the size of the + * decompressed block. If error occurs, e.g. the compressed data is + * corrupted or the output buffer is not large enough, then 0 (zero) will be + * returned instead. + * + *
+ * The input buffer and the output buffer can not overlap. + * + *
+ * Decompression is memory safe and guaranteed not to write the output + * buffer more than what is specified in maxout. + * + *
+ * It is recommended to have both input buffers as direct or heap buffers, + * not mixed. Mixing different types of buffers will hurt performance a lot. + * If both buffers are direct byte buffers and native decompression is + * available, it will be employed. + */ + int decompressBuffer(ByteBuffer input, int inputOffset, int length, + ByteBuffer output, int outputOffset, int maxout); + + /** + * @param file + * the compressed file to read + * @return input stream that decompresses its output using the codec's + * algorithm + * @throws FileNotFoundException + * see {@link FileOutputStream#FileOutputStream(File)} for when + * this is thrown + */ + InputStream read(File file) throws FileNotFoundException; + + /** + * @param file + * the compressed file to write + * @return output stream that compresses its input using the codec's + * algorithm + * @throws FileNotFoundException + * see {@link FileOutputStream#FileOutputStream(File)} for when + * this is thrown + */ + OutputStream write(File file) throws FileNotFoundException; + + String getId(); + } \ No newline at end of file