Class CompositeExpression
java.lang.Object
org.apache.commons.jelly.expression.ExpressionSupport
org.apache.commons.jelly.expression.CompositeExpression
- All Implemented Interfaces:
Expression
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 expressionevaluate
(JellyContext context) Evaluates the expression with the given context and returns the resultevaluateAsIterator
(JellyContext context) Evaluates the expression with the given context coercing the result to be an Iterator.evaluateAsString
(JellyContext context) Evaluates the expression with the given context coercing the result to be a String.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 expressiontoString()
Methods inherited from class org.apache.commons.jelly.expression.ExpressionSupport
evaluateAsBoolean, evaluateRecurse
-
Constructor Details
-
CompositeExpression
public CompositeExpression() -
CompositeExpression
-
-
Method Details
-
toString
-
parse
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
- Returns:
- the Expression objects that make up this composite expression
-
setExpressions
Sets the Expression objects that make up this composite expression -
addExpression
Adds a new expression to the end of the expression list -
addTextExpression
A helper method to add a new constant text expression -
getExpressionText
- Returns:
- the textual representation of this expression
-
evaluate
Description copied from interface:Expression
Evaluates the expression with the given context and returns the result -
evaluateAsString
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
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
-