ChecksumCalculatingInputStream.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one
  3.  * or more contributor license agreements.  See the NOTICE file
  4.  * distributed with this work for additional information
  5.  * regarding copyright ownership.  The ASF licenses this file
  6.  * to you under the Apache License, Version 2.0 (the
  7.  * "License"); you may not use this file except in compliance
  8.  * with the License.  You may obtain a copy of the License at
  9.  *
  10.  *   https://www.apache.org/licenses/LICENSE-2.0
  11.  *
  12.  * Unless required by applicable law or agreed to in writing,
  13.  * software distributed under the License is distributed on an
  14.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15.  * KIND, either express or implied.  See the License for the
  16.  * specific language governing permissions and limitations
  17.  * under the License.
  18.  */
  19. package org.apache.commons.compress.utils;

  20. import java.io.InputStream;
  21. import java.util.Objects;
  22. import java.util.zip.CheckedInputStream;
  23. import java.util.zip.Checksum;

  24. /**
  25.  * Calculates the checksum of the data read.
  26.  *
  27.  * @NotThreadSafe
  28.  * @since 1.14
  29.  * @deprecated Use {@link CheckedInputStream}.
  30.  */
  31. @Deprecated
  32. public class ChecksumCalculatingInputStream extends CheckedInputStream {

  33.     /**
  34.      * Constructs a new instance.
  35.      *
  36.      * @param checksum    The checksum to update
  37.      * @param inputStream The input stream to read.
  38.      * @deprecated Use {@link CheckedInputStream#CheckedInputStream(InputStream, Checksum)}.
  39.      */
  40.     @Deprecated
  41.     @SuppressWarnings("resource")
  42.     public ChecksumCalculatingInputStream(final Checksum checksum, final InputStream inputStream) {
  43.         super(Objects.requireNonNull(inputStream, "inputStream"), Objects.requireNonNull(checksum, "checksum"));
  44.     }

  45.     /**
  46.      * Returns the calculated checksum.
  47.      *
  48.      * @return the calculated checksum.
  49.      * @deprecated Use {@link CheckedInputStream#getChecksum()} and {@link Checksum#getValue()}.
  50.      */
  51.     @Deprecated
  52.     public long getValue() {
  53.         return getChecksum().getValue();
  54.     }

  55. }