Object avrgInCollection = null;
Object expResult = this._exp.evaluate();
if (!(expResult instanceof java.util.List))
{
logger.severe(Thread.currentThread().getName()+" "+"result of expression is not of type List");
throw new SPLException(Messages.getString(
"SPL_PASSED_EXPRESSION_TYPE_ERROR_MSG",
new Object[] { "","is not", "List" }));
}
ArrayList resultArray = (ArrayList) expResult;
Integer size = new Integer(resultArray.size());
//System.out.println("resultArray size " + resultArray.size() + " to string " + resultArray.toString());
if ((resultArray != null) && (!resultArray.isEmpty()))
{
Iterator resultIt = resultArray.iterator();
while (resultIt.hasNext())
{
Object resultObject = resultIt.next();
//System.out.println("resultObject,class " + resultObject + " " + resultObject.getClass());
if (avrgInCollection == null)
{
avrgInCollection = resultObject;
}
else
{
//System.out.println("Adding resultObject to sum "+ resultObject + " " + avrgInCollection);
avrgInCollection = ExpressionUtility.plus(
(Number) avrgInCollection, (Number) resultObject);
}
//System.out.println("current sum is " + avrgInCollection);
}
//System.out.println("sum ,Array size " + avrgInCollection + " " + size);
avrgInCollection = ExpressionUtility.division(
(Number) avrgInCollection, (Number) size);
//System.out.println("AvrgInCollection=" + avrgInCollection);
logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
return avrgInCollection;
}
else
{
logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
throw new SPLException(Messages.getString(
"SPL_BLANK_EXPRESSION_PASSED_ERROR_MSG",
new Object[] { "" }));
}
}