Package org.opencastproject.util
Class Checksum
java.lang.Object
org.opencastproject.util.Checksum
- All Implemented Interfaces:
Serializable
This class stores value and type of a generated checksum.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChecksumTypeThe checksum typeprotected StringThe checksum value -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertToHex(byte[] data) Converts the checksum to a hex string.static ChecksumCreates a checksum of typetypeand valuevalue.static Checksumcreate(ChecksumType type, File file) Creates a checksum of typetypefrom the given file.static Checksumcreate(ChecksumType type, InputStream is) Creates a checksum of typetypefrom the given input stream.static Checksumcreate(ChecksumType type, String value) Creates a checksum of typetypeand valuevalue.booleanstatic ChecksumfromString(String checksum) Creates a checksum from a string in the form "value (type)".getType()Returns the checksum type.getValue()Returns the checksum value.inthashCode()toString()
-
Field Details
-
value
The checksum value -
type
The checksum type
-
-
Constructor Details
-
Checksum
public Checksum()Needed by JAXB
-
-
Method Details
-
getType
Returns the checksum type.- Returns:
- the type
-
getValue
Returns the checksum value.- Returns:
- the value
-
convertToHex
Converts the checksum to a hex string.- Parameters:
data- the digest- Returns:
- the digest hex representation
-
equals
-
hashCode
public int hashCode() -
toString
-
fromString
Creates a checksum from a string in the form "value (type)".- Parameters:
checksum- the checksum in string form- Returns:
- the checksum
- Throws:
NoSuchAlgorithmException- if the checksum of the specified type cannot be created
-
create
Creates a checksum of typetypeand valuevalue.- Parameters:
type- the checksum type namevalue- the checksum value- Returns:
- the checksum
- Throws:
NoSuchAlgorithmException- if the checksum of the specified type cannot be created
-
create
Creates a checksum of typetypeand valuevalue.- Parameters:
type- the checksum typevalue- the checksum value- Returns:
- the checksum
-
create
Creates a checksum of typetypefrom the given file.- Parameters:
type- the checksum typefile- the file- Returns:
- the checksum
- Throws:
IOException- if the file cannot be accessed
-
create
Creates a checksum of typetypefrom the given input stream. The stream gets closed afterwards.- Throws:
IOException
-