Package io.ocfl.api.model
Class DigestAlgorithm
java.lang.Object
io.ocfl.api.model.DigestAlgorithm
- Direct Known Subclasses:
SizeDigestAlgorithm
,StandardDigestAlgorithm
Maps OCFL defined digest algorithms to their Java names. Java does not include built-in implementations for all of the
algorithms, using a 3rd party provider, such as BouncyCastle, is necessary for some, such as blake2b. New algorithms
should be registered in the
DigestAlgorithmRegistry
.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DigestAlgorithm
(String ocflName, String javaStandardName) -
Method Summary
Modifier and TypeMethodDescriptionabstract String
encode
(byte[] value) Encodes a binary digest value into a string representation.boolean
static DigestAlgorithm
fromOcflName
(String ocflName) Creates a DigestAlgorithm for the given OCFL name.static DigestAlgorithm
fromOcflName
(String ocflName, String javaStandardName) Creates a DigestAlgorithm for the given OCFL name.The Java name for the digest algorithm.abstract MessageDigest
Creates a newMessageDigest
that implements the digest algorithmThe OCFL name for the digest algorithm.int
hashCode()
boolean
Indicates whether or not there is a Java mapping for the algorithm.toString()
-
Constructor Details
-
DigestAlgorithm
-
-
Method Details
-
getMessageDigest
Creates a newMessageDigest
that implements the digest algorithm- Returns:
- new
MessageDigest
-
encode
Encodes a binary digest value into a string representation.- Parameters:
value
- digest value- Returns:
- the digest value as a string
-
fromOcflName
Creates a DigestAlgorithm for the given OCFL name. If the name is not mapped in theDigestAlgorithmRegistry
then a new object is created, but not automatically added to the registry. Newly created DigestAlgorithms are not automatically mapped to Java names.- Parameters:
ocflName
- ocfl name of algorithm- Returns:
- digest algorithm
-
fromOcflName
Creates a DigestAlgorithm for the given OCFL name. If the name is not mapped in theDigestAlgorithmRegistry
then a new object is created, but not automatically added to the registry.- Parameters:
ocflName
- ocfl name of algorithmjavaStandardName
- the name of the algorithm in Java- Returns:
- digest algorithm
-
getOcflName
The OCFL name for the digest algorithm.- Returns:
- standardized ocfl name for the digest algorithm
-
getJavaStandardName
The Java name for the digest algorithm.- Returns:
- name of the digest algorithm in Java or null
-
hasJavaStandardName
public boolean hasJavaStandardName()Indicates whether or not there is a Java mapping for the algorithm.- Returns:
- whether or not the digest algorithm has a Java name
-
toString
-
equals
-
hashCode
public int hashCode()
-