Package org.spdx.library.model.v2
Class Checksum
- java.lang.Object
-
- org.spdx.core.CoreModelObject
-
- org.spdx.library.model.v2.ModelObjectV2
-
- org.spdx.library.model.v2.Checksum
-
- All Implemented Interfaces:
Comparable<Checksum>
public class Checksum extends ModelObjectV2 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
-
Fields inherited from class org.spdx.library.model.v2.ModelObjectV2
LATEST_SPDX_2_VERSION
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<String>
_verify(Set<String> verifiedIds, String specVersion)
Implementation of the specific verifications for this model objectint
compareTo(Checksum compare)
static Checksum
create(org.spdx.storage.IModelStore modelStore, String documentUri, ChecksumAlgorithm algorithm, String value)
Create a checksum with an anonymous IDChecksumAlgorithm
getAlgorithm()
String
getType()
String
getValue()
void
setAlgorithm(ChecksumAlgorithm algorithm)
Set the checksum algorithm.void
setValue(String value)
Set the value - this should only be called by factory methodsString
toString()
-
Methods inherited from class org.spdx.library.model.v2.ModelObjectV2
_verify, createAnnotation, createByteOffsetPointer, createChecksum, createConjunctiveLicenseSet, createCreationInfo, createCrossRef, createDisjunctiveLicenseSet, createExternalDocumentRef, createExternalRef, createExtractedLicense, createLineCharPointer, createPackage, createPackageVerificationCode, createRelationship, createSpdxFile, createSpdxSnippet, createStartEndPointer, equals, getAnyLicenseInfoPropertyValue, getDocumentUri, getElementPropertyValue, getId, hashCode, isEquivalentToNull, isNoAssertion, isRelatedElement, toTypedValue, verify
-
Methods inherited from class org.spdx.core.CoreModelObject
addPropertyValueToCollection, clearValueCollection, clone, copyFrom, enterCriticalSection, equivalent, equivalent, getBooleanPropertyValue, getCopyManager, getDoublePropertyValue, getEnumPropertyValue, getIdPrefix, getIntegerPropertyValue, getModelStore, getObjectPropertyValue, getObjectPropertyValue, getObjectPropertyValueCollection, getObjectPropertyValueSet, getObjectUri, getPropertyValueDescriptors, getSpecVersion, getStringCollection, getStringPropertyValue, isCollectionMembersAssignableTo, isExternal, isStrict, leaveCriticalSection, removeProperty, removePropertyValueFromCollection, setCopyManager, setIdPrefix, setPropertyValue, setStrict, updateAddPropertyValueToCollection, updateClearValueCollection, updatePropertyValue, updateRemoveProperty, updateRemovePropertyValueFromCollection, verify, verify, verifyCollection
-
-
-
-
Constructor Detail
-
Checksum
public Checksum() throws org.spdx.core.InvalidSPDXAnalysisException
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
Checksum
public Checksum(String id) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
id
- identifier- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
Checksum
public Checksum(org.spdx.storage.IModelStore modelStore, String documentUri, String id, @Nullable org.spdx.core.IModelCopyManager copyManager, boolean create) throws org.spdx.core.InvalidSPDXAnalysisException
- Parameters:
modelStore
- container which includes the model datadocumentUri
- URI for the SPDX document containing the model dataid
- identifiercopyManager
- if non-null, allows for copying of any properties set which use other model stores or document URI'screate
- if true, create the license if it does not exist- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
-
Method Detail
-
create
public static Checksum create(org.spdx.storage.IModelStore modelStore, String documentUri, ChecksumAlgorithm algorithm, String value) throws org.spdx.core.InvalidSPDXAnalysisException
Create a checksum with an anonymous ID- Parameters:
modelStore
-documentUri
-algorithm
-value
-- Returns:
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getType
public String getType()
- Specified by:
getType
in classorg.spdx.core.CoreModelObject
-
_verify
protected List<String> _verify(Set<String> verifiedIds, String specVersion)
Description copied from class:ModelObjectV2
Implementation of the specific verifications for this model object- Specified by:
_verify
in classModelObjectV2
- 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
public ChecksumAlgorithm getAlgorithm() throws org.spdx.core.InvalidSPDXAnalysisException
- Returns:
- the ChecksumAlgorithm MISSING denotes that there was no algorithm stored
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setAlgorithm
public void setAlgorithm(ChecksumAlgorithm algorithm) throws org.spdx.core.InvalidSPDXAnalysisException
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:
org.spdx.core.InvalidSPDXAnalysisException
-
getValue
public String getValue() throws org.spdx.core.InvalidSPDXAnalysisException
- Returns:
- the checksum algorithm or an empty string if no algorithm value was stored
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setValue
public void setValue(String value) throws org.spdx.core.InvalidSPDXAnalysisException
Set the value - this should only be called by factory methods- Parameters:
value
-- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
toString
public String toString()
- Overrides:
toString
in classModelObjectV2
-
compareTo
public int compareTo(Checksum compare)
- Specified by:
compareTo
in interfaceComparable<Checksum>
-
-