public Object value(InternalContextAdapter context) throws MethodInvocationException {
/*
* get the two args
*/
Object left = jjtGetChild(0).value( context );
Object right = jjtGetChild(1).value( context );
/*
* if either is null, lets log and bail
*/
if (left == null || right == null)
{
log.error((left == null ? "Left" : "Right")
+ " side ("
+ jjtGetChild( (left == null? 0 : 1) ).literal()
+ ") of multiplication operation has null value."
+ " Operation not possible. "
+ context.getCurrentTemplateName() + " [line " + getLine()
+ ", column " + getColumn() + "]");
return null;
}
/*
* convert to Number if applicable
*/
if (left instanceof TemplateNumber)
{
left = ( (TemplateNumber) left).getAsNumber();
}
if (right instanceof TemplateNumber)
{
right = ( (TemplateNumber) right).getAsNumber();
}
/*
* if not a Number, not much we can do either
*/
if ( !( left instanceof Number ) || !( right instanceof Number ))
{
log.error((!(left instanceof Number) ? "Left" : "Right")
+ " side of multiplication operation is not a Number. "
+ context.getCurrentTemplateName() + " [line " + getLine()
+ ", column " + getColumn() + "]");
return null;
}
return MathUtils.multiply( (Number)left, (Number)right);
}
computes the product of the two args. |