org.codehaus.plexus.interpolation

Class RegexBasedInterpolator

public class RegexBasedInterpolator extends Object implements Interpolator

Expansion of the original RegexBasedInterpolator, found in plexus-utils, this interpolator provides options for setting custom prefix/suffix regex parts, and includes a RecursionInterceptor parameter in its interpolate(..) call, to allow the detection of cyclical expression references.

Version: $Id: RegexBasedInterpolator.java 7826 2008-11-14 16:21:07Z olamy $

Field Summary
static StringDEFAULT_REGEXP
Constructor Summary
RegexBasedInterpolator()
Setup a basic interpolator.
RegexBasedInterpolator(boolean reusePatterns)
RegexBasedInterpolator(String startRegex, String endRegex)
Setup an interpolator with no value sources, and the specified regex pattern prefix and suffix in place of the default one.
RegexBasedInterpolator(List valueSources)
Setup a basic interpolator with the specified list of value sources.
RegexBasedInterpolator(String startRegex, String endRegex, List valueSources)
Setup an interpolator with the specified value sources, and the specified regex pattern prefix and suffix in place of the default one.
Method Summary
voidaddPostProcessor(InterpolationPostProcessor postProcessor)
voidaddValueSource(ValueSource valueSource)
voidclearAnswers()
voidclearFeedback()
Clear the feedback messages from previous interpolate(..) calls.
ListgetFeedback()
Return any feedback messages and errors that were generated - but suppressed - during the interpolation process.
Stringinterpolate(String input, 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.
Stringinterpolate(String input, String thisPrefixPattern)
Stringinterpolate(String input)
Stringinterpolate(String input, RecursionInterceptor recursionInterceptor)
booleanisCacheAnswers()
booleanisReusePatterns()
voidremovePostProcessor(InterpolationPostProcessor postProcessor)
voidremoveValuesSource(ValueSource valueSource)
voidsetCacheAnswers(boolean cacheAnswers)
voidsetReusePatterns(boolean reusePatterns)

Field Detail

DEFAULT_REGEXP

public static final String DEFAULT_REGEXP

Constructor Detail

RegexBasedInterpolator

public RegexBasedInterpolator()
Setup a basic interpolator.
NOTE: You will have to call addValueSource at least once if you use this constructor!

RegexBasedInterpolator

public RegexBasedInterpolator(boolean reusePatterns)

Parameters: reusePatterns already compiled patterns will be reused

RegexBasedInterpolator

public RegexBasedInterpolator(String startRegex, String endRegex)
Setup an interpolator with no value sources, and the specified regex pattern prefix and suffix in place of the default one.
NOTE: You will have to call addValueSource at least once if you use this constructor!

Parameters: startRegex start of the regular expression to use endRegex end of the regular expression to use

RegexBasedInterpolator

public RegexBasedInterpolator(List valueSources)
Setup a basic interpolator with the specified list of value sources.

Parameters: valueSources The list of value sources to use

RegexBasedInterpolator

public RegexBasedInterpolator(String startRegex, String endRegex, List valueSources)
Setup an interpolator with the specified value sources, and the specified regex pattern prefix and suffix in place of the default one.

Parameters: startRegex start of the regular expression to use endRegex end of the regular expression to use valueSources The list of value sources to use

Method Detail

addPostProcessor

public void addPostProcessor(InterpolationPostProcessor postProcessor)
{@inheritDoc }

addValueSource

public void addValueSource(ValueSource valueSource)
{@inheritDoc }

clearAnswers

public void clearAnswers()

clearFeedback

public void clearFeedback()
Clear the feedback messages from previous interpolate(..) calls.

getFeedback

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

Returns: a List that may be interspersed with String and Throwable instances.

interpolate

public String interpolate(String input, 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. The supplied recursion interceptor will provide protection from expression cycles, ensuring that the input can be resolved or an exception is thrown.

Parameters: input The input string to interpolate thisPrefixPattern 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.

interpolate

public String interpolate(String input, String thisPrefixPattern)
See RegexBasedInterpolator.
This method triggers the use of a SimpleRecursionInterceptor instance for protection against expression cycles.

Parameters: input The input string to interpolate thisPrefixPattern An optional pattern that should be trimmed from the start of any expressions found in the input.

interpolate

public String interpolate(String input)
See RegexBasedInterpolator.
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.

Parameters: input The input string to interpolate

interpolate

public String interpolate(String input, RecursionInterceptor recursionInterceptor)
See RegexBasedInterpolator.
This method leaves empty the expression prefix which would otherwise be trimmed from expressions. The result is that any detected expression will be resolved as-is.

Parameters: input The input string to interpolate recursionInterceptor Used to protect the interpolation process from expression cycles, and throw an exception if one is detected.

isCacheAnswers

public boolean isCacheAnswers()

isReusePatterns

public boolean isReusePatterns()

removePostProcessor

public void removePostProcessor(InterpolationPostProcessor postProcessor)
{@inheritDoc }

removeValuesSource

public void removeValuesSource(ValueSource valueSource)
{@inheritDoc }

setCacheAnswers

public void setCacheAnswers(boolean cacheAnswers)

setReusePatterns

public void setReusePatterns(boolean reusePatterns)
Copyright © 2001-2009 Codehaus. All Rights Reserved.