]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.compressions/src/org/simantics/compressions/Compressions.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.compressions / src / org / simantics / compressions / Compressions.java
index c13291d995cd9497329d97053e79b9fff49d5089..66a29e7cb473c2ae15e8eb65ed359a7ace28022b 100644 (file)
@@ -1,92 +1,92 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2012 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.compressions;\r
-\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-import java.util.Collection;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.osgi.framework.InvalidSyntaxException;\r
-import org.osgi.framework.ServiceReference;\r
-\r
-/**\r
- * A facade for accessing {@link CompressionCodec} implementations.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public final class Compressions {\r
-\r
-       private static final Map<String, CompressionCodec> CODECS = new HashMap<>();\r
-    private static boolean initialized = false;\r
-\r
-    public static final String LZ4 = "LZ4";\r
-    public static final String FASTLZ = "FASTLZ";\r
-    \r
-    private static void collectCodecs() {\r
-        try {\r
-            Collection<ServiceReference<CompressionCodec>> serv = Activator.getContext().getServiceReferences(CompressionCodec.class, null);\r
-            for (ServiceReference<CompressionCodec> service : serv) {\r
-                CompressionCodec codec = Activator.getContext().getService(service);\r
-                CODECS.put(codec.getId(), codec);\r
-            }\r
-            initialized = true;\r
-        } catch (InvalidSyntaxException e) {\r
-            e.printStackTrace();\r
-        }\r
-    }\r
-    \r
-       \r
-       /**\r
-        * Get a {@link CompressionCodec} matching the requested name.\r
-        * @param <T>\r
-        * \r
-        * @param codec codec name\r
-        * @return \r
-        * @return matching codec\r
-        * @see #FASTLZ\r
-        * @see #LZ4\r
-        */\r
-       public static CompressionCodec get(String codecId) {\r
-           if (!initialized) {\r
-               collectCodecs();\r
-           }\r
-           CompressionCodec codec = CODECS.get(codecId);\r
-           if (codec == null) {\r
-               throw new IllegalArgumentException("No codec with id " + codecId + " installed");\r
-           }\r
-           return codec;\r
-       }\r
-       \r
-       /**\r
-        * @param codecId\r
-        * @param file\r
-        * @return\r
-        * @throws FileNotFoundException \r
-        */\r
-       public static OutputStream write(String codecId, File file) throws FileNotFoundException {\r
-               return get(codecId).write(file);\r
-       }\r
-\r
-       /**\r
-        * @param codecId\r
-        * @param file\r
-        * @return\r
-        * @throws FileNotFoundException \r
-        */\r
-       public static InputStream read(String codecId, File file) throws FileNotFoundException {\r
-               return get(codecId).read(file);\r
-       }\r
+/*******************************************************************************
+ * 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.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A facade for accessing {@link CompressionCodec} implementations.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public final class Compressions {
+
+       private static final Map<String, CompressionCodec> CODECS = new HashMap<>();
+    private static boolean initialized = false;
+
+    public static final String LZ4 = "LZ4";
+    public static final String FASTLZ = "FASTLZ";
+    
+    private static void collectCodecs() {
+        try {
+            Collection<ServiceReference<CompressionCodec>> serv = Activator.getContext().getServiceReferences(CompressionCodec.class, null);
+            for (ServiceReference<CompressionCodec> service : serv) {
+                CompressionCodec codec = Activator.getContext().getService(service);
+                CODECS.put(codec.getId(), codec);
+            }
+            initialized = true;
+        } catch (InvalidSyntaxException e) {
+            e.printStackTrace();
+        }
+    }
+    
+       
+       /**
+        * Get a {@link CompressionCodec} matching the requested name.
+        * @param <T>
+        * 
+        * @param codec codec name
+        * @return 
+        * @return matching codec
+        * @see #FASTLZ
+        * @see #LZ4
+        */
+       public static CompressionCodec get(String codecId) {
+           if (!initialized) {
+               collectCodecs();
+           }
+           CompressionCodec codec = CODECS.get(codecId);
+           if (codec == null) {
+               throw new IllegalArgumentException("No codec with id " + codecId + " installed");
+           }
+           return codec;
+       }
+       
+       /**
+        * @param codecId
+        * @param file
+        * @return
+        * @throws FileNotFoundException 
+        */
+       public static OutputStream write(String codecId, File file) throws FileNotFoundException {
+               return get(codecId).write(file);
+       }
+
+       /**
+        * @param codecId
+        * @param file
+        * @return
+        * @throws FileNotFoundException 
+        */
+       public static InputStream read(String codecId, File file) throws FileNotFoundException {
+               return get(codecId).read(file);
+       }
 }
\ No newline at end of file