25 lines
881 B
Java
25 lines
881 B
Java
package net.sf.jasperreports.engine.fill;
|
|
|
|
class JRLongAverageIncrementer extends JRAbstractExtendedIncrementer {
|
|
private static JRLongAverageIncrementer mainInstance = new JRLongAverageIncrementer();
|
|
|
|
public static JRLongAverageIncrementer getInstance() {
|
|
return mainInstance;
|
|
}
|
|
|
|
public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
|
|
if (expressionValue == null) {
|
|
if (variable.isInitialized())
|
|
return null;
|
|
return variable.getValue();
|
|
}
|
|
Number countValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)0));
|
|
Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable((byte)1));
|
|
return new Long(sumValue.longValue() / countValue.longValue());
|
|
}
|
|
|
|
public Object initialValue() {
|
|
return JRLongIncrementerFactory.ZERO;
|
|
}
|
|
}
|