org.apache.commons.jelly.expression
Class CompositeExpression

java.lang.Object
  extended by org.apache.commons.jelly.expression.ExpressionSupport
      extended by 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: 1807798 $
Author:
James Strachan

Field Summary
private  java.util.List expressions
          The expressions
 
Fields inherited from class org.apache.commons.jelly.expression.ExpressionSupport
EMPTY_ITERATOR
 
Constructor Summary
CompositeExpression()
           
CompositeExpression(java.util.List expressions)
           
 
Method Summary
 void addExpression(Expression expression)
          Adds a new expression to the end of the expression list
 void addTextExpression(java.lang.String text)
          A helper method to add a new constant text expression
 java.lang.Object evaluate(JellyContext context)
          Evaluates the expression with the given context and returns the result
 java.util.Iterator evaluateAsIterator(JellyContext context)
          Evaluates the expression with the given context coercing the result to be an Iterator.
 java.lang.String evaluateAsString(JellyContext context)
          Evaluates the expression with the given context coercing the result to be a String.
 java.util.List getExpressions()
           
 java.lang.String getExpressionText()
           
static Expression parse(java.lang.String text, ExpressionFactory factory)
          Parses the given String to be either a ConstantExpresssion, an Expression denoted as "${foo}" or some String with embedded expresssions such as "abc${something}def${else}xyz" which results in a CompositeExpression being returned.
 void setExpressions(java.util.List expressions)
          Sets the Expression objects that make up this composite expression
 java.lang.String toString()
           
 
Methods inherited from class org.apache.commons.jelly.expression.ExpressionSupport
evaluateAsBoolean, evaluateRecurse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

expressions

private java.util.List expressions
The expressions

Constructor Detail

CompositeExpression

public CompositeExpression()

CompositeExpression

public CompositeExpression(java.util.List expressions)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parse

public static Expression parse(java.lang.String text,
                               ExpressionFactory factory)
                        throws JellyException
Parses the given String to be either a ConstantExpresssion, an Expression denoted as "${foo}" or some String with embedded expresssions such as "abc${something}def${else}xyz" which results in a CompositeExpression being returned.

Parameters:
text - is the String to parse into expressions
factory - is the Factory of Expression objects used to create expresssions for the contents of the String "foo" inside expressions such as "${foo}"
Returns:
the Expresssion 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 java.util.List getExpressions()
Returns:
the Expression objects that make up this composite expression

setExpressions

public void setExpressions(java.util.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(java.lang.String text)
A helper method to add a new constant text expression


getExpressionText

public java.lang.String getExpressionText()
Returns:
the textual representation of this expression

evaluate

public java.lang.Object evaluate(JellyContext context)
Description copied from interface: Expression
Evaluates the expression with the given context and returns the result


evaluateAsString

public java.lang.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 interface Expression
Overrides:
evaluateAsString in class ExpressionSupport

evaluateAsIterator

public java.util.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 interface Expression
Overrides:
evaluateAsIterator in class ExpressionSupport