org.tinyjee.maven.dim.sources
Class AOPLikeSnippetSelector
java.lang.Object
org.tinyjee.maven.dim.sources.AbstractSnippetSelector
org.tinyjee.maven.dim.sources.AOPLikeSnippetSelector
- All Implemented Interfaces:
- SnippetSelector
public class AOPLikeSnippetSelector
- extends AbstractSnippetSelector
Implements an AOP expression like snippet selector using the expression prefix "AJ:".
Well formed content required: This snippet selector requires well formed Java source input. Anything else will cause failures.
Expression samples:
AJ:..toString()
AJ:..fieldName
AJ:public void my..MyClass.myMethod(..)
AJ:public void my..MyClass.myMethod(java.lang.String, ..)
AJ:public void my..MyClass.myMethod(..String, ..)
AJ:@SuppressWarnings(value="unchecked")
AJ:@my..Annotation(..value="something"..)
See also AbstractSelectableJavaEntitiesList
for more details.
The selector uses AbstractSelectableJavaEntitiesList.selectAnnotated(String)
to retrieve matching elements of the given
java source in case of the expression starts with an '@', otherwise AbstractSelectableJavaEntitiesList.selectMatching(String)
is used to find matching java entities.
Comments and bean properties are expanded if "expand-snippets=true"
is set. Effectively this means when matching
a field, getter or setter all linked code parts are automatically included, as well as the javadoc comments.
- Author:
- Juergen_Kellerer, 2011-10-14
AOPLikeSnippetSelector
public AOPLikeSnippetSelector()
AOPLikeSnippetSelector
protected AOPLikeSnippetSelector(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.
bufferContent
protected String bufferContent(LineNumberReader content)
throws IOException
- Throws:
IOException
collectJavaEntities
protected SelectableJavaEntitiesList<AbstractJavaEntity> collectJavaEntities(URL contentUrl,
String content)
throws IOException
- Throws:
IOException
add
protected void add(JavaClass javaClass,
SelectableJavaEntitiesList<AbstractJavaEntity> allEntities)