Java 类net.sf.jasperreports.engine.data.JRBeanArrayDataSource 实例源码

项目:lams    文件:JasperReportsUtils.java   
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>In the default implementation, a {@code JRDataSource},
 * {@code java.util.Collection} or object array is detected.
 * The latter are converted to {@code JRBeanCollectionDataSource}
 * or {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource (never {@code null})
 * @throws IllegalArgumentException if the value could not be converted
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
public static JRDataSource convertReportData(Object value) throws IllegalArgumentException {
    if (value instanceof JRDataSource) {
        return (JRDataSource) value;
    }
    else if (value instanceof Collection) {
        return new JRBeanCollectionDataSource((Collection<?>) value);
    }
    else if (value instanceof Object[]) {
        return new JRBeanArrayDataSource((Object[]) value);
    }
    else {
        throw new IllegalArgumentException("Value [" + value + "] cannot be converted to a JRDataSource");
    }
}
项目:SamlSnort    文件:ReportUtil.java   
public static JasperPrint createJasperPrint(TestSuite testSuite)
        throws JRException {
    LOGGER.entering(ReportUtil.class.getName(), "createJasperPrint",
            testSuite);

    Map<Object, Object> properties = new HashMap<Object, Object>();
    properties.put("REPORT_TITLE", RESORUCE.getString("reportName"));
    properties.put("SUBREPORT_INPUT_STREAM", ReportUtil.class
            .getResourceAsStream("subreport.jasper"));

    JasperPrint print = JasperFillManager
    .fillReport(ReportUtil.class.getResourceAsStream("report.jasper"),
            properties, new JRBeanArrayDataSource(
                    new TestSuite[] { testSuite }));

    LOGGER.exiting(ReportUtil.class.getName(), "createJasperPrint", print);
    return print;
}
项目:spring4-understanding    文件:JasperReportsUtils.java   
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>In the default implementation, a {@code JRDataSource},
 * {@code java.util.Collection} or object array is detected.
 * The latter are converted to {@code JRBeanCollectionDataSource}
 * or {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource (never {@code null})
 * @throws IllegalArgumentException if the value could not be converted
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
public static JRDataSource convertReportData(Object value) throws IllegalArgumentException {
    if (value instanceof JRDataSource) {
        return (JRDataSource) value;
    }
    else if (value instanceof Collection) {
        return new JRBeanCollectionDataSource((Collection<?>) value);
    }
    else if (value instanceof Object[]) {
        return new JRBeanArrayDataSource((Object[]) value);
    }
    else {
        throw new IllegalArgumentException("Value [" + value + "] cannot be converted to a JRDataSource");
    }
}
项目:jasperreports    文件:DataSourceApp.java   
/**
 *
 */
public void fill3() throws JRException
{
    long start = System.currentTimeMillis();
    //Preparing parameters
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("ReportTitle", "Address Report");
    parameters.put("DataFile", "CustomBeanFactory.java - Bean Array");

    JasperFillManager.fillReportToFile("build/reports/DataSourceReport.jasper", parameters, new JRBeanArrayDataSource(CustomBeanFactory.getBeanArray()));
    System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
项目:class-guard    文件:JasperReportsUtils.java   
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>In the default implementation, a {@code JRDataSource},
 * {@code java.util.Collection} or object array is detected.
 * The latter are converted to {@code JRBeanCollectionDataSource}
 * or {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource (never {@code null})
 * @throws IllegalArgumentException if the value could not be converted
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
public static JRDataSource convertReportData(Object value) throws IllegalArgumentException {
    if (value instanceof JRDataSource) {
        return (JRDataSource) value;
    }
    else if (value instanceof Collection) {
        return new JRBeanCollectionDataSource((Collection) value);
    }
    else if (value instanceof Object[]) {
        return new JRBeanArrayDataSource((Object[]) value);
    }
    else {
        throw new IllegalArgumentException("Value [" + value + "] cannot be converted to a JRDataSource");
    }
}
项目:TarjetasISIS    文件:Reporte.java   
public static void generarReporteCliente(String jrxml, List<Cliente> parametros, String nombreArchivo)  throws JRException{

    HashMap<String, Object> map = new HashMap<String, Object>();

    //Levanta el jrxml
    List<ClienteReporte> salida = transformarClientes(parametros);

    File file = new File(jrxml);


    //Almacena el array de datos
    JRBeanArrayDataSource jArray= new JRBeanArrayDataSource(salida.toArray());

    InputStream input = null;
    try{
        input = new FileInputStream(file);

    }catch(Exception e){
        System.out.println(e.getMessage());
    }

    //Levanta el modelo del reporte         
    JasperDesign jd = JRXmlLoader.load(input);

    //Compila el reporte
    JasperReport reporte = JasperCompileManager.compileReport(jd);

    //Lo llena con los datos del datasource
    JasperPrint print = JasperFillManager.fillReport(reporte, map, jArray);

    //Lo muestra con el jasperviewer
    //JasperViewer.viewReport(print, false);


    JasperExportManager.exportReportToPdfFile(print, nombreArchivo + ".pdf");

    //Abre el reporte recien generado
    try {
         File path = new File (nombreArchivo + ".pdf");
         Desktop.getDesktop().open(path);
    }catch (IOException ex) {
         ex.printStackTrace();
    }       
}
项目:dynamicreports-jasper    文件:BeanArraySubDatasourceExpression.java   
@Override
protected JRDataSource createSubDatasource(Object[] data) {
    return new JRBeanArrayDataSource(data);
}
项目:TarjetasISIS    文件:Reporte.java   
public static void generarReporte(String jrxml, List<LugarObservacion> parametros, String nombreArchivo)  throws JRException{
    HashMap<String, Object> map = new HashMap<String, Object>();

    //Levanta el jrxml


    File file = new File(jrxml);


    //Almacena el array de datos
    JRBeanArrayDataSource jArray= new JRBeanArrayDataSource(parametros.toArray());

    InputStream input = null;
    try{
        input = new FileInputStream(file);

    }catch(Exception e){
        System.out.println(e.getMessage());
    }

    //Levanta el modelo del reporte         
    JasperDesign jd = JRXmlLoader.load(input);

    //Compila el reporte
    JasperReport reporte = JasperCompileManager.compileReport(jd);

    //Lo llena con los datos del datasource
    JasperPrint print = JasperFillManager.fillReport(reporte, map, jArray);

    //Lo muestra con el jasperviewer
    JasperViewer.viewReport(print, true);


    JasperExportManager.exportReportToPdfFile(print, nombreArchivo + ".pdf");

    //Abre el reporte recien generado
    try {
         File path = new File (nombreArchivo + ".pdf");
         Desktop.getDesktop().open(path);
    }catch (IOException ex) {
         ex.printStackTrace();
    }




}
项目:TarjetasISIS    文件:Reporte.java   
public static void generarReporteTarjetas(String jrxml, List<Tarjeta> parametros, String nombreArchivo)  throws JRException{

    HashMap<String, Object> map = new HashMap<String, Object>();

    List<TarjetaReporte> salida = transformarTarjetas(parametros);
    //Levanta el jrxml


    File file = new File(jrxml);


    //Almacena el array de datos
    JRBeanArrayDataSource jArray= new JRBeanArrayDataSource(salida.toArray());

    InputStream input = null;
    try{
        input = new FileInputStream(file);

    }catch(Exception e){
        System.out.println(e.getMessage());
    }

    //Levanta el modelo del reporte         
    JasperDesign jd = JRXmlLoader.load(input);

    //Compila el reporte
    JasperReport reporte = JasperCompileManager.compileReport(jd);

    //Lo llena con los datos del datasource
    JasperPrint print = JasperFillManager.fillReport(reporte, map, jArray);

    //Lo muestra con el jasperviewer
    //JasperViewer.viewReport(print, false);


    JasperExportManager.exportReportToPdfFile(print, nombreArchivo + ".pdf");

    //Abre el reporte recien generado
    try {
         File path = new File (nombreArchivo + ".pdf");
         Desktop.getDesktop().open(path);
    }catch (IOException ex) {
         ex.printStackTrace();
    }




}