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 |
|---|---|
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 |
|---|---|
void |
compare(SPDXDocument[] compareDocs)
Compares multiple SPDX documents
|
void |
compare(SPDXDocument doc1,
SPDXDocument doc2)
Compares 2 SPDX documents
|
boolean |
compareLicense(int doc1,
SPDXLicenseInfo license1,
int doc2,
SPDXLicenseInfo 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.
|
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() |
SpdxComparer.SPDXReviewDifference[] |
getReviewerDifferences(int docindex1,
int docindex2)
Get all reviewer differences between two documents.
|
SPDXDocument |
getSpdxDoc(int docIndex) |
String[] |
getUniqueCreators(int doc1index,
int doc2index)
Returns any creators which are in the SPDX document 1 which are not in document 2
|
SPDXNonStandardLicense[] |
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
|
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 |
isCopyrightTextsEqual() |
boolean |
isCreatorInformationEqual() |
boolean |
isDataLicenseEqual() |
boolean |
isDifferenceFound() |
boolean |
isDocumentCommentsEqual() |
boolean |
isExtractedLicensingInfosEqual() |
boolean |
isfilesEquals() |
boolean |
isLicenseCommentsEqual() |
boolean |
isLicenseListVersionEqual() |
boolean |
isPackageChecksumsEqual() |
boolean |
isPackageConcludedLicensesEqual() |
boolean |
isPackageDeclaredLicensesEqual() |
boolean |
isPackageDescriptionsEqual() |
boolean |
isPackageDownloadLocationsEqual() |
boolean |
isPackageEqual() |
boolean |
isPackageFileNamesEqual() |
boolean |
ispackageHomePagesEqual() |
boolean |
isPackageLicenseInfoFromFilesEqual() |
boolean |
isPackageNamesEqual() |
boolean |
isPackageOriginatorsEqual() |
boolean |
isPackageSummariesEqual() |
boolean |
isPackageSuppliersEqual() |
boolean |
isPackageVerificationCodesEqual() |
boolean |
isPackageVersionsEqual() |
boolean |
isReviewersEqual() |
boolean |
isSourceInformationEqual() |
boolean |
isSpdxVersionEqual() |
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 doc1, SPDXDocument doc2) throws InvalidSPDXAnalysisException, SpdxCompareException
doc1 - doc2 - InvalidSPDXAnalysisExceptionSpdxCompareExceptionpublic void compare(SPDXDocument[] compareDocs) throws InvalidSPDXAnalysisException, SpdxCompareException
compareDocs - SpdxCompareExceptionInvalidSPDXAnalysisExceptionpublic boolean compareLicense(int doc1,
SPDXLicenseInfo license1,
int doc2,
SPDXLicenseInfo license2)
throws SpdxCompareException
doc1 - Index of the SPDX document for license1license1 - doc2 - Index of the SPDX document for license2license2 - SpdxCompareExceptionpublic 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 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 SPDXNonStandardLicense[] getUniqueExtractedLicenses(int docIndexA, int docIndexB) throws SpdxCompareException
docIndexA - docIndexB - SpdxCompareExceptionpublic SpdxLicenseDifference[] getExtractedLicenseDifferences(int docIndexA, int docIndexB) throws SpdxCompareException
docIndexA - docIndexB - SpdxCompareExceptionpublic boolean isPackageEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageNamesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageVersionsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageLicenseInfoFromFilesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageFileNamesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageSuppliersEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageOriginatorsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageDownloadLocationsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageVerificationCodesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageChecksumsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isSourceInformationEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageDeclaredLicensesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageConcludedLicensesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isLicenseCommentsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isCopyrightTextsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageSummariesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isPackageDescriptionsEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isCreatorInformationEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic String[] getUniqueCreators(int doc1index, int doc2index) throws SpdxCompareException
doc1index - doc2index - SpdxCompareExceptionpublic boolean isfilesEquals()
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 int getNumSpdxDocs()
public boolean ispackageHomePagesEqual()
throws SpdxCompareException
SpdxCompareExceptionpublic boolean isLicenseListVersionEqual()
throws SpdxCompareException
SpdxCompareExceptionCopyright © 2014 Linux Foundation. All Rights Reserved.