Package org.spdx.utility.compare
Class SpdxPackageComparer
- java.lang.Object
-
- org.spdx.utility.compare.SpdxItemComparer
-
- org.spdx.utility.compare.SpdxPackageComparer
-
public class SpdxPackageComparer extends SpdxItemComparer
Compares two SPDX package.The
compare(pkgA, pkgB)method will perform the comparison and store the results.isDifferenceFound()will return true of any differences were found.- Author:
- Gary O'Neall
-
-
Field Summary
-
Fields inherited from class org.spdx.utility.compare.SpdxItemComparer
documentItem, extractedLicenseIdMap, name
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDocumentPackage(org.spdx.library.model.v2.SpdxDocument spdxDocument, org.spdx.library.model.v2.SpdxPackage spdxPackage)Add a package to the comparer and performs the comparison to any existing documentsprotected voidcheckInProgress()checks to make sure there is not a compare in progressorg.spdx.library.model.v2.SpdxPackagegetDocPackage(org.spdx.library.model.v2.SpdxDocument document)Return the package associated with the documentList<SpdxExternalRefDifference>getExternalRefDifferences(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)List<SpdxFileDifference>getFileDifferences(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)Get any fileDifferences which are in docA but not in docBintgetNumPackages()StringgetPackageName()List<org.spdx.library.model.v2.Checksum>getUniqueChecksums(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)Get the checksums which are present in document A but not in document BList<org.spdx.library.model.v2.ExternalRef>getUniqueExternalRefs(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)List<org.spdx.library.model.v2.SpdxFile>getUniqueFiles(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)Return any unique files by name which are in docA but not in docBbooleanisDeclaredLicensesEquals()booleanisDifferenceFound()booleanisExternalRefsEquals()booleanisFilesAnalyzedEquals()booleanisInProgress()booleanisPackageChecksumsEquals()booleanisPackageDescriptionsEquals()booleanisPackageDownloadLocationsEquals()booleanisPackageFilenamesEquals()booleanisPackageFilesEquals()booleanisPackageHomePagesEquals()booleanisPackageOriginatorsEqual()booleanisPackageSourceInfosEquals()booleanisPackageSummaryEquals()booleanisPackageSuppliersEquals()booleanisPackageVerificationCodesEquals()booleanisPackageVersionsEquals()-
Methods inherited from class org.spdx.utility.compare.SpdxItemComparer
addDocumentItem, checkCompareMade, getItem, getUniqueAnnotations, getUniqueRelationship, getUniqueSeenLicenses, isAnnotationsEquals, isAttributionTextEquals, isCommentsEquals, isConcludedLicenseEquals, isCopyrightsEquals, isLicenseCommentsEquals, isLicenseCommmentsEquals, isRelationshipsEquals, isSeenLicenseEquals
-
-
-
-
Constructor Detail
-
SpdxPackageComparer
public SpdxPackageComparer(Map<org.spdx.library.model.v2.SpdxDocument,Map<org.spdx.library.model.v2.SpdxDocument,Map<String,String>>> extractedLicenseIdMap)
- Parameters:
extractedLicenseIdMap- map of all extracted license IDs for any SPDX documents to be added to the comparer
-
-
Method Detail
-
addDocumentPackage
public void addDocumentPackage(org.spdx.library.model.v2.SpdxDocument spdxDocument, org.spdx.library.model.v2.SpdxPackage spdxPackage) throws SpdxCompareException, org.spdx.core.InvalidSPDXAnalysisExceptionAdd a package to the comparer and performs the comparison to any existing documents- Parameters:
spdxDocument- document containing the packagespdxPackage- packaged to be added- Throws:
SpdxCompareException- on compare errorsorg.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
isInProgress
public boolean isInProgress()
- Overrides:
isInProgressin classSpdxItemComparer- Returns:
- the inProgress
-
isDifferenceFound
public boolean isDifferenceFound() throws SpdxCompareException- Overrides:
isDifferenceFoundin classSpdxItemComparer- Returns:
- the differenceFound
- Throws:
SpdxCompareException- on compare errors
-
checkInProgress
protected void checkInProgress() throws SpdxCompareExceptionchecks to make sure there is not a compare in progress- Overrides:
checkInProgressin classSpdxItemComparer- Throws:
SpdxCompareException- on compare errors
-
isPackageVersionsEquals
public boolean isPackageVersionsEquals() throws SpdxCompareException- Returns:
- the packageVersionsEquals
- Throws:
SpdxCompareException- on compare errors
-
isPackageFilenamesEquals
public boolean isPackageFilenamesEquals() throws SpdxCompareException- Returns:
- the packageFilenamesEquals
- Throws:
SpdxCompareException
-
isPackageSuppliersEquals
public boolean isPackageSuppliersEquals() throws SpdxCompareException- Returns:
- the packageSuppliersEquals
- Throws:
SpdxCompareException
-
isPackageDownloadLocationsEquals
public boolean isPackageDownloadLocationsEquals() throws SpdxCompareException- Returns:
- the packageDownloadLocationsEquals
- Throws:
SpdxCompareException
-
isPackageVerificationCodesEquals
public boolean isPackageVerificationCodesEquals() throws SpdxCompareException- Returns:
- the packageVerificationCodesEquals
- Throws:
SpdxCompareException
-
isFilesAnalyzedEquals
public boolean isFilesAnalyzedEquals() throws SpdxCompareException- Returns:
- the filesAnalyzedEquals
- Throws:
SpdxCompareException- on compare errors
-
isPackageChecksumsEquals
public boolean isPackageChecksumsEquals() throws SpdxCompareException- Returns:
- the packageChecksumsEquals
- Throws:
SpdxCompareException
-
isPackageSourceInfosEquals
public boolean isPackageSourceInfosEquals() throws SpdxCompareException- Returns:
- the packageSourceInfosEquals
- Throws:
SpdxCompareException
-
isDeclaredLicensesEquals
public boolean isDeclaredLicensesEquals() throws SpdxCompareException- Returns:
- the declaredLicensesEquals
- Throws:
SpdxCompareException
-
isPackageSummaryEquals
public boolean isPackageSummaryEquals() throws SpdxCompareException- Returns:
- the packageSummaryEquals
- Throws:
SpdxCompareException
-
isPackageDescriptionsEquals
public boolean isPackageDescriptionsEquals() throws SpdxCompareException- Returns:
- the packageDescriptionsEquals
- Throws:
SpdxCompareException
-
isPackageOriginatorsEqual
public boolean isPackageOriginatorsEqual() throws SpdxCompareException- Returns:
- the packageOriginatorsEqual
- Throws:
SpdxCompareException
-
isPackageHomePagesEquals
public boolean isPackageHomePagesEquals() throws SpdxCompareException- Returns:
- the packageHomePagesEquals
- Throws:
SpdxCompareException
-
isExternalRefsEquals
public boolean isExternalRefsEquals() throws SpdxCompareException- Returns:
- the externalRefsEquals
- Throws:
SpdxCompareException- on compare errors
-
getDocPackage
public org.spdx.library.model.v2.SpdxPackage getDocPackage(org.spdx.library.model.v2.SpdxDocument document)
Return the package associated with the document- Parameters:
document- document- Returns:
- The package associated with the document
-
getUniqueChecksums
public List<org.spdx.library.model.v2.Checksum> getUniqueChecksums(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
Get the checksums which are present in document A but not in document B- Returns:
- the uniqueChecksums
- Throws:
SpdxCompareException
-
getUniqueExternalRefs
public List<org.spdx.library.model.v2.ExternalRef> getUniqueExternalRefs(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
- Throws:
SpdxCompareException
-
getExternalRefDifferences
public List<SpdxExternalRefDifference> getExternalRefDifferences(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
- Throws:
SpdxCompareException
-
isPackageFilesEquals
public boolean isPackageFilesEquals() throws SpdxCompareException- Returns:
- the packageFilesEquals
- Throws:
SpdxCompareException
-
getFileDifferences
public List<SpdxFileDifference> getFileDifferences(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
Get any fileDifferences which are in docA but not in docB- Parameters:
docA- A document to comparedocB- B document compare- Returns:
- any fileDifferences which are in docA but not in docB
- Throws:
SpdxCompareException
-
getUniqueFiles
public List<org.spdx.library.model.v2.SpdxFile> getUniqueFiles(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
Return any unique files by name which are in docA but not in docB- Parameters:
docA- A document to comparedocB- B document compare- Returns:
- any unique files by name which are in docA but not in docB
- Throws:
SpdxCompareException
-
getPackageName
public String getPackageName() throws SpdxCompareException
- Returns:
- package name
- Throws:
SpdxCompareException
-
getNumPackages
public int getNumPackages() throws SpdxCompareException- Returns:
- number of package
- Throws:
SpdxCompareException- on compare errors
-
-