public class LicenseCompareHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static Map<String,String> |
NORMALIZE_TOKENS |
protected static com.google.common.collect.ImmutableSet<String> |
PUNCTUATION |
protected static com.google.common.collect.ImmutableSet<String> |
SKIPPABLE_TOKENS |
protected static Pattern |
TOKEN_SPLIT_PATTERN |
protected static String |
TOKEN_SPLIT_REGEX |
| Constructor and Description |
|---|
LicenseCompareHelper() |
| Modifier and Type | Method and Description |
|---|---|
static String |
getFirstLicenseToken(String text) |
static boolean |
isLicenseEqual(AnyLicenseInfo license1,
AnyLicenseInfo license2,
Map<String,String> xlationMap)
Compares two licenses from potentially two different documents which may have
different license ID's for the same license
|
static boolean |
isLicenseTextEquivalent(String licenseTextA,
String licenseTextB)
Returns true if two sets of license text is considered a match per
the SPDX License matching guidelines documented at spdx.org (currently http://spdx.org/wiki/spdx-license-list-match-guidelines)
There are 2 unimplemented features - bullets/numbering is not considered and comments with no whitespace between text is not skipped
|
static boolean |
isSingleTokenString(String text) |
static CompareTemplateOutputHandler.DifferenceDescription |
isTextStandardException(LicenseException exception,
String compareText)
Compares exception text to the exception text of an SPDX Standard exception
|
static CompareTemplateOutputHandler.DifferenceDescription |
isTextStandardLicense(License license,
String compareText)
Compares license text to the license text of an SPDX Standard License
|
static String |
locateOriginalText(String fullLicenseText,
int startToken,
int endToken,
Map<Integer,LineColumn> tokenToLocation,
String[] tokens)
Locate the original text starting with the start token and ending with the end token
|
static String[] |
matchingStandardLicenseIds(String licenseText)
Returns a list of SPDX Standard License ID's that match the text provided using
the SPDX matching guidelines.
|
static String[] |
tokenizeLicenseText(String licenseText,
Map<Integer,LineColumn> tokenToLocation)
Tokenizes the license text, normalizes quotes, lowercases and converts multi-words for better equiv.
|
protected static final String TOKEN_SPLIT_REGEX
protected static final Pattern TOKEN_SPLIT_PATTERN
protected static final com.google.common.collect.ImmutableSet<String> PUNCTUATION
protected static final com.google.common.collect.ImmutableSet<String> SKIPPABLE_TOKENS
public static boolean isLicenseTextEquivalent(String licenseTextA, String licenseTextB)
licenseTextA - licenseTextB - public static String locateOriginalText(String fullLicenseText, int startToken, int endToken, Map<Integer,LineColumn> tokenToLocation, String[] tokens)
fullLicenseText - startToken - endToken - tokenToLocation - public static String[] tokenizeLicenseText(String licenseText, Map<Integer,LineColumn> tokenToLocation)
tokenLocations - location for all of the tokenslicenseText - IOExceptionpublic static String getFirstLicenseToken(String text)
text - public static boolean isSingleTokenString(String text)
text - public static boolean isLicenseEqual(AnyLicenseInfo license1, AnyLicenseInfo license2, Map<String,String> xlationMap) throws SpdxCompareException
license1 - license2 - xlationMap - Mapping the license ID's from license 1 to license 2SpdxCompareExceptionpublic static CompareTemplateOutputHandler.DifferenceDescription isTextStandardLicense(License license, String compareText) throws SpdxCompareException
license - SPDX Standard License to comparecompareText - Text to compare to the standard licenseSpdxCompareExceptionpublic static CompareTemplateOutputHandler.DifferenceDescription isTextStandardException(LicenseException exception, String compareText) throws SpdxCompareException
exception - SPDX Standard exception to comparecompareText - Text to compare to the standard exceptionsSpdxCompareExceptionpublic static String[] matchingStandardLicenseIds(String licenseText) throws InvalidSPDXAnalysisException, SpdxCompareException
licenseText - Text to compare to the standard license textsInvalidSPDXAnalysisException - If an error occurs accessing the standard licensesSpdxCompareException - If an error occurs in the comparisonCopyright © 2018 Linux Foundation. All Rights Reserved.