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. Thecompare(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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDocumentSnippet(org.spdx.library.model.v2.SpdxDocument spdxDocument, org.spdx.library.model.v2.SpdxSnippet snippet)
Add a snippet to the comparer and performs the comparison to any existing documentsprotected void
checkInProgress()
checks to make sure there is not a compare in progressorg.spdx.library.model.v2.SpdxSnippet
getDocSnippet(org.spdx.library.model.v2.SpdxDocument spdxDocument)
int
getNumSnippets()
SpdxFileDifference
getSnippetFromFileDifference(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.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 fileorg.spdx.library.model.v2.SpdxFile
getUniqueSnippetFromFile(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)
Get an SpdxFile that only exists in docA but not docBboolean
isByteRangeEquals()
boolean
isDifferenceFound()
boolean
isLineRangeEquals()
boolean
isNameEquals()
boolean
isSnippetFromFilesEquals()
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 Detail
-
SpdxSnippetComparer
public SpdxSnippetComparer(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
-
addDocumentSnippet
public void addDocumentSnippet(org.spdx.library.model.v2.SpdxDocument spdxDocument, org.spdx.library.model.v2.SpdxSnippet snippet) throws SpdxCompareException, org.spdx.core.InvalidSPDXAnalysisException
Add a snippet to the comparer and performs the comparison to any existing documents- Parameters:
spdxDocument
- document containing the packagesnippet
- snippet to be added- Throws:
org.spdx.core.InvalidSPDXAnalysisException
SpdxCompareException
-
isDifferenceFound
public boolean isDifferenceFound() throws SpdxCompareException
- Overrides:
isDifferenceFound
in classSpdxItemComparer
- Returns:
- the differenceFound
- Throws:
SpdxCompareException
-
checkInProgress
protected void checkInProgress() throws SpdxCompareException
checks to make sure there is not a compare in progress- Overrides:
checkInProgress
in classSpdxItemComparer
- Throws:
SpdxCompareException
-
getSnippetFromFileDifference
public SpdxFileDifference getSnippetFromFileDifference(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
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 file- Parameters:
docA
-docB
-- Returns:
- the file difference or null if there is no file difference
- Throws:
SpdxCompareException
-
isByteRangeEquals
public boolean isByteRangeEquals() throws SpdxCompareException
- Returns:
- the byteRangeEquals
- Throws:
SpdxCompareException
-
isLineRangeEquals
public boolean isLineRangeEquals() throws SpdxCompareException
- Returns:
- the lineRangeEquals
- Throws:
SpdxCompareException
-
isSnippetFromFilesEquals
public boolean isSnippetFromFilesEquals() throws SpdxCompareException
The snippetFromFiles can be true if there are some unique snippetFromFiles or differences between the snippetFromFiles (or both)- Returns:
- the snippetFromFilesEquals
- Throws:
SpdxCompareException
-
isNameEquals
public boolean isNameEquals() throws SpdxCompareException
- Returns:
- the nameEquals
- Throws:
SpdxCompareException
-
getUniqueSnippetFromFile
public org.spdx.library.model.v2.SpdxFile getUniqueSnippetFromFile(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
Get 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
public org.spdx.library.model.v2.SpdxSnippet getDocSnippet(org.spdx.library.model.v2.SpdxDocument spdxDocument)
- Parameters:
spdxDocument
-- Returns:
-
-