in apache-rat-core/src/main/java/org/apache/rat/analysis/license/FullTextMatchingLicense.java [77:109]
public boolean match(Document subject, String line) throws RatHeaderAnalysisException {
final String inputToMatch = prune(line).toLowerCase(Locale.ENGLISH);
if (seenFirstLine) { // Accumulate more input
buffer.append(inputToMatch);
} else {
int offset = inputToMatch.indexOf(firstLine);
if (offset >= 0) {
// we have a match, save the text starting with the match
buffer.append(inputToMatch.substring(offset));
seenFirstLine = true;
// Drop out to check whether full text is matched
} else {
// we assume that the first line must appear in a single line
return false; // no more to do here
}
}
if (buffer.length() >= fullText.length()) { // we have enough data to match
if (buffer.toString().contains(fullText)) {
reportOnLicense(subject);
return true; // we found a match
} else { // buffer contains first line but does not contain full text
// It's possible that the buffer contains the first line again
int offset = buffer.substring(1).indexOf(firstLine);
if (offset >= 0) { // first line found again
buffer.delete(0,offset); // reset buffer to the new start
} else { // buffer does not even contain first line, so cannot be used to match full text
init();
}
}
}
return false;
}