BinaryOperatorExpressionpublic class BinaryOperatorExpression extends Expression An expression representing a binary operator on a value |
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.Object | evaluate(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 Expression | getExpression() return mExpression;
| public java.lang.String | getExpressionString()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.List | getExpressions() return mExpressions;
| public java.util.List | getOperators() return mOperators;
| public void | setExpression(Expression pExpression) mExpression = pExpression;
| public void | setExpressions(java.util.List pExpressions) mExpressions = pExpressions;
| public void | setOperators(java.util.List pOperators) mOperators = pOperators;
|
|