Package org.apache.rat.analysis.license
Class FullTextMatchingLicense
- java.lang.Object
-
- org.apache.rat.analysis.license.BaseLicense
-
- org.apache.rat.analysis.license.FullTextMatchingLicense
-
- All Implemented Interfaces:
IHeaderMatcher
- Direct Known Subclasses:
FullTextLicenseMatcher
,GPL1License
,GPL2License
,GPL3License
,MITLicense
,OASISLicense
public class FullTextMatchingLicense extends BaseLicense implements IHeaderMatcher
Accumulates all letters and numbers contained inside the header and compares it to the full text of a given license (after reducing it to letters and numbers as well).The text comparison is case insensitive but assumes only characters in the US-ASCII charset are being matched.
- Since:
- Rat 0.9
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuilder
buffer
private static int
DEFAULT_INITIAL_LINE_LENGTH
private java.lang.String
firstLine
private java.lang.String
fullText
private boolean
seenFirstLine
-
Constructor Summary
Constructors Modifier Constructor Description FullTextMatchingLicense()
protected
FullTextMatchingLicense(MetaData.Datum licenseFamilyCategory, MetaData.Datum licenseFamilyName, java.lang.String notes, java.lang.String fullText)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasFullText()
private void
init()
boolean
match(Document subject, java.lang.String line)
Matches the text accumulated to licenses.void
reset()
Resets this matches.void
setFullText(java.lang.String text)
-
Methods inherited from class org.apache.rat.analysis.license.BaseLicense
getLicenseFamilyCategory, getLicenseFamilyName, getNotes, prune, reportOnLicense, setLicenseFamilyCategory, setLicenseFamilyName, setNotes
-
-
-
-
Field Detail
-
DEFAULT_INITIAL_LINE_LENGTH
private static final int DEFAULT_INITIAL_LINE_LENGTH
- See Also:
- Constant Field Values
-
fullText
private java.lang.String fullText
-
firstLine
private java.lang.String firstLine
-
seenFirstLine
private boolean seenFirstLine
-
buffer
private final java.lang.StringBuilder buffer
-
-
Constructor Detail
-
FullTextMatchingLicense
public FullTextMatchingLicense()
-
FullTextMatchingLicense
protected FullTextMatchingLicense(MetaData.Datum licenseFamilyCategory, MetaData.Datum licenseFamilyName, java.lang.String notes, java.lang.String fullText)
-
-
Method Detail
-
setFullText
public final void setFullText(java.lang.String text)
-
hasFullText
public final boolean hasFullText()
-
match
public boolean match(Document subject, java.lang.String line) throws RatHeaderAnalysisException
Description copied from interface:IHeaderMatcher
Matches the text accumulated to licenses. TODO probably a poor design choice - hope to fix later- Specified by:
match
in interfaceIHeaderMatcher
- Parameters:
subject
- current document.line
- next line of text, not null- Returns:
- whether the current line matched in the document.
- Throws:
RatHeaderAnalysisException
- in case of internal RAT errors.
-
reset
public void reset()
Description copied from interface:IHeaderMatcher
Resets this matches. Subsequent calls toIHeaderMatcher.match(org.apache.rat.api.Document, java.lang.String)
will accumulate new text.- Specified by:
reset
in interfaceIHeaderMatcher
-
init
private void init()
-
-