Class MultiDelimiterStringSearchInterpolator
- java.lang.Object
-
- org.codehaus.plexus.interpolation.multi.MultiDelimiterStringSearchInterpolator
-
- All Implemented Interfaces:
BasicInterpolator,Interpolator
public class MultiDelimiterStringSearchInterpolator extends java.lang.Object implements Interpolator
-
-
Field Summary
Fields Modifier and Type Field Description private booleancacheAnswersprivate java.util.LinkedHashSet<DelimiterSpecification>delimitersprivate java.lang.StringescapeStringprivate java.util.MapexistingAnswersprivate static intMAX_TRIESprivate java.util.ListpostProcessorsprivate java.util.List<ValueSource>valueSources
-
Constructor Summary
Constructors Constructor Description MultiDelimiterStringSearchInterpolator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiDelimiterStringSearchInterpolatoraddDelimiterSpec(java.lang.String delimiterSpec)voidaddPostProcessor(InterpolationPostProcessor postProcessor)Add a new post-processor to handle final processing after recursively-interpolated value is determined.voidaddValueSource(ValueSource valueSource)Add a newValueSourceto the stack used to resolve expressions in this interpolator instance.voidclearAnswers()voidclearFeedback()Clear the feedback messages from previous interpolate(..) calls.MultiDelimiterStringSearchInterpolatorescapeString(java.lang.String escapeString)java.lang.StringgetEscapeString()java.util.ListgetFeedback()Return any feedback messages and errors that were generated - but suppressed - during the interpolation process.java.lang.Stringinterpolate(java.lang.String input)java.lang.Stringinterpolate(java.lang.String input, java.lang.String thisPrefixPattern)java.lang.Stringinterpolate(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.Stringinterpolate(java.lang.String input, RecursionInterceptor recursionInterceptor)Entry point for recursive resolution of an expression and all of its nested expressions.private java.lang.Stringinterpolate(java.lang.String input, RecursionInterceptor recursionInterceptor, java.util.Set<java.lang.String> unresolvable)booleanisCacheAnswers()booleanremoveDelimiterSpec(java.lang.String delimiterSpec)voidremovePostProcessor(InterpolationPostProcessor postProcessor)Remove the given post-processor.voidremoveValuesSource(ValueSource valueSource)Remove the specifiedValueSourcefrom the stack used to resolve expressions in this interpolator instance.private DelimiterSpecificationselect(java.lang.String input, int lastEndIdx)voidsetCacheAnswers(boolean cacheAnswers)MultiDelimiterStringSearchInterpolatorsetDelimiterSpecs(java.util.LinkedHashSet<java.lang.String> specs)voidsetEscapeString(java.lang.String escapeString)MultiDelimiterStringSearchInterpolatorwithPostProcessor(InterpolationPostProcessor postProcessor)MultiDelimiterStringSearchInterpolatorwithValueSource(ValueSource vs)
-
-
-
Field Detail
-
MAX_TRIES
private static final int MAX_TRIES
- See Also:
- Constant Field Values
-
existingAnswers
private java.util.Map existingAnswers
-
valueSources
private java.util.List<ValueSource> valueSources
-
postProcessors
private java.util.List postProcessors
-
cacheAnswers
private boolean cacheAnswers
-
delimiters
private java.util.LinkedHashSet<DelimiterSpecification> delimiters
-
escapeString
private java.lang.String escapeString
-
-
Method Detail
-
addDelimiterSpec
public MultiDelimiterStringSearchInterpolator addDelimiterSpec(java.lang.String delimiterSpec)
-
removeDelimiterSpec
public boolean removeDelimiterSpec(java.lang.String delimiterSpec)
-
withValueSource
public MultiDelimiterStringSearchInterpolator withValueSource(ValueSource vs)
-
withPostProcessor
public MultiDelimiterStringSearchInterpolator withPostProcessor(InterpolationPostProcessor postProcessor)
-
addValueSource
public void addValueSource(ValueSource valueSource)
Add a newValueSourceto the stack used to resolve expressions in this interpolator instance.- Specified by:
addValueSourcein interfaceInterpolator- Parameters:
valueSource-ValueSource.
-
removeValuesSource
public void removeValuesSource(ValueSource valueSource)
Remove the specifiedValueSourcefrom the stack used to resolve expressions in this interpolator instance.- Specified by:
removeValuesSourcein 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:
addPostProcessorin interfaceInterpolator- Parameters:
postProcessor-InterpolationPostProcessor.
-
removePostProcessor
public void removePostProcessor(InterpolationPostProcessor postProcessor)
Remove the given post-processor.- Specified by:
removePostProcessorin interfaceInterpolator- Parameters:
postProcessor-InterpolationPostProcessor.
-
interpolate
public java.lang.String interpolate(java.lang.String input, java.lang.String thisPrefixPattern) throws InterpolationExceptionDescription copied from interface:InterpolatorSeeInterpolator.interpolate(String, String, RecursionInterceptor).This method triggers the use of a
SimpleRecursionInterceptorinstance for protection against expression cycles.- Specified by:
interpolatein 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 InterpolationExceptionDescription copied from interface:InterpolatorAttempt 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:
interpolatein 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 InterpolationExceptionDescription copied from interface:BasicInterpolatorSeeInterpolator.interpolate(String, String, org.codehaus.plexus.interpolation.RecursionInterceptor).This method triggers the use of a
SimpleRecursionInterceptorinstance 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:
interpolatein 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 InterpolationExceptionEntry point for recursive resolution of an expression and all of its nested expressions. TODO: Ensure unresolvable expressions don't trigger infinite recursion.- Specified by:
interpolatein 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
-
select
private DelimiterSpecification select(java.lang.String input, int lastEndIdx)
-
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:
getFeedbackin interfaceInterpolator- Returns:
- a
Listthat may be interspersed withStringandThrowableinstances.
-
clearFeedback
public void clearFeedback()
Clear the feedback messages from previous interpolate(..) calls.- Specified by:
clearFeedbackin interfaceInterpolator
-
isCacheAnswers
public boolean isCacheAnswers()
- Specified by:
isCacheAnswersin interfaceInterpolator- Returns:
- state of the cacheAnswers
-
setCacheAnswers
public void setCacheAnswers(boolean cacheAnswers)
- Specified by:
setCacheAnswersin interfaceInterpolator- Parameters:
cacheAnswers- true/false.
-
clearAnswers
public void clearAnswers()
- Specified by:
clearAnswersin interfaceInterpolator
-
getEscapeString
public java.lang.String getEscapeString()
-
setEscapeString
public void setEscapeString(java.lang.String escapeString)
-
escapeString
public MultiDelimiterStringSearchInterpolator escapeString(java.lang.String escapeString)
-
setDelimiterSpecs
public MultiDelimiterStringSearchInterpolator setDelimiterSpecs(java.util.LinkedHashSet<java.lang.String> specs)
-
-