Package is.codion.plugin.jasperreports
Class JasperReportsDataSource<T>
java.lang.Object
is.codion.plugin.jasperreports.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 Summary
ConstructorsConstructorDescriptionJasperReportsDataSource(Iterator<T> reportIterator, BiFunction<T, net.sf.jasperreports.engine.JRField, Object> valueProvider) Instantiates a new JasperReportsDataSource.JasperReportsDataSource(Iterator<T> reportIterator, BiFunction<T, net.sf.jasperreports.engine.JRField, Object> valueProvider, Consumer<T> onNext) Instantiates a new JasperReportsDataSource. -
Method Summary
Modifier and TypeMethodDescriptionfinal Tfinal ObjectgetFieldValue(net.sf.jasperreports.engine.JRField field) Returns the value associated with the attributed namedfield.getName()final booleannext()
-
Constructor Details
-
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 datavalueProvider- 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 datavalueProvider- a Function returning the value for a given field from the given itemonNext- called each time next has been called
-
-
Method Details
-
next
public final boolean next()- Specified by:
nextin interfacenet.sf.jasperreports.engine.JRDataSource
-
getFieldValue
public final Object getFieldValue(net.sf.jasperreports.engine.JRField field) throws net.sf.jasperreports.engine.JRException Returns the value associated with the attributed namedfield.getName()- Specified by:
getFieldValuein interfacenet.sf.jasperreports.engine.JRDataSource- Parameters:
field- the report field which value to retrieve- Returns:
- the value associated with the attribute named
field.getName() - Throws:
net.sf.jasperreports.engine.JRException- in case of an exception
-
currentItem
- Returns:
- the current item
- Throws:
IllegalStateException- in case next has not been called and no current item is available
-