Class SpdxSnippetComparer
java.lang.Object
org.spdx.utility.compare.SpdxItemComparer
org.spdx.utility.compare.SpdxSnippetComparer
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDocumentSnippet(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 voidchecks to make sure there is not a compare in progressorg.spdx.library.model.v2.SpdxSnippetgetDocSnippet(org.spdx.library.model.v2.SpdxDocument spdxDocument) intgetSnippetFromFileDifference(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, they are considered unique files and the getUniqueSnippetFromFile should be called to obtain the unique fileorg.spdx.library.model.v2.SpdxFilegetUniqueSnippetFromFile(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) Get an SpdxFile that only exists in docA but not docBbooleanbooleanbooleanbooleanbooleanThe 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, isLicenseCommentsEquals, isLicenseCommmentsEquals, isRelationshipsEquals, isSeenLicenseEquals
-
Constructor Details
-
SpdxSnippetComparer
-
-
Method Details
-
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- on SPDX parsing errorsSpdxCompareException
-
isDifferenceFound
- Overrides:
isDifferenceFoundin classSpdxItemComparer- Returns:
- the differenceFound
- Throws:
SpdxCompareException- on compare errors
-
checkInProgress
checks to make sure there is not a compare in progress- Overrides:
checkInProgressin classSpdxItemComparer- Throws:
SpdxCompareException- on compare errors
-
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, they are considered unique files and the getUniqueSnippetFromFile should be called to obtain the unique file- Parameters:
docA- A document to comparedocB- B document to compare- 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 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- A document to comparedocB- B document to compare- Returns:
- an SpdxFile that only exists in docA but not docB
- 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- document containing the snippet- Returns:
- snippet in the spdxDocument
-