Package org.apache.rat.analysis.license
Class CopyrightHeader
- java.lang.Object
-
- org.apache.rat.analysis.license.BaseLicense
-
- org.apache.rat.analysis.license.CopyrightHeader
-
- All Implemented Interfaces:
IHeaderMatcher
- Direct Known Subclasses:
AppliedApacheSoftwareLicense20
public class CopyrightHeader extends BaseLicense implements IHeaderMatcher
Matches a typical Copyright header line only based on a regex pattern which allows for one (starting) year or year range, and a configurable copyright owner.
The matching is done case insensitive
Example supported Copyright header lines, using copyright owner "FooBar"- * Copyright 2010 FooBar. *
- * Copyright 2010-2012 FooBar. *
- *copyright 2012 foobar*
Note also that the copyright owner is appended to the regex pattern, so can support additional regex but also requires escaping where needed,
e.g. use "FooBar \(www\.foobar\.com\)" for matching "FooBar (www.foobar.com)"
- Since:
- Rat 0.9
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COPYRIGHT_PREFIX_PATTERN_DEFN
private boolean
copyrightMatch
private java.lang.String
copyrightOwner
private java.util.regex.Pattern
copyrightPattern
-
Constructor Summary
Constructors Modifier Constructor Description CopyrightHeader()
protected
CopyrightHeader(MetaData.Datum licenseFamilyCategory, MetaData.Datum licenseFamilyName, java.lang.String notes)
protected
CopyrightHeader(MetaData.Datum licenseFamilyCategory, MetaData.Datum licenseFamilyName, java.lang.String notes, java.lang.String copyrightOwner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getCopyRightOwner()
boolean
hasCopyrightPattern()
protected boolean
isCopyrightMatch()
boolean
match(Document subject, java.lang.String s)
Matches the text accumulated to licenses.protected boolean
matchCopyright(java.lang.String s)
void
reset()
Resets this matches.void
setCopyrightOwner(java.lang.String copyrightOwner)
-
Methods inherited from class org.apache.rat.analysis.license.BaseLicense
getLicenseFamilyCategory, getLicenseFamilyName, getNotes, prune, reportOnLicense, setLicenseFamilyCategory, setLicenseFamilyName, setNotes
-
-
-
-
Field Detail
-
COPYRIGHT_PREFIX_PATTERN_DEFN
public static final java.lang.String COPYRIGHT_PREFIX_PATTERN_DEFN
- See Also:
- Constant Field Values
-
copyrightPattern
private java.util.regex.Pattern copyrightPattern
-
copyrightOwner
private java.lang.String copyrightOwner
-
copyrightMatch
private boolean copyrightMatch
-
-
Constructor Detail
-
CopyrightHeader
public CopyrightHeader()
-
CopyrightHeader
protected CopyrightHeader(MetaData.Datum licenseFamilyCategory, MetaData.Datum licenseFamilyName, java.lang.String notes)
-
CopyrightHeader
protected CopyrightHeader(MetaData.Datum licenseFamilyCategory, MetaData.Datum licenseFamilyName, java.lang.String notes, java.lang.String copyrightOwner)
-
-
Method Detail
-
setCopyrightOwner
public final void setCopyrightOwner(java.lang.String copyrightOwner)
-
getCopyRightOwner
public java.lang.String getCopyRightOwner()
-
hasCopyrightPattern
public boolean hasCopyrightPattern()
-
isCopyrightMatch
protected boolean isCopyrightMatch()
-
matchCopyright
protected boolean matchCopyright(java.lang.String s)
-
match
public boolean match(Document subject, java.lang.String s) 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.s
- 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
-
-