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
  • Constructor Details

    • 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 Details

    • addDocumentPackage

      public void addDocumentPackage(org.spdx.library.model.v2.SpdxDocument spdxDocument, org.spdx.library.model.v2.SpdxPackage spdxPackage) throws SpdxCompareException, org.spdx.core.InvalidSPDXAnalysisException
      Add a package to the comparer and performs the comparison to any existing documents
      Parameters:
      spdxDocument - document containing the package
      spdxPackage - packaged to be added
      Throws:
      SpdxCompareException - on compare errors
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors
    • isInProgress

      public boolean isInProgress()
      Overrides:
      isInProgress in class SpdxItemComparer
      Returns:
      the inProgress
    • isDifferenceFound

      public boolean isDifferenceFound() throws SpdxCompareException
      Overrides:
      isDifferenceFound in class SpdxItemComparer
      Returns:
      the differenceFound
      Throws:
      SpdxCompareException - on compare errors
    • checkInProgress

      protected void checkInProgress() throws SpdxCompareException
      checks to make sure there is not a compare in progress
      Overrides:
      checkInProgress in class SpdxItemComparer
      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 compare
      docB - 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 compare
      docB - 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