public class SpdxComparer extends Object
compare(spdxdoc1, spdxdoc2)
For reviewers, the comparison results are separated into unique reviewers for a give document
which can be obtained by the method getUniqueReviewers(index1, index2). The
uniqueness is determined by the reviewer name. If two documents contain reviewers with the
same name but different dates or comments, the reviews are considered to be the same review
with different data. The differences for these reviews can be obtained through the method
getReviewerDifferences(index1, index2)
For files, the comparison results are separated into unique files based on the file names
which can be obtained by the method getUniqueFiles(index1, index2). If two
documents contain files with the same name, but different data, the differences for these
files can be obtained through the method getFileDifferences(index1, index2)
Multi-threading considerations: This class is "mostly" threadsafe in that the calls to
perform the comparison are synchronized and a flag is used to throw an error for any
calls to getters when a compare is in progress. There is a small theoretical window in the
getters where the compare operation is started in the middle of a get operation.| Modifier and Type | Class and Description |
|---|---|
static class |
SpdxComparer.SPDXReviewDifference
Contains the results of a comparison between two SPDXReviews where
the reviewer name is the same but there is a difference in the
reviewer comment or the reviewer date
|
| Constructor and Description |
|---|
SpdxComparer() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
arraysEqual(Object[] a1,
Object[] a2)
Compare two object arrays
|
protected SpdxFile[] |
collectAllFiles(SpdxDocument spdxDocument)
Collect all of the files present in the SPDX document including files within documents
and files embedded in packages
|
protected SpdxPackage[] |
collectAllPackages(SpdxDocument spdxDocument)
Collect all of the packages present in the SPDX document including packages
embedded in other relationships within documents
|
void |
compare(SpdxDocument[] spdxDocuments)
Compares multiple SPDX documents
|
void |
compare(SpdxDocument spdxDoc1,
SpdxDocument spdxDoc2)
Compares 2 SPDX documents
|
boolean |
compareLicense(int doc1,
AnyLicenseInfo license1,
int doc2,
AnyLicenseInfo license2)
Compares two licenses from two different SPDX documents taking into account
the extracted license infos who's ID's may be different between the two documents
Note: The ExtracedLicenseIDMap must be initialized before this method is invoked
|
static int |
compareStrings(String stringA,
String stringB)
Compares two strings including trimming the string and taking into account
they may be null.
|
static boolean |
elementsEquivalent(RdfModelObject[] elementsA,
RdfModelObject[] elementsB)
Returns true if two arrays of SPDX elements contain equivalent elements
|
static boolean |
elementsEquivalent(RdfModelObject elementA,
RdfModelObject elementB) |
static Annotation[] |
findUniqueAnnotations(Annotation[] annotationsA,
Annotation[] annotationsB)
Find any SPDX annotations which are in annotationsA but not in annotationsB
|
static Checksum[] |
findUniqueChecksums(Checksum[] checksumsA,
Checksum[] checksumsB)
Find any SPDX checksums which are in elementsA but not in elementsB
|
static ExternalDocumentRef[] |
findUniqueExternalDocumentRefs(ExternalDocumentRef[] externalDocRefsA,
ExternalDocumentRef[] externalDocRefsB)
Find unique relationships that are present in relationshipsA but not relationshipsB
|
static Relationship[] |
findUniqueRelationships(Relationship[] relationshipsA,
Relationship[] relationshipsB)
Find unique relationships that are present in relationshipsA but not relationshipsB
|
SpdxLicenseDifference[] |
getExtractedLicenseDifferences(int docIndexA,
int docIndexB)
Retrieves any licenses which where the text matches in both documents but
other fields are different
|
SpdxFileDifference[] |
getFileDifferences(int docindex1,
int docindex2)
Returns any file differences found between the first and second SPDX documents
as specified by the document index
|
int |
getNumSpdxDocs() |
SpdxPackageComparer[] |
getPackageComparers() |
SpdxPackageComparer[] |
getPackageDifferences() |
SpdxComparer.SPDXReviewDifference[] |
getReviewerDifferences(int docindex1,
int docindex2)
Get all reviewer differences between two documents.
|
SpdxSnippetComparer[] |
getSnippetComparers() |
SpdxDocument |
getSpdxDoc(int docIndex) |
SpdxDocument[] |
getSpdxDocuments() |
String[] |
getUniqueCreators(int doc1index,
int doc2index)
Returns any creators which are in the SPDX document 1 which are not in document 2
|
Annotation[] |
getUniqueDocumentAnnotations(int docindex1,
int docindex2)
Return any document annotations which are in spdx document index 1 but not in spdx document index 2
|
Relationship[] |
getUniqueDocumentRelationship(int docindex1,
int docindex2)
Return any document annotations which are in spdx document index 1 but not in spdx document index 2
|
ExternalDocumentRef[] |
getUniqueExternalDocumentRefs(int docindex1,
int docindex2)
Return any external document references which are in spdx document index 1 but not in spdx document index 2
|
ExtractedLicenseInfo[] |
getUniqueExtractedLicenses(int docIndexA,
int docIndexB)
Retrieves any unique extracted licenses fromt the first SPDX document index
relative to the second - unique is determined by the license text matching
|
SpdxFile[] |
getUniqueFiles(int docindex1,
int docindex2)
Return any files which are in spdx document index 1 but not in spdx document index 2
|
SpdxPackage[] |
getUniquePackages(int docindex1,
int docindex2)
Return any files which are in spdx document index 1 but not in spdx document index 2
|
SPDXReview[] |
getUniqueReviewers(int docindex1,
int docindex2)
Get all unique reviewers in SPDX document at index 1 relative to reviewers
in SPDX Document at index 2
|
boolean |
isCreatorInformationEqual() |
boolean |
isDataLicenseEqual() |
boolean |
isDifferenceFound() |
boolean |
isDocumentAnnotationsEquals() |
boolean |
isDocumentCommentsEqual() |
boolean |
isDocumentContentsEquals() |
boolean |
isDocumentRelationshipsEquals() |
boolean |
isExternalDcoumentRefsEquals() |
boolean |
isExtractedLicensingInfosEqual() |
boolean |
isfilesEquals() |
boolean |
isLicenseListVersionEqual() |
boolean |
isPackagesEquals() |
boolean |
isReviewersEqual() |
boolean |
isSnippetsEqual() |
boolean |
isSpdxVersionEqual() |
static boolean |
objectsEqual(Object o1,
Object o2)
returns true if the two objects are equal considering nulls
|
static boolean |
stringsEqual(String stringA,
String stringB)
Compares two strings returning true if they are equal
considering null values and trimming the strings.
|
public void compare(SpdxDocument spdxDoc1, SpdxDocument spdxDoc2) throws InvalidSPDXAnalysisException, SpdxCompareException
spdxDoc1 - spdxDoc2 - InvalidSPDXAnalysisExceptionSpdxCompareExceptionpublic void compare(SpdxDocument[] spdxDocuments) throws InvalidSPDXAnalysisException, SpdxCompareException
spdxDocuments - SpdxCompareExceptionInvalidSPDXAnalysisExceptionprotected SpdxPackage[] collectAllPackages(SpdxDocument spdxDocument) throws InvalidSPDXAnalysisException
spdxDocument - InvalidSPDXAnalysisExceptionprotected SpdxFile[] collectAllFiles(SpdxDocument spdxDocument) throws InvalidSPDXAnalysisException
spdxDocument - InvalidSPDXAnalysisExceptionpublic boolean compareLicense(int doc1,
AnyLicenseInfo license1,
int doc2,
AnyLicenseInfo license2)
throws SpdxCompareException
doc1 - Index of the SPDX document for license1license1 - doc2 - Index of the SPDX document for license2license2 - SpdxCompareExceptionpublic static boolean objectsEqual(Object o1, Object o2)
o1 - o2 - public static boolean elementsEquivalent(RdfModelObject elementA, RdfModelObject elementB)
public static boolean arraysEqual(Object[] a1, Object[] a2)
a1 - a2 - public static boolean stringsEqual(String stringA, String stringB)
stringA - stringB - public static int compareStrings(String stringA, String stringB)
stringA - stringB - public boolean isDifferenceFound()
public boolean isSpdxVersionEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic SpdxDocument getSpdxDoc(int docIndex) throws SpdxCompareException
docIndex - Reference to which document number - 0 is the first document parameter in compareSpdxCompareExceptionpublic boolean isDataLicenseEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isDocumentCommentsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isReviewersEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isExternalDcoumentRefsEquals()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isExtractedLicensingInfosEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic SPDXReview[] getUniqueReviewers(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic SpdxComparer.SPDXReviewDifference[] getReviewerDifferences(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic ExtractedLicenseInfo[] getUniqueExtractedLicenses(int docIndexA, int docIndexB) throws SpdxCompareException
docIndexA - docIndexB - SpdxCompareExceptionpublic SpdxLicenseDifference[] getExtractedLicenseDifferences(int docIndexA, int docIndexB) throws SpdxCompareException
docIndexA - docIndexB - SpdxCompareExceptionpublic boolean isCreatorInformationEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic String[] getUniqueCreators(int doc1index, int doc2index) throws SpdxCompareException
doc1index - doc2index - SpdxCompareExceptionpublic boolean isfilesEquals()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackagesEquals()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isDocumentAnnotationsEquals()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isDocumentRelationshipsEquals()
throws SpdxCompareException
SpdxCompareExceptionpublic SpdxFile[] getUniqueFiles(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic SpdxFileDifference[] getFileDifferences(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic SpdxPackage[] getUniquePackages(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic ExternalDocumentRef[] getUniqueExternalDocumentRefs(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic Annotation[] getUniqueDocumentAnnotations(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic Relationship[] getUniqueDocumentRelationship(int docindex1, int docindex2) throws SpdxCompareException
docindex1 - docindex2 - SpdxCompareExceptionpublic SpdxPackageComparer[] getPackageDifferences() throws SpdxCompareException
SpdxCompareExceptionpublic SpdxPackageComparer[] getPackageComparers()
public int getNumSpdxDocs()
public boolean isLicenseListVersionEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic static Checksum[] findUniqueChecksums(Checksum[] checksumsA, Checksum[] checksumsB)
checksumsA - checksumsB - public static Annotation[] findUniqueAnnotations(Annotation[] annotationsA, Annotation[] annotationsB)
annotationsA - annotationsB - public static boolean elementsEquivalent(RdfModelObject[] elementsA, RdfModelObject[] elementsB)
elementsA - elementsB - public static Relationship[] findUniqueRelationships(Relationship[] relationshipsA, Relationship[] relationshipsB)
relationshipsA - relationshipsB - public static ExternalDocumentRef[] findUniqueExternalDocumentRefs(ExternalDocumentRef[] externalDocRefsA, ExternalDocumentRef[] externalDocRefsB) throws InvalidSPDXAnalysisException
externalDocRefsA - externalDocRefsB - InvalidSPDXAnalysisExceptionpublic SpdxDocument[] getSpdxDocuments()
public boolean isDocumentContentsEquals()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isSnippetsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic SpdxSnippetComparer[] getSnippetComparers()
Copyright © 2017 Linux Foundation. All Rights Reserved.