Class CompositeExpression
- java.lang.Object
-
- org.apache.commons.jelly.expression.ExpressionSupport
-
- org.apache.commons.jelly.expression.CompositeExpression
-
- All Implemented Interfaces:
Expression
public class CompositeExpression extends ExpressionSupport
CompositeExpression
is a Composite expression made up of several Expression objects which are concatenated into a single String.- Version:
- $Revision: 155420 $
- Author:
- James Strachan
-
-
Field Summary
-
Fields inherited from class org.apache.commons.jelly.expression.ExpressionSupport
EMPTY_ITERATOR
-
Fields inherited from interface org.apache.commons.jelly.expression.Expression
NULL
-
-
Constructor Summary
Constructors Constructor Description CompositeExpression()
CompositeExpression(List expressions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExpression(Expression expression)
Adds a new expression to the end of the expression listvoid
addTextExpression(String text)
A helper method to add a new constant text expressionObject
evaluate(JellyContext context)
Evaluates the expression with the given context and returns the resultIterator
evaluateAsIterator(JellyContext context)
Evaluates the expression with the given context coercing the result to be an Iterator.String
evaluateAsString(JellyContext context)
Evaluates the expression with the given context coercing the result to be a String.List
getExpressions()
String
getExpressionText()
static Expression
parse(String text, ExpressionFactory factory)
Parses the given String to be either a ConstantExpression, an Expression denoted as "${foo}" or some String with embedded expressions such as "abc${something}def${else}xyz" which results in a CompositeExpression being returned.void
setExpressions(List expressions)
Sets the Expression objects that make up this composite expressionString
toString()
-
Methods inherited from class org.apache.commons.jelly.expression.ExpressionSupport
evaluateAsBoolean, evaluateRecurse
-
-
-
-
Constructor Detail
-
CompositeExpression
public CompositeExpression()
-
CompositeExpression
public CompositeExpression(List expressions)
-
-
Method Detail
-
parse
public static Expression parse(String text, ExpressionFactory factory) throws JellyException
Parses the given String to be either a ConstantExpression, an Expression denoted as "${foo}" or some String with embedded expressions such as "abc${something}def${else}xyz" which results in a CompositeExpression being returned.- Parameters:
text
- is the String to parse into expressionsfactory
- is the Factory of Expression objects used to create expressions for the contents of the String "foo" inside expressions such as "${foo}"- Returns:
- the Expression for the given String.
- Throws:
JellyException
- if the text is invalid (such as missing '}' character).JellyException
- if there was some problem creating the underlying Expression object from the ExpressionFactory
-
getExpressions
public List getExpressions()
- Returns:
- the Expression objects that make up this composite expression
-
setExpressions
public void setExpressions(List expressions)
Sets the Expression objects that make up this composite expression
-
addExpression
public void addExpression(Expression expression)
Adds a new expression to the end of the expression list
-
addTextExpression
public void addTextExpression(String text)
A helper method to add a new constant text expression
-
getExpressionText
public String getExpressionText()
- Returns:
- the textual representation of this expression
-
evaluate
public Object evaluate(JellyContext context)
Description copied from interface:Expression
Evaluates the expression with the given context and returns the result
-
evaluateAsString
public String evaluateAsString(JellyContext context)
Description copied from interface:Expression
Evaluates the expression with the given context coercing the result to be a String.- Specified by:
evaluateAsString
in interfaceExpression
- Overrides:
evaluateAsString
in classExpressionSupport
-
evaluateAsIterator
public Iterator evaluateAsIterator(JellyContext context)
Description copied from interface:Expression
Evaluates the expression with the given context coercing the result to be an Iterator.- Specified by:
evaluateAsIterator
in interfaceExpression
- Overrides:
evaluateAsIterator
in classExpressionSupport
-
-