Package org.spdx.utility.compare
Class SpdxItemComparer
- java.lang.Object
-
- org.spdx.utility.compare.SpdxItemComparer
-
- Direct Known Subclasses:
SpdxFileComparer
,SpdxPackageComparer
,SpdxSnippetComparer
public class SpdxItemComparer extends Object
Compares two SPDX items. Thecompare(itemA, itemB)
method will perform the comparison and store the results.isDifferenceFound()
will return true of any differences were found.- Author:
- Gary
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<org.spdx.library.model.v2.SpdxDocument,org.spdx.library.model.v2.SpdxItem>
documentItem
Map of SPDX document to Itemsprotected Map<org.spdx.library.model.v2.SpdxDocument,Map<org.spdx.library.model.v2.SpdxDocument,Map<String,String>>>
extractedLicenseIdMap
Mapping of all extracted license info ID's between all SPDX documents included in the comparerprotected String
name
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDocumentItem(org.spdx.library.model.v2.SpdxDocument spdxDocument, org.spdx.library.model.v2.SpdxItem spdxItem)
Add a new item to the comparer and compare the contents of the item to all items which have been previously addedprotected void
checkCompareMade()
protected void
checkInProgress()
checks to make sure there is not a compare in progressorg.spdx.library.model.v2.SpdxItem
getItem(org.spdx.library.model.v2.SpdxDocument doc)
Get the item contained by the document docList<org.spdx.library.model.v2.Annotation>
getUniqueAnnotations(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)
Get annotations that are in docA but not in docBList<org.spdx.library.model.v2.Relationship>
getUniqueRelationship(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)
Get relationships that are in docA but not in docBList<org.spdx.library.model.v2.license.AnyLicenseInfo>
getUniqueSeenLicenses(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB)
Get any licenses found in docA but not in docBboolean
isAnnotationsEquals()
boolean
isAttributionTextEquals()
boolean
isCommentsEquals()
boolean
isConcludedLicenseEquals()
boolean
isCopyrightsEquals()
boolean
isDifferenceFound()
boolean
isInProgress()
boolean
isLicenseCommmentsEquals()
boolean
isRelationshipsEquals()
boolean
isSeenLicenseEquals()
-
-
-
Method Detail
-
addDocumentItem
public void addDocumentItem(org.spdx.library.model.v2.SpdxDocument spdxDocument, org.spdx.library.model.v2.SpdxItem spdxItem) throws SpdxCompareException, org.spdx.core.InvalidSPDXAnalysisException
Add a new item to the comparer and compare the contents of the item to all items which have been previously added- Parameters:
spdxDocument
-spdxItem
-- Throws:
SpdxCompareException
org.spdx.core.InvalidSPDXAnalysisException
-
isConcludedLicenseEquals
public boolean isConcludedLicenseEquals() throws SpdxCompareException
- Returns:
- the concludedLicenseEquals
- Throws:
SpdxCompareException
-
isSeenLicenseEquals
public boolean isSeenLicenseEquals() throws SpdxCompareException
- Returns:
- the seenLicenseEquals
- Throws:
SpdxCompareException
-
getUniqueSeenLicenses
public List<org.spdx.library.model.v2.license.AnyLicenseInfo> getUniqueSeenLicenses(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
Get any licenses found in docA but not in docB- Parameters:
docA
-docB
-- Returns:
- Throws:
SpdxCompareException
-
isCommentsEquals
public boolean isCommentsEquals() throws SpdxCompareException
- Returns:
- the commentsEquals
- Throws:
SpdxCompareException
-
isCopyrightsEquals
public boolean isCopyrightsEquals() throws SpdxCompareException
- Returns:
- the copyrightsEquals
- Throws:
SpdxCompareException
-
isLicenseCommmentsEquals
public boolean isLicenseCommmentsEquals() throws SpdxCompareException
- Returns:
- the licenseCommmentsEquals
- Throws:
SpdxCompareException
-
checkInProgress
protected void checkInProgress() throws SpdxCompareException
checks to make sure there is not a compare in progress- Throws:
SpdxCompareException
-
checkCompareMade
protected void checkCompareMade() throws SpdxCompareException
- Throws:
SpdxCompareException
- if no comparisons have been made
-
isDifferenceFound
public boolean isDifferenceFound() throws SpdxCompareException
- Returns:
- Throws:
SpdxCompareException
-
isInProgress
public boolean isInProgress() throws SpdxCompareException
- Returns:
- the inProgress
- Throws:
SpdxCompareException
-
getItem
public org.spdx.library.model.v2.SpdxItem getItem(org.spdx.library.model.v2.SpdxDocument doc) throws SpdxCompareException
Get the item contained by the document doc- Parameters:
doc
-- Returns:
- Throws:
SpdxCompareException
-
isRelationshipsEquals
public boolean isRelationshipsEquals() throws SpdxCompareException
- Returns:
- the relationshipsEquals
- Throws:
SpdxCompareException
-
getUniqueRelationship
public List<org.spdx.library.model.v2.Relationship> getUniqueRelationship(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
Get relationships that are in docA but not in docB- Parameters:
docA
-docB
-- Returns:
- Throws:
SpdxCompareException
-
isAnnotationsEquals
public boolean isAnnotationsEquals() throws SpdxCompareException
- Returns:
- the annotationsEquals
- Throws:
SpdxCompareException
-
isAttributionTextEquals
public boolean isAttributionTextEquals() throws SpdxCompareException
- Returns:
- the attributionTextEquals
- Throws:
SpdxCompareException
-
getUniqueAnnotations
public List<org.spdx.library.model.v2.Annotation> getUniqueAnnotations(org.spdx.library.model.v2.SpdxDocument docA, org.spdx.library.model.v2.SpdxDocument docB) throws SpdxCompareException
Get annotations that are in docA but not in docB- Parameters:
docA
-docB
-- Returns:
- Throws:
SpdxCompareException
-
-