Class StringSearchInterpolator
- java.lang.Object
-
- org.codehaus.plexus.interpolation.StringSearchInterpolator
-
- All Implemented Interfaces:
BasicInterpolator
,Interpolator
public class StringSearchInterpolator extends java.lang.Object implements Interpolator
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
cacheAnswers
static java.lang.String
DEFAULT_END_EXPR
static java.lang.String
DEFAULT_START_EXPR
private java.lang.String
endExpr
private java.lang.String
escapeString
private java.util.Map<java.lang.String,java.lang.Object>
existingAnswers
private java.util.List<InterpolationPostProcessor>
postProcessors
private java.lang.String
startExpr
private java.util.List<ValueSource>
valueSources
-
Constructor Summary
Constructors Constructor Description StringSearchInterpolator()
StringSearchInterpolator(java.lang.String startExpr, java.lang.String endExpr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPostProcessor(InterpolationPostProcessor postProcessor)
Add a new post-processor to handle final processing after recursively-interpolated value is determined.void
addValueSource(ValueSource valueSource)
Add a newValueSource
to the stack used to resolve expressions in this interpolator instance.void
clearAnswers()
void
clearFeedback()
Clear the feedback messages from previous interpolate(..) calls.java.lang.String
getEscapeString()
java.util.List
getFeedback()
Return any feedback messages and errors that were generated - but suppressed - during the interpolation process.java.lang.String
interpolate(java.lang.String input)
java.lang.String
interpolate(java.lang.String input, java.lang.String thisPrefixPattern)
java.lang.String
interpolate(java.lang.String input, java.lang.String thisPrefixPattern, RecursionInterceptor recursionInterceptor)
Attempt to resolve all expressions in the given input string, using the given pattern to first trim an optional prefix from each expression.java.lang.String
interpolate(java.lang.String input, RecursionInterceptor recursionInterceptor)
Entry point for recursive resolution of an expression and all of its nested expressions.private java.lang.String
interpolate(java.lang.String input, RecursionInterceptor recursionInterceptor, java.util.Set<java.lang.String> unresolvable)
boolean
isCacheAnswers()
void
removePostProcessor(InterpolationPostProcessor postProcessor)
Remove the given post-processor.void
removeValuesSource(ValueSource valueSource)
Remove the specifiedValueSource
from the stack used to resolve expressions in this interpolator instance.void
setCacheAnswers(boolean cacheAnswers)
void
setEscapeString(java.lang.String escapeString)
-
-
-
Field Detail
-
existingAnswers
private java.util.Map<java.lang.String,java.lang.Object> existingAnswers
-
valueSources
private java.util.List<ValueSource> valueSources
-
postProcessors
private java.util.List<InterpolationPostProcessor> postProcessors
-
cacheAnswers
private boolean cacheAnswers
-
DEFAULT_START_EXPR
public static final java.lang.String DEFAULT_START_EXPR
- See Also:
- Constant Field Values
-
DEFAULT_END_EXPR
public static final java.lang.String DEFAULT_END_EXPR
- See Also:
- Constant Field Values
-
startExpr
private java.lang.String startExpr
-
endExpr
private java.lang.String endExpr
-
escapeString
private java.lang.String escapeString
-
-
Method Detail
-
addValueSource
public void addValueSource(ValueSource valueSource)
Add a newValueSource
to the stack used to resolve expressions in this interpolator instance.- Specified by:
addValueSource
in interfaceInterpolator
- Parameters:
valueSource
-ValueSource
.
-
removeValuesSource
public void removeValuesSource(ValueSource valueSource)
Remove the specifiedValueSource
from the stack used to resolve expressions in this interpolator instance.- Specified by:
removeValuesSource
in interfaceInterpolator
- Parameters:
valueSource
-ValueSource
.
-
addPostProcessor
public void addPostProcessor(InterpolationPostProcessor postProcessor)
Add a new post-processor to handle final processing after recursively-interpolated value is determined.- Specified by:
addPostProcessor
in interfaceInterpolator
- Parameters:
postProcessor
-InterpolationPostProcessor
.
-
removePostProcessor
public void removePostProcessor(InterpolationPostProcessor postProcessor)
Remove the given post-processor.- Specified by:
removePostProcessor
in interfaceInterpolator
- Parameters:
postProcessor
-InterpolationPostProcessor
.
-
interpolate
public java.lang.String interpolate(java.lang.String input, java.lang.String thisPrefixPattern) throws InterpolationException
Description copied from interface:Interpolator
SeeInterpolator.interpolate(String, String, RecursionInterceptor)
.This method triggers the use of a
SimpleRecursionInterceptor
instance for protection against expression cycles.- Specified by:
interpolate
in interfaceInterpolator
- Parameters:
input
- The input string to interpolatethisPrefixPattern
- An optional pattern that should be trimmed from the start of any expressions found in the input.- Returns:
- interpolated string.
- Throws:
InterpolationException
- in case of an error.
-
interpolate
public java.lang.String interpolate(java.lang.String input, java.lang.String thisPrefixPattern, RecursionInterceptor recursionInterceptor) throws InterpolationException
Description copied from interface:Interpolator
Attempt to resolve all expressions in the given input string, using the given pattern to first trim an optional prefix from each expression. The supplied recursion interceptor will provide protection from expression cycles, ensuring that the input can be resolved or an exception is thrown. return an empty String if input is null- Specified by:
interpolate
in interfaceInterpolator
- Parameters:
input
- The input string to interpolatethisPrefixPattern
- An optional pattern that should be trimmed from the start of any expressions found in the input.recursionInterceptor
- Used to protect the interpolation process from expression cycles, and throw an exception if one is detected.- Returns:
- interpolated string.
- Throws:
InterpolationException
- in case of an error.
-
interpolate
public java.lang.String interpolate(java.lang.String input) throws InterpolationException
Description copied from interface:BasicInterpolator
SeeInterpolator.interpolate(String, String, org.codehaus.plexus.interpolation.RecursionInterceptor)
.This method triggers the use of a
SimpleRecursionInterceptor
instance for protection against expression cycles. It also leaves empty the expression prefix which would otherwise be trimmed from expressions. The result is that any detected expression will be resolved as-is.- Specified by:
interpolate
in interfaceBasicInterpolator
- Parameters:
input
- The input string to interpolate- Returns:
- the interpolated string.
- Throws:
InterpolationException
- in case of an error.
-
interpolate
public java.lang.String interpolate(java.lang.String input, RecursionInterceptor recursionInterceptor) throws InterpolationException
Entry point for recursive resolution of an expression and all of its nested expressions. TODO: Ensure unresolvable expressions don't trigger infinite recursion.- Specified by:
interpolate
in interfaceBasicInterpolator
- Parameters:
input
- The input string to interpolaterecursionInterceptor
- Used to protect the interpolation process from expression cycles, and throw an exception if one is detected.- Returns:
- the interpolated string.
- Throws:
InterpolationException
- in case of an error.
-
interpolate
private java.lang.String interpolate(java.lang.String input, RecursionInterceptor recursionInterceptor, java.util.Set<java.lang.String> unresolvable) throws InterpolationException
- Throws:
InterpolationException
-
getFeedback
public java.util.List getFeedback()
Return any feedback messages and errors that were generated - but suppressed - during the interpolation process. Since unresolvable expressions will be left in the source string as-is, this feedback is optional, and will only be useful for debugging interpolation problems.- Specified by:
getFeedback
in interfaceInterpolator
- Returns:
- a
List
that may be interspersed withString
andThrowable
instances.
-
clearFeedback
public void clearFeedback()
Clear the feedback messages from previous interpolate(..) calls.- Specified by:
clearFeedback
in interfaceInterpolator
-
isCacheAnswers
public boolean isCacheAnswers()
- Specified by:
isCacheAnswers
in interfaceInterpolator
- Returns:
- state of the cacheAnswers
-
setCacheAnswers
public void setCacheAnswers(boolean cacheAnswers)
- Specified by:
setCacheAnswers
in interfaceInterpolator
- Parameters:
cacheAnswers
- true/false.
-
clearAnswers
public void clearAnswers()
- Specified by:
clearAnswers
in interfaceInterpolator
-
getEscapeString
public java.lang.String getEscapeString()
-
setEscapeString
public void setEscapeString(java.lang.String escapeString)
-
-