gt: 		Number newValue = (Number)expressionValue;
context: /*
   * ============================================================================
   * GNU Lesser General Public License
   * ============================================================================
   *
   * JasperReports - Free Java report-generating library.
   * Copyright (C) 2001-2009 JasperSoft Corporation http://www.jaspersoft.com
   * 
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   * 
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   * 
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
   * 
   * JasperSoft Corporation
   * 539 Bryant Street, Suite 100
   * San Francisco, CA 94107
   * http://www.jaspersoft.com
   */
  package net.sf.jasperreports.engine.fill;
  
  import net.sf.jasperreports.engine.JRVariable;
  
  
  /**
   * @author Teodor Danciu (teodord@users.sourceforge.net)
   * @version $Id: JRFloatIncrementerFactory.java 2696 2009-03-24 18:35:01Z teodord $
   */
  public class JRFloatIncrementerFactory extends JRAbstractExtendedIncrementerFactory
  {
  
  
  	/**
  	 *
  	 */
  	protected static final Float ZERO = new Float(0);
  
  
  	/**
  	 *
  	 */
  	private static JRFloatIncrementerFactory mainInstance = new JRFloatIncrementerFactory();
  
  
  	/**
  	 *
  	 */
  	public JRFloatIncrementerFactory()
  	{
  	}
  
  
  	/**
  	 *
  	 */
  	public static JRFloatIncrementerFactory getInstance()
  	{
  		return mainInstance;
  	}
  
  
  	/**
  	 *
  	 */
  	public JRExtendedIncrementer getExtendedIncrementer(byte calculation)
  	{
  		JRExtendedIncrementer incrementer = null;
  
  		switch (calculation)
  		{
  			case JRVariable.CALCULATION_COUNT :
  			{
  				incrementer = JRFloatCountIncrementer.getInstance();
  				break;
  			}
  			case JRVariable.CALCULATION_SUM :
  			{
  				incrementer = JRFloatSumIncrementer.getInstance();
  				break;
  			}
  			case JRVariable.CALCULATION_AVERAGE :
  			{
  				incrementer = JRFloatAverageIncrementer.getInstance();
  				break;
  			}
  			case JRVariable.CALCULATION_LOWEST :
  			case JRVariable.CALCULATION_HIGHEST :
  			{
  				incrementer = JRComparableIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
  				break;
  			}
  			case JRVariable.CALCULATION_STANDARD_DEVIATION :
  			{
  				incrementer = JRFloatStandardDeviationIncrementer.getInstance();
  				break;
  			}
  			case JRVariable.CALCULATION_VARIANCE :
  			{
  				incrementer = JRFloatVarianceIncrementer.getInstance();
  				break;
  			}
  			case JRVariable.CALCULATION_DISTINCT_COUNT :
  			{
  				incrementer = JRFloatDistinctCountIncrementer.getInstance();
  				break;
  			}
  			case JRVariable.CALCULATION_SYSTEM :
  			case JRVariable.CALCULATION_NOTHING :
  			case JRVariable.CALCULATION_FIRST :
  			default :
  			{
  				incrementer = JRDefaultIncrementerFactory.getInstance().getExtendedIncrementer(calculation);
  				break;
  			}
  		}
  		
  		return incrementer;
  	}
  
  
  }
  
  
  /**
   *
   */
  class JRFloatCountIncrementer extends JRAbstractExtendedIncrementer
  {
  	/**
  	 *
  	 */
  	private static JRFloatCountIncrementer mainInstance = new JRFloatCountIncrementer();
  
  	/**
  	 *
  	 */
  	private JRFloatCountIncrementer()
  	{
  	}
  
  	/**
  	 *
  	 */
  	public static JRFloatCountIncrementer getInstance()
  	{
  		return mainInstance;
  	}
  
  	/**
  	 *
  	 */
  	public Object increment(
  		JRCalculable variable, 
  		Object expressionValue,
  		AbstractValueProvider valueProvider
  		)
  	{
  		Number value = (Number)variable.getIncrementedValue();
  
  		if (value == null || variable.isInitialized())
  		{
  			value = JRFloatIncrementerFactory.ZERO;
  		}
  
  		if (expressionValue == null)
  		{
  			return value;
  		}
  
  		return new Float(value.floatValue() + 1);
  	}
  
  	
  	public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider)
  	{
  		Number value = (Number)calculable.getIncrementedValue();
  		Number combineValue = (Number) calculableValue.getValue();
  
  		if (value == null || calculable.isInitialized())
  		{
  			value = JRFloatIncrementerFactory.ZERO;
  		}
  
  		if (combineValue == null)
  		{
  			return value;
  		}
  
  		return new Float(value.floatValue() + combineValue.floatValue());
  	}
  
  	
  	public Object initialValue()
  	{
  		return JRFloatIncrementerFactory.ZERO;
  	}
  }
  
  
  /**
   *
   */
  class JRFloatDistinctCountIncrementer extends JRAbstractExtendedIncrementer
  {
  	/**
  	 *
  	 */
  	private static JRFloatDistinctCountIncrementer mainInstance = new JRFloatDistinctCountIncrementer();
  
  	/**
  	 *
  	 */
  	private JRFloatDistinctCountIncrementer()
  	{
  	}
  
  	/**
  	 *
  	 */
  	public static JRFloatDistinctCountIncrementer getInstance()
  	{
  		return mainInstance;
  	}
  
  	/**
  	 *
  	 */
  	public Object increment(
  		JRCalculable variable, 
  		Object expressionValue,
  		AbstractValueProvider valueProvider
  		)
  	{
  		DistinctCountHolder holder = 
  			(DistinctCountHolder)valueProvider.getValue(variable.getHelperVariable(JRCalculable.HELPER_COUNT));
  		
  		if (variable.isInitialized())
  		{
  			holder.init();
  		}
  
  		return new Float(holder.getCount());
  	}
  
  	public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider)
  	{
  		DistinctCountHolder holder = 
  			(DistinctCountHolder)valueProvider.getValue(calculable.getHelperVariable(JRCalculable.HELPER_COUNT));
  		
  		return new Float(holder.getCount());
  	}
  	
  	public Object initialValue()
  	{
  		return JRFloatIncrementerFactory.ZERO;
  	}
  }
  
  
  /**
   *
   */
  class JRFloatSumIncrementer extends JRAbstractExtendedIncrementer
  {
  	/**
  	 *
  	 */
  	private static JRFloatSumIncrementer mainInstance = new JRFloatSumIncrementer();
  
  	/**
  	 *
  	 */
  	private JRFloatSumIncrementer()
  	{
  	}
  
  	/**
  	 *
  	 */
  	public static JRFloatSumIncrementer getInstance()
  	{
  		return mainInstance;
  	}
  
  	/**
  	 *
  	 */
  	public Object increment(
  		JRCalculable variable, 
  		Object expressionValue,
  		AbstractValueProvider valueProvider
  		)
  	{
  		Number value = (Number)variable.getIncrementedValue();
  		Number newValue = (Number)expressionValue;
  
  		if (newValue == null)
  		{
  			if (variable.isInitialized())
  			{
  				return null;
  			}
  
  			return value;
  		}
  
  		if (value == null || variable.isInitialized())
  		{
  			value = JRFloatIncrementerFactory.ZERO;
  		}
  
  		return new Float(value.floatValue() + newValue.floatValue());
  	}
  
  	
  	public Object initialValue()
  	{
  		return JRFloatIncrementerFactory.ZERO;
  	}
  }
  
  
  /**
   *
   */
  class JRFloatAverageIncrementer extends JRAbstractExtendedIncrementer
  {
  	/**
  	 *
  	 */
  	private static JRFloatAverageIncrementer mainInstance = new JRFloatAverageIncrementer();
  
  	/**
  	 *
  	 */
  	private JRFloatAverageIncrementer()
  	{
  	}
  
  	/**
  	 *
  	 */
  	public static JRFloatAverageIncrementer 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(JRCalculable.HELPER_COUNT));
  		Number sumValue = (Number)valueProvider.getValue(variable.getHelperVariable(JRCalculable.HELPER_SUM));
  		return new Float(sumValue.floatValue() / countValue.floatValue());
  	}
  
  	
  	public Object initialValue()
  	{
  		return JRFloatIncrementerFactory.ZERO;
  	}
  }
  
  
  /**
   *
   */
  class JRFloatStandardDeviationIncrementer extends JRAbstractExtendedIncrementer
  {
  	/**
  	 *
  	 */
  	private static JRFloatStandardDeviationIncrementer mainInstance = new JRFloatStandardDeviationIncrementer();
  
  	/**
  	 *
  	 */
  	private JRFloatStandardDeviationIncrementer()
  	{
  	}
  
  	/**
  	 *
  	 */
  	public static JRFloatStandardDeviationIncrementer getInstance()
  	{
  		return mainInstance;
  	}
  
  	/**
  	 *
  	 */
  	public Object increment(
  		JRCalculable variable, 
  		Object expressionValue,
  		AbstractValueProvider valueProvider
  		)
  	{
  		if (expressionValue == null)
  		{
  			if (variable.isInitialized())
  			{
  				return null;
  			}
  			return variable.getValue(); 
  		}
  		Number varianceValue = (Number)valueProvider.getValue(variable.getHelperVariable(JRCalculable.HELPER_VARIANCE));
  		return new Float( Math.sqrt(varianceValue.doubleValue()) );
  	}
  
  	
  	public Object initialValue()
  	{
  		return JRFloatIncrementerFactory.ZERO;
  	}
  }
  
  
  /**
   *
   */
  class JRFloatVarianceIncrementer extends JRAbstractExtendedIncrementer
  {
  	/**
  	 *
  	 */
  	private static JRFloatVarianceIncrementer mainInstance = new JRFloatVarianceIncrementer();
  
  	/**
  	 *
  	 */
  	private JRFloatVarianceIncrementer()
  	{
  	}
  
  	/**
  	 *
  	 */
  	public static JRFloatVarianceIncrementer getInstance()
  	{
  		return mainInstance;
  	}
  
  	/**
  	 *
  	 */
  	public Object increment(
  		JRCalculable variable, 
  		Object expressionValue,
  		AbstractValueProvider valueProvider
  		)
  	{
  		Number value = (Number)variable.getIncrementedValue();
  