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
  • Constructor Details

    • CompositeExpression

      public CompositeExpression()
    • CompositeExpression

      public CompositeExpression(List expressions)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 expressions
      factory - 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 interface Expression
      Overrides:
      evaluateAsString in class ExpressionSupport
    • 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 interface Expression
      Overrides:
      evaluateAsIterator in class ExpressionSupport