Package org.apache.rat.analysis.matchers
Class AbstractSimpleMatcher
java.lang.Object
org.apache.rat.analysis.matchers.AbstractHeaderMatcher
org.apache.rat.analysis.matchers.AbstractSimpleMatcher
- All Implemented Interfaces:
IHeaderMatcher
- Direct Known Subclasses:
CopyrightMatcher
,FullTextMatcher
,SimpleRegexMatcher
,SimpleTextMatcher
,SPDXMatcherFactory.Match
An abstract IHeaderMatcher that does simple matching. Implementations need to implement the
doMatch(String)
method to perform the actual matching. All handling of the State
is managed by this class. By default the
finalizeState()
method will convert State.i
to State.f
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.rat.analysis.IHeaderMatcher
IHeaderMatcher.Builder, IHeaderMatcher.State
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs the AbstractSimpleMatcher with the specified id. -
Method Summary
Modifier and TypeMethodDescriptionGets the the current state of the matcher.protected abstract boolean
Performs the actual match test.Gets the final state for this matcher.Attempts to matchline
and returns the State after the match is attempted.void
reset()
Resets this stateState.i
.Methods inherited from class org.apache.rat.analysis.matchers.AbstractHeaderMatcher
getId, toString
-
Constructor Details
-
AbstractSimpleMatcher
Constructs the AbstractSimpleMatcher with the specified id. If the id is null or an empty string a unique random id will be generated.- Parameters:
id
- the Id to use. May be null.
-
-
Method Details
-
doMatch
Performs the actual match test.- Parameters:
line
- the line to check.- Returns:
true
if the line matches,false
otherwise.
-
matches
Description copied from interface:IHeaderMatcher
Attempts to matchline
and returns the State after the match is attempted.- Parameters:
line
- next line of text, not null- Returns:
- the new state after the matching was attempted.
-
reset
public void reset()Description copied from interface:IHeaderMatcher
Resets this stateState.i
. If text is being cached this method should clear that cache. -
finalizeState
Description copied from interface:IHeaderMatcher
Gets the final state for this matcher. This is called after the EOF on the input. At this point there should be no matchers in anState.i
state. -
currentState
Description copied from interface:IHeaderMatcher
Gets the the current state of the matcher. All matchers should be inState.i
at the start.- Returns:
- the current state of the matcher.
-