Package org.spdx.library.model
Class Checksum
java.lang.Object
org.spdx.library.model.ModelObject
org.spdx.library.model.Checksum
- All Implemented Interfaces:
Comparable<Checksum>
public class Checksum extends ModelObject implements Comparable<Checksum>
A Checksum is value that allows the contents of a file to be authenticated.
Even small changes to the content of the file will change its checksum.
This class allows the results of a variety of checksum and cryptographic
message digest algorithms to be represented.
- Author:
- Gary O'Neall
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Checksum()Checksum(String id)Checksum(IModelStore modelStore, String documentUri, String id, ModelCopyManager copyManager, boolean create) -
Method Summary
Modifier and Type Method Description protected List<String>_verify(Set<String> verifiedIds, String specVersion)Implementation of the specific verifications for this model objectintcompareTo(Checksum compare)static Checksumcreate(IModelStore modelStore, String documentUri, ChecksumAlgorithm algorithm, String value)Create a checksum with an anonymous IDChecksumAlgorithmgetAlgorithm()StringgetType()StringgetValue()protected voidsetAlgorithm(ChecksumAlgorithm algorithm)Set the checksum algorithm.protected voidsetValue(String value)Set the value - this should only be called by factory methodsStringtoString()Methods inherited from class org.spdx.library.model.ModelObject
addPropertyValueToCollection, addValueToCollection, clearValueCollection, clearValueCollection, clone, copyFrom, createAnnotation, createByteOffsetPointer, createChecksum, createConjunctiveLicenseSet, createCreationInfo, createCrossRef, createDisjunctiveLicenseSet, createExternalDocumentRef, createExternalRef, createLineCharPointer, createPackage, createPackageVerificationCode, createRelationship, createSpdxFile, createSpdxSnippet, createStartEndPointer, enterCriticalSection, equals, equivalent, equivalent, getAnyLicenseInfoPropertyValue, getBooleanPropertyValue, getCopyManager, getDocumentUri, getElementPropertyValue, getEnumPropertyValue, getId, getIntegerPropertyValue, getModelStore, getObjectPropertyValue, getObjectPropertyValue, getObjectPropertyValueCollection, getObjectPropertyValueSet, getPropertyValueNames, getStringCollection, getStringPropertyValue, hashCode, idToIdType, isCollectionMembersAssignableTo, isStrict, leaveCriticalSection, removeProperty, removeProperty, removePropertyValueFromCollection, removePropertyValueFromCollection, replacePropertyValueCollection, setCopyManager, setPropertyValue, setPropertyValue, setStrict, toTypedValue, updateAddPropertyValueToCollection, updateClearValueCollection, updatePropertyValue, updateRemoveProperty, updateRemovePropertyValueFromCollection, verify, verify, verify, verifyCollection
-
Constructor Details
-
Checksum
- Throws:
InvalidSPDXAnalysisException
-
Checksum
- Parameters:
id-- Throws:
InvalidSPDXAnalysisException
-
Checksum
public Checksum(IModelStore modelStore, String documentUri, String id, @Nullable ModelCopyManager copyManager, boolean create) throws InvalidSPDXAnalysisException- Parameters:
modelStore-documentUri-id-copyManager-create-- Throws:
InvalidSPDXAnalysisException
-
-
Method Details
-
create
public static Checksum create(IModelStore modelStore, String documentUri, ChecksumAlgorithm algorithm, String value) throws InvalidSPDXAnalysisExceptionCreate a checksum with an anonymous ID- Parameters:
modelStore-documentUri-algorithm-value-- Returns:
- Throws:
InvalidSPDXAnalysisException
-
getType
- Specified by:
getTypein classModelObject- Returns:
- The class name for this object. Class names are defined in the constants file
-
_verify
Description copied from class:ModelObjectImplementation of the specific verifications for this model object- Specified by:
_verifyin classModelObject- Parameters:
verifiedIds- list of all Element Id's which have already been verified - prevents infinite recursionspecVersion- Version of the SPDX spec to verify against- Returns:
- Any verification errors or warnings associated with this object
-
getAlgorithm
- Returns:
- the ChecksumAlgorithm MISSING denotes that there was no algorithm stored
- Throws:
InvalidSPDXAnalysisException
-
setAlgorithm
Set the checksum algorithm. This should only be called by factory classes since they should not be modified once created and stored.- Parameters:
algorithm-- Throws:
InvalidSPDXAnalysisException
-
getValue
- Returns:
- the checksum algorithm or an empty string if no algorithm value was stored
- Throws:
InvalidSPDXAnalysisException
-
setValue
Set the value - this should only be called by factory methods- Parameters:
value-- Throws:
InvalidSPDXAnalysisException
-
toString
- Overrides:
toStringin classModelObject
-
compareTo
- Specified by:
compareToin interfaceComparable<Checksum>
-