X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.fastlz%2Fsrc%2Forg%2Fsimantics%2Ffastlz%2FFastLZJava.java;h=f001534cf1bc41a1fbf0114ed98ef1cb8c18e9d3;hb=refs%2Fchanges%2F38%2F238%2F2;hp=3e0f4523e2df7c241cded18b49668e81de01d597;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.fastlz/src/org/simantics/fastlz/FastLZJava.java b/bundles/org.simantics.fastlz/src/org/simantics/fastlz/FastLZJava.java index 3e0f4523e..f001534cf 100644 --- a/bundles/org.simantics.fastlz/src/org/simantics/fastlz/FastLZJava.java +++ b/bundles/org.simantics.fastlz/src/org/simantics/fastlz/FastLZJava.java @@ -1,98 +1,98 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.fastlz; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; - -import org.simantics.fastlz.java.FastLZImpl; -import org.simantics.fastlz.java.FastLZJavaInputStream; -import org.simantics.fastlz.java.FastLZJavaOutputStream; - -/** - * A Java port of the native {@link FastLZ} library. - * - * @author Tuukka Lehtonen - * - * @see FastLZ - * @see FastLZImpl - * @see FastLZJavaInputStream - * @see FastLZJavaOutputStream - */ -public class FastLZJava { - - /** - * 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 must be at least 5% larger than the input buffer and - * can not be smaller than 66 bytes. - * - *

- * 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. - */ - public static int compress(byte[] input, int inputOffset, int length, byte[] output, int outputOffset) { - return FastLZImpl.fastlz_compress(input, inputOffset, length, output, outputOffset); - } - - /** - * 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. - */ - public static int decompress(byte[] input, int inputOffset, int length, byte[] output, int outputOffset, int maxout) { - return FastLZImpl.fastlz_decompress(input, inputOffset, length, output, outputOffset, maxout); - } - - /** - * @param file the FastLZ-compressed file to read - * @return input stream that decompresses its output using the FastLZ - * algorithm - * @throws FileNotFoundException see - * {@link FileOutputStream#FileOutputStream(File)} for when this is - * thrown - */ - public static InputStream read(File file) throws FileNotFoundException { - return new FastLZJavaInputStream(new FileInputStream(file)); - } - - /** - * @param file the FastLZ-compressed file to write - * @return output stream that compresses its input using the FastLZ - * algorithm - * @throws FileNotFoundException see - * {@link FileOutputStream#FileOutputStream(File)} for when this is - * thrown - */ - public static OutputStream write(File file) throws FileNotFoundException { - return new FastLZJavaOutputStream(new FileOutputStream(file)); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 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.fastlz; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + +import org.simantics.fastlz.java.FastLZImpl; +import org.simantics.fastlz.java.FastLZJavaInputStream; +import org.simantics.fastlz.java.FastLZJavaOutputStream; + +/** + * A Java port of the native {@link FastLZ} library. + * + * @author Tuukka Lehtonen + * + * @see FastLZ + * @see FastLZImpl + * @see FastLZJavaInputStream + * @see FastLZJavaOutputStream + */ +public class FastLZJava { + + /** + * 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 must be at least 5% larger than the input buffer and + * can not be smaller than 66 bytes. + * + *

+ * 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. + */ + public static int compress(byte[] input, int inputOffset, int length, byte[] output, int outputOffset) { + return FastLZImpl.fastlz_compress(input, inputOffset, length, output, outputOffset); + } + + /** + * 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. + */ + public static int decompress(byte[] input, int inputOffset, int length, byte[] output, int outputOffset, int maxout) { + return FastLZImpl.fastlz_decompress(input, inputOffset, length, output, outputOffset, maxout); + } + + /** + * @param file the FastLZ-compressed file to read + * @return input stream that decompresses its output using the FastLZ + * algorithm + * @throws FileNotFoundException see + * {@link FileOutputStream#FileOutputStream(File)} for when this is + * thrown + */ + public static InputStream read(File file) throws FileNotFoundException { + return new FastLZJavaInputStream(new FileInputStream(file)); + } + + /** + * @param file the FastLZ-compressed file to write + * @return output stream that compresses its input using the FastLZ + * algorithm + * @throws FileNotFoundException see + * {@link FileOutputStream#FileOutputStream(File)} for when this is + * thrown + */ + public static OutputStream write(File file) throws FileNotFoundException { + return new FastLZJavaOutputStream(new FileOutputStream(file)); + } + +}