FileDocCategorySizeDatePackage
BinaryOperatorExpression.javaAPI DocGlassfish v2 API5247Sat May 05 19:17:26 BST 2007org.apache.taglibs.standard.lang.jstl

BinaryOperatorExpression

public class BinaryOperatorExpression extends Expression

An expression representing a binary operator on a value

author
Nathan Abramson - Art Technology Group
author
Shawn Bayern
version
$Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: tcfujii $

Fields Summary
Expression
mExpression
List
mOperators
List
mExpressions
Constructors Summary
public BinaryOperatorExpression(Expression pExpression, List pOperators, List pExpressions)
Constructor

    mExpression = pExpression;
    mOperators = pOperators;
    mExpressions = pExpressions;
  
Methods Summary
public java.lang.Objectevaluate(java.lang.Object pContext, VariableResolver pResolver, java.util.Map functions, java.lang.String defaultPrefix, Logger pLogger)
Evaluates to the literal value

    Object value = mExpression.evaluate (pContext, pResolver, functions,
					 defaultPrefix, pLogger);
    for (int i = 0; i < mOperators.size (); i++) {
      BinaryOperator operator = (BinaryOperator) mOperators.get (i);

      // For the And/Or operators, we need to coerce to a boolean
      // before testing if we shouldEvaluate
      if (operator.shouldCoerceToBoolean ()) {
	value = Coercions.coerceToBoolean (value, pLogger);
      }

      if (operator.shouldEvaluate (value)) {
	Expression expression = (Expression) mExpressions.get (i);
	Object nextValue = expression.evaluate (pContext, pResolver,
						functions, defaultPrefix,
						pLogger);

	value = operator.apply (value, nextValue, pContext, pLogger);
      }
    }
    return value;
  
public ExpressiongetExpression()

 return mExpression; 
public java.lang.StringgetExpressionString()
Returns the expression in the expression language syntax

    StringBuffer buf = new StringBuffer ();
    buf.append ("(");
    buf.append (mExpression.getExpressionString ());
    for (int i = 0; i < mOperators.size (); i++) {
      BinaryOperator operator = (BinaryOperator) mOperators.get (i);
      Expression expression = (Expression) mExpressions.get (i);
      buf.append (" ");
      buf.append (operator.getOperatorSymbol ());
      buf.append (" ");
      buf.append (expression.getExpressionString ());
    }
    buf.append (")");

    return buf.toString ();
  
public java.util.ListgetExpressions()

 return mExpressions; 
public java.util.ListgetOperators()

 return mOperators; 
public voidsetExpression(Expression pExpression)

 mExpression = pExpression; 
public voidsetExpressions(java.util.List pExpressions)

 mExpressions = pExpressions; 
public voidsetOperators(java.util.List pOperators)

 mOperators = pOperators;