org.tinyjee.maven.dim.sources
Class AbstractSnippetSelector

java.lang.Object
  extended by org.tinyjee.maven.dim.sources.AbstractSnippetSelector
All Implemented Interfaces:
SnippetSelector
Direct Known Subclasses:
AbstractStreamingSnippetSelector, AOPLikeSnippetSelector, LineRangeSnippetSelector, XPathSnippetSelector

public abstract class AbstractSnippetSelector
extends Object
implements SnippetSelector

Implements an abstract base for snippet selectors that operate on a single expression prefix.

Author:
Juergen_Kellerer, 2011-10-14

Field Summary
protected  String expressionPrefix
          The prefix to use for detecting expressions belonging to this selector.
 
Fields inherited from interface org.tinyjee.maven.dim.spi.SnippetSelector
CASE_SENSITIVE, EXPAND_SNIPPETS, SELECTORS
 
Constructor Summary
protected AbstractSnippetSelector(String expressionPrefix)
          Constructs a new instance with the given expression-prefix.
 
Method Summary
protected  void assertExpressionIsValid(String expression, URL contentUrl, Map<String,Object> macroParameters)
          Fails if the given expression cannot be used to select snippets.
 boolean canSelectSnippetsWith(String expression, URL contentUrl, Map<String,Object> macroParameters)
          Returns true if the expression is supported by this snippet selector.
 String[] getExpressionPrefixes()
          Returns all prefixes that are explicitly supported by this snippet selector.
protected  String stripPrefix(String expression)
          Strips the prefix form the given snippet selection expression.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.tinyjee.maven.dim.spi.SnippetSelector
selectSnippets
 

Field Detail

expressionPrefix

protected final String expressionPrefix
The prefix to use for detecting expressions belonging to this selector.

Constructor Detail

AbstractSnippetSelector

protected AbstractSnippetSelector(String expressionPrefix)
Constructs a new instance with the given expression-prefix.

Parameters:
expressionPrefix - the prefix to use for detecting expressions belonging to this selector.
Method Detail

getExpressionPrefixes

public String[] getExpressionPrefixes()
Description copied from interface: SnippetSelector
Returns all prefixes that are explicitly supported by this snippet selector.

Specified by:
getExpressionPrefixes in interface SnippetSelector
Returns:
all prefixes that are explicitly supported by this snippet selector.

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
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.

assertExpressionIsValid

protected void assertExpressionIsValid(String expression,
                                       URL contentUrl,
                                       Map<String,Object> macroParameters)
Fails if the given expression cannot be used to select snippets.

Parameters:
expression - the expression to test.
contentUrl - the url to the content.
macroParameters - the parameters given with the macro call.

stripPrefix

protected String stripPrefix(String expression)
Strips the prefix form the given snippet selection expression.

Parameters:
expression - the expression to process.
Returns:
a snippet selection expression without the prefix.

toString

public String toString()
Overrides:
toString in class Object