]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.fastlz/src/org/simantics/fastlz/impl/FastLZOutputStream.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.fastlz / src / org / simantics / fastlz / impl / FastLZOutputStream.java
diff --git a/bundles/org.simantics.fastlz/src/org/simantics/fastlz/impl/FastLZOutputStream.java b/bundles/org.simantics.fastlz/src/org/simantics/fastlz/impl/FastLZOutputStream.java
new file mode 100644 (file)
index 0000000..e1f60bb
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.fastlz.impl;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
+import java.io.OutputStream;\r
+import java.nio.ByteBuffer;\r
+import java.nio.channels.WritableByteChannel;\r
+\r
+import org.simantics.compressions.impl.CompressingOutputStream;\r
+import org.simantics.fastlz.FastLZ;\r
+\r
+\r
+/**\r
+ * @author Hannu Niemistö\r
+ */\r
+public class FastLZOutputStream extends CompressingOutputStream {\r
+\r
+    public FastLZOutputStream(File file) throws FileNotFoundException {\r
+        super(file);\r
+    }\r
+\r
+    public FastLZOutputStream(FileOutputStream stream) {\r
+        super(stream);\r
+    }\r
+\r
+    public FastLZOutputStream(OutputStream stream) {\r
+        super(stream);\r
+    }\r
+\r
+    public FastLZOutputStream(OutputStream stream, WritableByteChannel channel) {\r
+        super(stream, channel);\r
+    }\r
+\r
+    @Override\r
+    protected int compressBound(int inputSize) {\r
+        return FastLZ.compressBound(inputSize);\r
+    }\r
+\r
+    @Override\r
+    protected int compress(ByteBuffer uncompressed, int uncompressedOffset, int uncompressedSize,\r
+            ByteBuffer compressed, int compressedOffset) {\r
+        return FastLZ.compressBuffer(uncompressed, uncompressedOffset, uncompressedSize, compressed, compressedOffset);\r
+    }\r
+\r
+    protected ByteBuffer allocateBuffer(int capacity) {\r
+        return ByteBuffer.allocateDirect(capacity);\r
+    }\r
+\r
+}\r