cstamas commented on a change in pull request #139:
URL: https://github.com/apache/maven-resolver/pull/139#discussion_r787570194



##########
File path: 
maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumAlgorithmHelper.java
##########
@@ -0,0 +1,106 @@
+package org.eclipse.aether.spi.connector.checksum;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Helper for checksum operations.
+ *
+ * @since TBD
+ */
+public final class ChecksumAlgorithmHelper
+{
+    private ChecksumAlgorithmHelper()
+    {
+        // nop
+    }
+
+    /**
+     * Calculates checksums for specified data.
+     *
+     * @param data        The content for which to calculate checksums, must 
not be {@code null}.
+     * @param factories   The checksum algorithm factories to use, must not be 
{@code null}.
+     * @return The calculated checksums, indexed by algorithm name, or the 
exception that occurred while trying to
+     * calculate it, never {@code null}.
+     * @throws IOException In case of any problem.
+     */
+    public static Map<String, String> calculate( byte[] data, 
List<ChecksumAlgorithmFactory> factories )
+            throws IOException
+    {
+        return calculate( new ByteArrayInputStream( data ), factories );
+    }
+
+    /**
+     * Calculates checksums for specified file.
+     *
+     * @param file        The file for which to calculate checksums, must not 
be {@code null}.
+     * @param factories   The checksum algorithm factories to use, must not be 
{@code null}.
+     * @return The calculated checksums, indexed by algorithm name, or the 
exception that occurred while trying to
+     * calculate it, never {@code null}.
+     * @throws IOException In case of any problem.
+     */
+    public static Map<String, String> calculate( File file, 
List<ChecksumAlgorithmFactory> factories )
+            throws IOException
+    {
+        return calculate( new BufferedInputStream( new FileInputStream( file ) 
), factories );

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to