Class SpdxFileComparer


  • public class SpdxFileComparer
    extends SpdxItemComparer
    Compares two SPDX files. The compare(fileA, fileB) method will perform the comparison and store the results. isDifferenceFound() will return true of any differences were found.
    Author:
    Gary O'Neall
    • Constructor Detail

      • SpdxFileComparer

        public SpdxFileComparer​(Map<org.spdx.library.model.v2.SpdxDocument,​Map<org.spdx.library.model.v2.SpdxDocument,​Map<String,​String>>> extractedLicenseIdMap)
    • Method Detail

      • addDocumentFile

        public void addDocumentFile​(org.spdx.library.model.v2.SpdxDocument spdxDocument,
                                    org.spdx.library.model.v2.SpdxFile spdxFile)
                             throws SpdxCompareException,
                                    org.spdx.core.InvalidSPDXAnalysisException
        Add a file to the comparer and compare to the existing files
        Parameters:
        spdxDocument - document containing the file
        spdxFile - file to add
        Throws:
        SpdxCompareException - on compare errors
        org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors
      • 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 the file contained document A but not in document B
        Parameters:
        docA - document to compare
        docB - document to compare
        Returns:
        the checksums which are present in the file contained document A but not in document B
        Throws:
        SpdxCompareException - on compare errors
      • getFileDifference

        public SpdxFileDifference getFileDifference​(org.spdx.library.model.v2.SpdxDocument docA,
                                                    org.spdx.library.model.v2.SpdxDocument docB)
                                             throws SpdxCompareException
        Return a file difference for the file contained in two different documents
        Parameters:
        docA - document containing files to compare
        docB - document containing files to compare
        Returns:
        file differences between docA and docB
        Throws:
        SpdxCompareException - on compare errors