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 T
final Object
getFieldValue
(net.sf.jasperreports.engine.JRField field) Returns value of the attribute with the namefield.getName()
final boolean
next()
-
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:
next
in interfacenet.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 namefield.getName()
- Specified by:
getFieldValue
in interfacenet.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
- Returns:
- the current item
- Throws:
IllegalStateException
- in case next has not been called and no current item is available
-