if (percentageCalculatorClass == null)
{
calculator = (JRPercentageCalculator) builtInCalculators.get(valueClass.getName());
if (calculator == null)
{
throw new JRRuntimeException("Measure with type " + valueClass.getName() + " should specify a percentage calculator class.");
}
}
else
{
calculator = (JRPercentageCalculator) cachedCalculators.get(percentageCalculatorClass.getName());
if (calculator == null)
{
try
{
calculator = (JRPercentageCalculator) percentageCalculatorClass.newInstance();
cachedCalculators.put(percentageCalculatorClass.getName(), calculator);
}
catch (InstantiationException e)
{
throw new JRRuntimeException("Error while creating percentage calculator instance of " + percentageCalculatorClass + ".", e);
}
catch (IllegalAccessException e)
{
throw new JRRuntimeException("Error while creating percentage calculator instance of " + percentageCalculatorClass + ".", e);
}
}
}
return calculator;