@@ -130,8 +130,19 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
130130 }
131131 Map <Integer , LineColumn > tokenToLocationA = new HashMap <>();
132132 Map <Integer , LineColumn > tokenToLocationB = new HashMap <>();
133- String [] licenseATokens = tokenizeLicenseText (licenseTextA ,tokenToLocationA );
134- String [] licenseBTokens = tokenizeLicenseText (licenseTextB ,tokenToLocationB );
133+ return isLicenseTextEquivalent (tokenizeLicenseText (licenseTextA ,tokenToLocationA ),
134+ tokenizeLicenseText (licenseTextB ,tokenToLocationB ));
135+ }
136+
137+ /**
138+ * Returns true if two sets of license tokens is considered a match per
139+ * the SPDX License matching guidelines documented at spdx.org (currently <a href="https://spdx.github.io/spdx-spec/v2.3/license-matching-guidelines-and-templates/">license matching guidelines</a>)
140+ * There are 2 unimplemented features - bullets/numbering is not considered and comments with no whitespace between text is not skipped
141+ * @param licenseATokens normalized license tokens to compare
142+ * @param licenseBTokens normalized license tokens to compare
143+ * @return true if the license text is equivalent
144+ */
145+ public static boolean isLicenseTextEquivalent (String [] licenseATokens , String [] licenseBTokens ) {
135146 int bTokenCounter = 0 ;
136147 int aTokenCounter = 0 ;
137148 String nextAToken = getTokenAt (licenseATokens , aTokenCounter ++);
@@ -145,7 +156,7 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
145156 if (nextAToken != null ) {
146157 return false ; // there is more stuff in the license text B, so not equal
147158 }
148- } else if (tokensEquivalent (nextAToken , nextBToken )) {
159+ } else if (tokensEquivalent (nextAToken , nextBToken )) {
149160 // just move onto the next set of tokens
150161 nextAToken = getTokenAt (licenseATokens , aTokenCounter ++);
151162 nextBToken = getTokenAt (licenseBTokens , bTokenCounter ++);
@@ -167,7 +178,7 @@ public static boolean isLicenseTextEquivalent(String licenseTextA, String licens
167178 }
168179 }
169180 // need to make sure B is at the end
170- while (canSkip (nextBToken )) {
181+ while (canSkip (nextBToken )) {
171182 nextBToken = getTokenAt (licenseBTokens , bTokenCounter ++);
172183 }
173184 return (nextBToken == null );
0 commit comments