Class JasperReportsDataSource<T>

  • Type Parameters:
    T - the type to fetch the data from
    All Implemented Interfaces:
    net.sf.jasperreports.engine.JRDataSource

    public class JasperReportsDataSource<T>
    extends Object
    implements net.sf.jasperreports.engine.JRDataSource
    A default JRDataSource implementation which iterates through the iterator received via the constructor.
    • Constructor Detail

      • JasperReportsDataSource

        public JasperReportsDataSource​(Iterator<T> reportIterator,
                                       BiFunction<T,​net.sf.jasperreports.engine.JRField,​Object> valueProvider)
        Instantiates a new JasperReportsDataSource.
        Parameters:
        reportIterator - the iterator providing the report data
        valueProvider - a Function returning the value for a given field from the given item
      • JasperReportsDataSource

        public JasperReportsDataSource​(Iterator<T> reportIterator,
                                       BiFunction<T,​net.sf.jasperreports.engine.JRField,​Object> valueProvider,
                                       Consumer<T> onNext)
        Instantiates a new JasperReportsDataSource.
        Parameters:
        reportIterator - the iterator providing the report data
        valueProvider - a Function returning the value for a given field from the given item
        onNext - called each time next has been called
    • Method Detail

      • next

        public final boolean next()
        Specified by:
        next in interface net.sf.jasperreports.engine.JRDataSource
      • getFieldValue

        public final Object getFieldValue​(net.sf.jasperreports.engine.JRField field)
                                   throws net.sf.jasperreports.engine.JRException
        Returns value of the attribute with the name field.getName()
        Specified by:
        getFieldValue in interface net.sf.jasperreports.engine.JRDataSource
        Parameters:
        field - the report field which value to retrieve
        Returns:
        the value of the attribute with the name field.getName()
        Throws:
        net.sf.jasperreports.engine.JRException - in case of an exception
      • currentItem

        public final T currentItem()
        Returns:
        the current item
        Throws:
        IllegalStateException - in case next has not been called and no current item is available