Class PrefixedValueSourceWrapper
- java.lang.Object
-
- org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper
-
- All Implemented Interfaces:
FeedbackEnabledValueSource
,QueryEnabledValueSource
,ValueSource
public class PrefixedValueSourceWrapper extends java.lang.Object implements FeedbackEnabledValueSource, QueryEnabledValueSource
ValueSource
implementation which simply wraps another value source, and trims any of a set of possible expression prefixes before delegating the modified expression to be resolved by the real value source.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowUnprefixedExpressions
private java.lang.String
lastExpression
private java.lang.String[]
possiblePrefixes
private ValueSource
valueSource
-
Constructor Summary
Constructors Constructor Description PrefixedValueSourceWrapper(ValueSource valueSource, java.lang.String prefix)
Wrap the given value source, but first trim the given prefix from any expressions before they are passed along for resolution.PrefixedValueSourceWrapper(ValueSource valueSource, java.lang.String prefix, boolean allowUnprefixedExpressions)
Wrap the given value source, but first trim the given prefix from any expressions before they are passed along for resolution.PrefixedValueSourceWrapper(ValueSource valueSource, java.util.List<java.lang.String> possiblePrefixes)
Wrap the given value source, but first trim one of the given prefixes from any expressions before they are passed along for resolution.PrefixedValueSourceWrapper(ValueSource valueSource, java.util.List<java.lang.String> possiblePrefixes, boolean allowUnprefixedExpressions)
Wrap the given value source, but first trim one of the given prefixes from any expressions before they are passed along for resolution.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearFeedback()
If the nestedValueSource
implementsFeedbackEnabledValueSource
, then clear that source's feedback list.java.util.List
getFeedback()
If the nestedValueSource
implementsFeedbackEnabledValueSource
, then return that source's feedback list.java.lang.String
getLastExpression()
If the nestedValueSource
implementsQueryEnabledValueSource
, then return that source's last expression.java.lang.Object
getValue(java.lang.String expression)
UsesValueSourceUtils.trimPrefix(String, java.util.Collection, boolean)
to get the trimmed expression.
-
-
-
Field Detail
-
valueSource
private final ValueSource valueSource
-
possiblePrefixes
private final java.lang.String[] possiblePrefixes
-
allowUnprefixedExpressions
private boolean allowUnprefixedExpressions
-
lastExpression
private java.lang.String lastExpression
-
-
Constructor Detail
-
PrefixedValueSourceWrapper
public PrefixedValueSourceWrapper(ValueSource valueSource, java.lang.String prefix)
Wrap the given value source, but first trim the given prefix from any expressions before they are passed along for resolution. If an expression doesn't start with the given prefix, do not resolve it.- Parameters:
valueSource
- TheValueSource
to wrap.prefix
- The expression prefix to trim.
-
PrefixedValueSourceWrapper
public PrefixedValueSourceWrapper(ValueSource valueSource, java.lang.String prefix, boolean allowUnprefixedExpressions)
Wrap the given value source, but first trim the given prefix from any expressions before they are passed along for resolution. If an expression doesn't start with the given prefix and the allowUnprefixedExpressions flag is set to true, simply pass the expression through to the nested value source unchanged. If this flag is false, only allow resolution of those expressions that start with the specified prefix.- Parameters:
valueSource
- TheValueSource
to wrap.prefix
- The expression prefix to trim.allowUnprefixedExpressions
- Flag telling the wrapper whether to continue resolving expressions that don't start with the prefix it tracks.
-
PrefixedValueSourceWrapper
public PrefixedValueSourceWrapper(ValueSource valueSource, java.util.List<java.lang.String> possiblePrefixes)
Wrap the given value source, but first trim one of the given prefixes from any expressions before they are passed along for resolution. If an expression doesn't start with one of the given prefixes, do not resolve it.- Parameters:
valueSource
- TheValueSource
to wrap.possiblePrefixes
- The List of expression prefixes to trim.
-
PrefixedValueSourceWrapper
public PrefixedValueSourceWrapper(ValueSource valueSource, java.util.List<java.lang.String> possiblePrefixes, boolean allowUnprefixedExpressions)
Wrap the given value source, but first trim one of the given prefixes from any expressions before they are passed along for resolution. If an expression doesn't start with the given prefix and the allowUnprefixedExpressions flag is set to true, simply pass the expression through to the nested value source unchanged. If this flag is false, only allow resolution of those expressions that start with the specified prefix.- Parameters:
valueSource
- TheValueSource
to wrap.possiblePrefixes
- The List of expression prefixes to trim.allowUnprefixedExpressions
- Flag telling the wrapper whether to continue resolving expressions that don't start with one of the prefixes it tracks.
-
-
Method Detail
-
getValue
public java.lang.Object getValue(java.lang.String expression)
UsesValueSourceUtils.trimPrefix(String, java.util.Collection, boolean)
to get the trimmed expression. If this expression is null (because the original expression was null, or because the expression is unprefixed and unprefixed expressions are not allowed here), then return null; otherwise, return the nestedValueSource.getValue(String)
result.- Specified by:
getValue
in interfaceValueSource
- Parameters:
expression
- The string expression.- Returns:
- the value related to the expression, or null if not found.
-
getFeedback
public java.util.List getFeedback()
If the nestedValueSource
implementsFeedbackEnabledValueSource
, then return that source's feedback list. Otherwise, returnCollections.EMPTY_LIST
.- Specified by:
getFeedback
in interfaceValueSource
- Returns:
- a combination of String and Throwable instances, where strings related to throwables are listed first.
-
getLastExpression
public java.lang.String getLastExpression()
If the nestedValueSource
implementsQueryEnabledValueSource
, then return that source's last expression. Otherwise, return the last expression that was processed by the wrapper itself.- Specified by:
getLastExpression
in interfaceQueryEnabledValueSource
- Returns:
- the most recent expression processed by this value source, or null.
-
clearFeedback
public void clearFeedback()
If the nestedValueSource
implementsFeedbackEnabledValueSource
, then clear that source's feedback list.- Specified by:
clearFeedback
in interfaceValueSource
-
-