Java源码示例:net.sf.jasperreports.engine.JRDataSourceProvider

示例1
/**
 * Create a report using the given provider.
 * @param provider the JRDataSourceProvider to use
 * @return the created report
 */
protected JRDataSource createReport(JRDataSourceProvider provider) {
	try {
		JasperReport report = getReport();
		if (report == null) {
			throw new IllegalStateException("No main report defined for JRDataSourceProvider - " +
					"specify a 'url' on this view or override 'getReport()'");
		}
		return provider.create(report);
	}
	catch (JRException ex) {
		throw new IllegalArgumentException("Supplied JRDataSourceProvider is invalid", ex);
	}
}
 
示例2
/**
 * Create a report using the given provider.
 * @param provider the JRDataSourceProvider to use
 * @return the created report
 */
protected JRDataSource createReport(JRDataSourceProvider provider) {
	try {
		JasperReport report = getReport();
		if (report == null) {
			throw new IllegalStateException("No main report defined for JRDataSourceProvider - " +
					"specify a 'url' on this view or override 'getReport()'");
		}
		return provider.create(report);
	}
	catch (JRException ex) {
		throw new IllegalArgumentException("Supplied JRDataSourceProvider is invalid", ex);
	}
}
 
示例3
@Override
public void contributeParameters(Map<String, Object> parameters) throws JRException 
{
	JRDataSourceProvider dsProvider = getProvider();
	if (dsProvider != null) 
	{
		JasperReport jr = (JasperReport) parameters.get(JRParameter.JASPER_REPORT);
		parameters.put(JRParameter.REPORT_DATA_SOURCE, dsProvider.create(jr));
	}
}
 
示例4
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>The default implementation delegates to {@code JasperReportUtils} unless
 * the report data value is an instance of {@code JRDataSourceProvider}.
 * A {@code JRDataSource}, {@code JRDataSourceProvider},
 * {@code java.util.Collection} or object array is detected.
 * {@code JRDataSource}s are returned as is, whilst {@code JRDataSourceProvider}s
 * are used to create an instance of {@code JRDataSource} which is then returned.
 * The latter two are converted to {@code JRBeanCollectionDataSource} or
 * {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource
 * @throws IllegalArgumentException if the value could not be converted
 * @see org.springframework.ui.jasperreports.JasperReportsUtils#convertReportData
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.JRDataSourceProvider
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
protected JRDataSource convertReportData(Object value) throws IllegalArgumentException {
	if (value instanceof JRDataSourceProvider) {
		return createReport((JRDataSourceProvider) value);
	}
	else {
		return JasperReportsUtils.convertReportData(value);
	}
}
 
示例5
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>The default implementation delegates to {@code JasperReportUtils} unless
 * the report data value is an instance of {@code JRDataSourceProvider}.
 * A {@code JRDataSource}, {@code JRDataSourceProvider},
 * {@code java.util.Collection} or object array is detected.
 * {@code JRDataSource}s are returned as is, whilst {@code JRDataSourceProvider}s
 * are used to create an instance of {@code JRDataSource} which is then returned.
 * The latter two are converted to {@code JRBeanCollectionDataSource} or
 * {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource
 * @throws IllegalArgumentException if the value could not be converted
 * @see org.springframework.ui.jasperreports.JasperReportsUtils#convertReportData
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.JRDataSourceProvider
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
protected JRDataSource convertReportData(Object value) throws IllegalArgumentException {
	if (value instanceof JRDataSourceProvider) {
		return createReport((JRDataSourceProvider) value);
	}
	else {
		return JasperReportsUtils.convertReportData(value);
	}
}