org.tinyjee.maven.dim.sources
Class GrepLikeSnippetSelector
java.lang.Object
org.tinyjee.maven.dim.sources.AbstractSnippetSelector
org.tinyjee.maven.dim.sources.AbstractStreamingSnippetSelector
org.tinyjee.maven.dim.sources.GrepLikeSnippetSelector
- All Implemented Interfaces:
- SnippetSelector
public class GrepLikeSnippetSelector
- extends AbstractStreamingSnippetSelector
Implements a token based snippet selector working similar as the unix command 'grep' using the expression prefix "grep:".
Expression samples:
grep:case-insensitive-token
grep:ERROR
%{include|source=build.log|snippet=GREP:Exception, GREP:org.tinyjee.dim|snippet-grow-offset=5}
%{include|source=build.log|snippet=GREP:Exception+3, GREP:org.tinyjee.dim+5}
By default this selector works case-insensitive, unless "case-sensitive=true"
is set.
The grep selector allows to define "snippet-end-offset
" inline by adding "+lines" to the end of a statement.
In order to match "+5" use an escaped expression like "\+5".
- Author:
- Juergen_Kellerer, 2011-10-14
GrepLikeSnippetSelector
public GrepLikeSnippetSelector()
GrepLikeSnippetSelector
protected GrepLikeSnippetSelector(String expressionPrefix)
selectSnippets
public Iterator<Integer> selectSnippets(String expression,
URL contentUrl,
LineNumberReader content,
Map<String,Object> macroParameters)
throws IOException
- Description copied from interface:
SnippetSelector
- Selects snippets in the given content and returns an iterator over selected line numbers.
Note: The caller reads the returned iterator fully before closing the content stream.
This way snippet selectors can truly implement streaming selection (in difference to the provided example).
- Parameters:
expression
- a single snippet expression.contentUrl
- the resolved URL of the content to include (might be 'null' if the source does not provide a Url).content
- a reader providing the content. Implementations must read content from this reader as the Url
may point to an outdated static source that does not reflect the content to include.macroParameters
- the parameters used with the macro call.
- Returns:
- an iterator containing all selected line numbers.
- Throws:
IOException
- In case of reading the URL failed.