org.codehaus.plexus.interpolation

Class PrefixedValueSourceWrapper

public class PrefixedValueSourceWrapper extends 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.

Version: $Id: PrefixedValueSourceWrapper.java 7681 2008-08-22 20:34:22Z jdcasey $

Author: jdcasey

Constructor Summary
PrefixedValueSourceWrapper(ValueSource valueSource, 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, 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, List 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, List 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
voidclearFeedback()
If the nested ValueSource implements FeedbackEnabledValueSource, then clear that source's feedback list.
ListgetFeedback()
If the nested ValueSource implements FeedbackEnabledValueSource, then return that source's feedback list.
StringgetLastExpression()
If the nested ValueSource implements QueryEnabledValueSource, then return that source's last expression.
ObjectgetValue(String expression)
Uses ValueSourceUtils to get the trimmed expression.

Constructor Detail

PrefixedValueSourceWrapper

public PrefixedValueSourceWrapper(ValueSource valueSource, 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 The ValueSource to wrap. prefix The expression prefix to trim.

PrefixedValueSourceWrapper

public PrefixedValueSourceWrapper(ValueSource valueSource, 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 The ValueSource 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, List 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 The ValueSource to wrap. possiblePrefixes The List of expression prefixes to trim.

PrefixedValueSourceWrapper

public PrefixedValueSourceWrapper(ValueSource valueSource, List 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 The ValueSource 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

clearFeedback

public void clearFeedback()
If the nested ValueSource implements FeedbackEnabledValueSource, then clear that source's feedback list.

getFeedback

public List getFeedback()
If the nested ValueSource implements FeedbackEnabledValueSource, then return that source's feedback list. Otherwise, return Collections#EMPTY_LIST.

getLastExpression

public String getLastExpression()
If the nested ValueSource implements QueryEnabledValueSource, then return that source's last expression. Otherwise, return the last expression that was processed by the wrapper itself.

getValue

public Object getValue(String expression)
Uses ValueSourceUtils 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 nested getValue result.
Copyright © 2001-2009 Codehaus. All Rights Reserved.