{
if (subreport != null)
{
verifyReportElement(subreport);
JRExpression expression = subreport.getExpression();
if (expression != null)
{
try
{
String className = expression.getValueClassName();
if (className == null)
{
addBrokenRule("Class not set for subreport expression.", expression);
}
else if (Arrays.binarySearch(getSubreportClassNames(), className) < 0)
{
addBrokenRule("Class \"" + className + "\" not supported for subreport expression.", expression);
}
}
catch (JRRuntimeException e)
{
addBrokenRule(e, expression);
}
}
expression = subreport.getParametersMapExpression();
if (expression != null)
{
try
{
Class clazz = expression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for subreport parameters map expression.", expression);
}
else if (!java.util.Map.class.isAssignableFrom(clazz))
{
addBrokenRule("Class " + clazz + " not supported for subreport parameters map expression. Use java.util.Map instead.", expression);
}
}
catch (JRRuntimeException e)
{
addBrokenRule(e, expression);
}
}
JRSubreportParameter[] parameters = subreport.getParameters();
if (parameters != null && parameters.length > 0)
{
for(int index = 0; index < parameters.length; index++)
{
JRSubreportParameter parameter = parameters[index];
if (parameter.getName() == null || parameter.getName().trim().length() == 0)
{
addBrokenRule("Subreport parameter name missing.", expression);
}
expression = parameter.getExpression();
if (expression != null)
{
try
{
Class clazz = expression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for subreport parameter expression : " + parameter.getName() + ". Use java.lang.Object class.", expression);
}
}
catch (JRRuntimeException e)
{
addBrokenRule(e, expression);
}
}
}
}
if (
subreport.getConnectionExpression() != null &&
subreport.getDataSourceExpression() != null
)
{
addBrokenRule("Subreport cannot have both connection expresion and data source expression.", subreport);
}
expression = subreport.getConnectionExpression();
if (expression != null)
{
try
{
Class clazz = expression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for subreport connection expression.", expression);
}
else if (!java.sql.Connection.class.isAssignableFrom(clazz))
{
addBrokenRule("Class " + clazz + " not supported for subreport connection expression. Use java.sql.Connection instead.", expression);
}
}
catch (JRRuntimeException e)
{
addBrokenRule(e, expression);
}
}
expression = subreport.getDataSourceExpression();
if (expression != null)
{
try
{
Class clazz = expression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for subreport data source expression.", expression);
}
else if (!net.sf.jasperreports.engine.JRDataSource.class.isAssignableFrom(clazz))