Package org.spdx.utility.compare
Class SpdxSnippetComparer
java.lang.Object
org.spdx.utility.compare.SpdxItemComparer
org.spdx.utility.compare.SpdxSnippetComparer
public class SpdxSnippetComparer extends SpdxItemComparer
Compares two SPDX snippets. The
compare(snippetA, snippetB) 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 -
Constructor Summary
Constructors Constructor Description SpdxSnippetComparer(Map<SpdxDocument,Map<SpdxDocument,Map<String,String>>> extractedLicenseIdMap) -
Method Summary
Modifier and Type Method Description voidaddDocumentSnippet(SpdxDocument spdxDocument, SpdxSnippet snippet)Add a snippet to the comparer and performs the comparison to any existing documentsprotected voidcheckInProgress()checks to make sure there is not a compare in progressSpdxSnippetgetDocSnippet(SpdxDocument spdxDocument)intgetNumSnippets()SpdxFileDifferencegetSnippetFromFileDifference(SpdxDocument docA, SpdxDocument docB)Get any file difference for the Spdx Snippet From File between the two SPDX documents If the fileName is different, the they are considered unique files and the getUniqueSnippetFromFile should be called to obtain the unique fileSpdxFilegetUniqueSnippetFromFile(SpdxDocument docA, SpdxDocument docB)Get an SpdxFile that only exists in docA but not docBbooleanisByteRangeEquals()booleanisDifferenceFound()booleanisLineRangeEquals()booleanisNameEquals()booleanisSnippetFromFilesEquals()The snippetFromFiles can be true if there are some unique snippetFromFiles or differences between the snippetFromFiles (or both)Methods inherited from class org.spdx.utility.compare.SpdxItemComparer
addDocumentItem, checkCompareMade, getItem, getUniqueAnnotations, getUniqueRelationship, getUniqueSeenLicenses, isAnnotationsEquals, isAttributionTextEquals, isCommentsEquals, isConcludedLicenseEquals, isCopyrightsEquals, isInProgress, isLicenseCommmentsEquals, isRelationshipsEquals, isSeenLicenseEquals
-
Constructor Details
-
SpdxSnippetComparer
public SpdxSnippetComparer(Map<SpdxDocument,Map<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
-
addDocumentSnippet
public void addDocumentSnippet(SpdxDocument spdxDocument, SpdxSnippet snippet) throws SpdxCompareException, InvalidSPDXAnalysisExceptionAdd a snippet to the comparer and performs the comparison to any existing documents- Parameters:
spdxDocument- document containing the packagesnippet- snippet to be added- Throws:
InvalidSPDXAnalysisExceptionSpdxCompareException
-
isDifferenceFound
- Overrides:
isDifferenceFoundin classSpdxItemComparer- Returns:
- the differenceFound
- Throws:
SpdxCompareException
-
checkInProgress
checks to make sure there is not a compare in progress- Overrides:
checkInProgressin classSpdxItemComparer- Throws:
SpdxCompareException
-
getSnippetFromFileDifference
public SpdxFileDifference getSnippetFromFileDifference(SpdxDocument docA, SpdxDocument docB) throws SpdxCompareExceptionGet any file difference for the Spdx Snippet From File between the two SPDX documents If the fileName is different, the they are considered unique files and the getUniqueSnippetFromFile should be called to obtain the unique file- Parameters:
docA-docB-- Returns:
- the file difference or null if there is no file difference
- Throws:
SpdxCompareException
-
isByteRangeEquals
- Returns:
- the byteRangeEquals
- Throws:
SpdxCompareException
-
isLineRangeEquals
- Returns:
- the lineRangeEquals
- Throws:
SpdxCompareException
-
isSnippetFromFilesEquals
The snippetFromFiles can be true if there are some unique snippetFromFiles or differences between the snippetFromFiles (or both)- Returns:
- the snippetFromFilesEquals
- Throws:
SpdxCompareException
-
isNameEquals
- Returns:
- the nameEquals
- Throws:
SpdxCompareException
-
getUniqueSnippetFromFile
public SpdxFile getUniqueSnippetFromFile(SpdxDocument docA, SpdxDocument docB) throws SpdxCompareExceptionGet an SpdxFile that only exists in docA but not docB- Parameters:
docA-docB-- Returns:
- Throws:
SpdxCompareException
-
getNumSnippets
public int getNumSnippets()- Returns:
- Total number of snippets
-
getDocSnippet
- Parameters:
spdxDocument-- Returns:
-