|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.tinyjee.maven.dim.sources.AbstractSnippetSelector org.tinyjee.maven.dim.sources.AbstractStreamingSnippetSelector org.tinyjee.maven.dim.sources.IdSnippetSelector
public class IdSnippetSelector
Implements the default ID based selector already known from the classic snippet macro that is part of Doxia.
In difference to the snippet macro, IDs must be prefixed with "#" and are matched fully. Sub-id matching is not allowed unless hierarchically built IDs use one of the defined delimiting charsID_DELIMITER_CHARS
)
(e.g. "ParentId.ChildId").
Snippets are processed on a line by line basis and multiple snippets with the same name may appear in one file.
In order to define a section using a snippet id, surround a block with:
// START SNIPPET: snippet-id
... code to include ...
// END SNIPPET: snippet-id
Expression samples:#snippet-id
#MySnippetIdToInclude
!#MySnippetIdToExclude
#FirstSnippet, #SecondSnippet, #ThirdSnippet
#ParentId
(Matches "ParentId" and "ParentId.[ANYTHING]")#ParentId.ChildId
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.tinyjee.maven.dim.sources.AbstractStreamingSnippetSelector |
---|
AbstractStreamingSnippetSelector.AbstractStreamIterator<E> |
Field Summary | |
---|---|
static String |
ID_DELIMITER_CHARS
Defines the chars that may surround an ID. |
Fields inherited from class org.tinyjee.maven.dim.sources.AbstractSnippetSelector |
---|
expressionPrefix |
Fields inherited from interface org.tinyjee.maven.dim.spi.SnippetSelector |
---|
CASE_SENSITIVE, EXPAND_SNIPPETS, SELECTORS |
Constructor Summary | |
---|---|
|
IdSnippetSelector()
Constructs a new SnippetId selector. |
protected |
IdSnippetSelector(String expressionPrefix)
|
Method Summary | |
---|---|
boolean |
canSelectSnippetsWith(String expression,
URL contentUrl,
Map<String,Object> macroParameters)
Returns true if the expression is supported by this snippet selector. |
protected boolean |
isDemarcator(String snippetId,
String what,
String line)
Determines if the given line is a demarcator. |
protected boolean |
isEnd(String snippetId,
String line)
Determines if the given line is an end demarcator. |
protected boolean |
isStart(String snippetId,
String line)
Determines if the given line is a start demarcator. |
Iterator<Integer> |
selectSnippets(String expression,
URL contentUrl,
LineNumberReader content,
Map<String,Object> macroParameters)
Selects snippets in the given content and returns an iterator over selected line numbers. |
Methods inherited from class org.tinyjee.maven.dim.sources.AbstractSnippetSelector |
---|
assertExpressionIsValid, getExpressionPrefixes, stripPrefix, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ID_DELIMITER_CHARS
Constructor Detail |
---|
public IdSnippetSelector()
protected IdSnippetSelector(String expressionPrefix)
Method Detail |
---|
public boolean canSelectSnippetsWith(String expression, URL contentUrl, Map<String,Object> macroParameters)
SnippetSelector
canSelectSnippetsWith
in interface SnippetSelector
canSelectSnippetsWith
in class AbstractSnippetSelector
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.
public Iterator<Integer> selectSnippets(String expression, URL contentUrl, LineNumberReader content, Map<String,Object> macroParameters) throws IOException
SnippetSelector
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.
IOException
- In case of reading the URL failed.protected boolean isStart(String snippetId, String line)
snippetId
- the id of the snippet.line
- the line.
protected boolean isDemarcator(String snippetId, String what, String line)
snippetId
- the id of the snippet.what
- Identifier for the demarcator.line
- the line.
protected boolean isEnd(String snippetId, String line)
snippetId
- the id of the snippet.line
- the line.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |