java.lang.Object
org.apache.tools.ant.types.selectors.modifiedselector.DigestAlgorithm
All Implemented Interfaces:
Algorithm

public class DigestAlgorithm extends Object implements Algorithm
Computes a 'hashvalue' for the content of file using java.security.MessageDigest. Use of this algorithm doesn't require any additional nested <param>s. Supported <param>s are:
Digest algorithm parameters
namevaluesdescriptionrequired
algorithm.algorithm MD5 | SHA (default provider) name of the algorithm the provider should use no, defaults to MD5
algorithm.provider name of the provider to use no, defaults to null
Since:
Ant 1.6
Version:
2004-07-08
  • Constructor Details

    • DigestAlgorithm

      public DigestAlgorithm()
  • Method Details

    • setAlgorithm

      public void setAlgorithm(String algorithm)
      Specifies the algorithm to be used to compute the checksum. Defaults to "MD5". Other popular algorithms like "SHA" may be used as well.
      Parameters:
      algorithm - the digest algorithm to use
    • setProvider

      public void setProvider(String provider)
      Sets the MessageDigest algorithm provider to be used to calculate the checksum.
      Parameters:
      provider - provider to use
    • initMessageDigest

      public void initMessageDigest()
      Initialize the security message digest.
    • isValid

      public boolean isValid()
      This algorithm supports only MD5 and SHA.
      Specified by:
      isValid in interface Algorithm
      Returns:
      true if all is ok, otherwise false.
    • getValue

      public String getValue(File file)
      Computes a value for a file content with the specified digest algorithm.
      Specified by:
      getValue in interface Algorithm
      Parameters:
      file - File object for which the value should be evaluated.
      Returns:
      The value for that file
    • toString

      public String toString()
      Override Object.toString().
      Overrides:
      toString in class Object
      Returns:
      some information about this algorithm.