org.tinyjee.maven.dim.sources
Class IdDefinitionSelector
java.lang.Object
org.tinyjee.maven.dim.sources.AbstractSnippetSelector
org.tinyjee.maven.dim.sources.AbstractStreamingSnippetSelector
org.tinyjee.maven.dim.sources.IdSnippetSelector
org.tinyjee.maven.dim.sources.IdDefinitionSelector
- All Implemented Interfaces:
- SnippetSelector
public class IdDefinitionSelector
- extends IdSnippetSelector
Implements a selector that matches all snippet ID definitions triggered by a single expression "snippet-ids".
The purpose of this selector is to exclude any snippet id definitions from matched content.
Example: "%{include|snippet=#id-to-include, !snippet-ids}".
- Author:
- Juergen_Kellerer, 2011-10-16
IdDefinitionSelector
public IdDefinitionSelector()
canSelectSnippetsWith
public boolean canSelectSnippetsWith(String expression,
URL contentUrl,
Map<String,Object> macroParameters)
- Description copied from interface:
SnippetSelector
- Returns true if the expression is supported by this snippet selector.
- Specified by:
canSelectSnippetsWith in interface SnippetSelector- Overrides:
canSelectSnippetsWith in class IdSnippetSelector
- 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).macroParameters - the parameters used with the macro call.
- Returns:
- true if the snippet selector supports the given expression.
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).
- Specified by:
selectSnippets in interface SnippetSelector- Overrides:
selectSnippets in class IdSnippetSelector
- 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.