Package org.apache.rat.analysis.matchers
Class CopyrightMatcher
java.lang.Object
org.apache.rat.analysis.matchers.AbstractHeaderMatcher
org.apache.rat.analysis.matchers.CopyrightMatcher
- All Implemented Interfaces:
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"
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 and so
can support additional regex but also requires escaping where needed,
e.g. use "FooBar \\(www\\.foobar\\.com\\)" or "FooBar
\\Q(www.foobar.com)\\E" to match "FooBar (www.foobar.com)"
The matcher also accepts "(C)", "(c)", and "©" in place of (or in addition to) the "Copyright" or "copyright" keyword
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.rat.analysis.IHeaderMatcher
IHeaderMatcher.Builder
-
Constructor Summary
ConstructorsConstructorDescriptionCopyrightMatcher
(String start, String end, String owner) Constructs the CopyrightMatcher with the specified start, stop and owner strings and a unique random id.CopyrightMatcher
(String id, String start, String end, String owner) Constructs the CopyrightMatcher with the specified start, stop and owner strings. -
Method Summary
Methods inherited from class org.apache.rat.analysis.matchers.AbstractHeaderMatcher
getId, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.rat.analysis.IHeaderMatcher
getDescription, reset
-
Constructor Details
-
CopyrightMatcher
Constructs the CopyrightMatcher with the specified start, stop and owner strings and a unique random id.- Parameters:
start
- the start date for the copyright, may be null.end
- the stop date for the copyright, may be null. May not be specified if start is not specified.owner
- the owner of the copyright, may be null.
-
CopyrightMatcher
Constructs the CopyrightMatcher with the specified start, stop and owner strings.- Parameters:
id
- the id for the matcher.start
- the start date for the copyright, may be null.end
- the end date for the copyright, may be null. May not be specified if start is not specified.owner
- the owner of the copyright. may be null.
-
-
Method Details
-
getStart
Gets the start date of the copyright.- Returns:
- the start date of the copyright or
null
if not set
-
getEnd
Gets the end date of the copyright.- Returns:
- the end date of the copyright or
null
if not set
-
getOwner
Gets the owner of the copyright.- Returns:
- the owner of the copyright or
null
if not set
-
matches
Description copied from interface:IHeaderMatcher
Attempts to match text in the IHeaders instance.- Parameters:
headers
- the representations of the headers to check- Returns:
true
if the matcher matches the text,false
otherwise.
-