Class Checksums

java.lang.Object
opennlp.tools.util.Checksums

final class Checksums extends Object
Computes and validates the hex-encoded file digests that downloads are verified against.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    The SHA-256 algorithm name.
    (package private) static final int
    The number of hex digits in a SHA-256 digest.
    (package private) static final String
    The SHA-512 algorithm name.
    (package private) static final int
    The number of hex digits in a SHA-512 digest.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Prevents construction of this utility class.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static String
    hexDigest(Path file, String algorithm)
    Computes the digest of a file's bytes.
    (package private) static boolean
    isHexDigest(String value, int length)
    Checks that a string is a hex digest of the given length, in either letter case.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Checksums

      private Checksums()
      Prevents construction of this utility class.
  • Method Details

    • hexDigest

      static String hexDigest(Path file, String algorithm) throws IOException
      Computes the digest of a file's bytes.
      Parameters:
      file - The file to digest.
      algorithm - The MessageDigest algorithm name, for example SHA_512.
      Returns:
      The digest as lowercase hex digits. Not null.
      Throws:
      IOException - Thrown if the file cannot be read or the algorithm is not available in this runtime.
    • isHexDigest

      static boolean isHexDigest(String value, int length)
      Checks that a string is a hex digest of the given length, in either letter case.
      Parameters:
      value - The string to inspect.
      length - The required number of hex digits.
      Returns:
      true if value has length characters and each is a hex digit.