public final class Checksum extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected ChecksumType |
type
The checksum type
|
protected String |
value
The checksum value
|
| Constructor and Description |
|---|
Checksum()
Needed by JAXB
|
| Modifier and Type | Method and Description |
|---|---|
static String |
convertToHex(byte[] data)
Converts the checksum to a hex string.
|
static Checksum |
create(ChecksumType type,
File file)
Creates a checksum of type
type from the given file. |
static Checksum |
create(ChecksumType type,
InputStream is)
Creates a checksum of type
type from the given input stream. |
static Checksum |
create(ChecksumType type,
String value)
Creates a checksum of type
type and value value. |
static Checksum |
create(String type,
String value)
Creates a checksum of type
type and value value. |
static Checksum |
createFor(ChecksumType type,
String string)
Create a checksum of type
type for the given string. |
boolean |
equals(Object obj) |
static Checksum |
fromString(String checksum)
Creates a checksum from a string in the form "value (type)".
|
ChecksumType |
getType()
Returns the checksum type.
|
String |
getValue()
Returns the checksum value.
|
int |
hashCode() |
String |
toString() |
protected String value
protected ChecksumType type
public ChecksumType getType()
public String getValue()
public static String convertToHex(byte[] data)
data - the digestpublic static Checksum fromString(String checksum) throws NoSuchAlgorithmException
checksum - the checksum in string formNoSuchAlgorithmException - if the checksum of the specified type cannot be createdpublic static Checksum create(String type, String value) throws NoSuchAlgorithmException
type and value value.type - the checksum type namevalue - the checksum valueNoSuchAlgorithmException - if the checksum of the specified type cannot be createdpublic static Checksum create(ChecksumType type, String value)
type and value value.type - the checksum typevalue - the checksum valuepublic static Checksum create(ChecksumType type, File file) throws IOException
type from the given file.type - the checksum typefile - the fileIOException - if the file cannot be accessedpublic static Checksum create(ChecksumType type, InputStream is) throws IOException
type from the given input stream.
The stream gets closed afterwards.IOExceptionpublic static Checksum createFor(ChecksumType type, String string) throws IOException
type for the given string.IOExceptionCopyright © 2009–2020 Opencast Project. All rights reserved.