Package net.sf.jasperreports.json.data
Class JsonQLDataSource
- java.lang.Object
-
- net.sf.jasperreports.engine.data.JRAbstractTextDataSource
-
- net.sf.jasperreports.json.data.JsonQLDataSource
-
- All Implemented Interfaces:
HierarchicalDataSource<JsonQLDataSource>
,JsonData<JsonQLDataSource>
,RandomAccessDataSource
,JRDataSource
,JRRewindableDataSource
public class JsonQLDataSource extends JRAbstractTextDataSource implements JsonData<JsonQLDataSource>, RandomAccessDataSource
- Author:
- Narcis Marcu (narcism@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXCEPTION_MESSAGE_KEY_JSON_FIELD_VALUE_NOT_RETRIEVED
static String
EXCEPTION_MESSAGE_KEY_NO_DATA
static String
PROPERTY_FIELD_EXPRESSION
Property specifying the JSONQL expression for the dataset field.-
Fields inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSource
EXCEPTION_MESSAGE_KEY_CANNOT_CONVERT_FIELD_TYPE, EXCEPTION_MESSAGE_KEY_CANNOT_MODIFY_PROPERTIES_AFTER_START, EXCEPTION_MESSAGE_KEY_NODE_NOT_AVAILABLE, EXCEPTION_MESSAGE_KEY_NULL_DOCUMENT, EXCEPTION_MESSAGE_KEY_NULL_SELECT_EXPRESSION, EXCEPTION_MESSAGE_KEY_UNKNOWN_COLUMN_NAME, EXCEPTION_MESSAGE_KEY_UNKNOWN_NUMBER_TYPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JsonQLDataSource(com.fasterxml.jackson.databind.JsonNode jacksonJsonTree, String selectExpression)
JsonQLDataSource(File file)
JsonQLDataSource(File file, String selectExpression)
JsonQLDataSource(InputStream jsonInputStream)
JsonQLDataSource(InputStream jsonInputStream, String selectExpression)
JsonQLDataSource(JasperReportsContext jasperReportsContext, String jsonSource, String selectExpression)
protected
JsonQLDataSource(JRJsonNode root, String selectExpression)
JsonQLDataSource(RepositoryContext repositoryContext, String jsonSource, String selectExpression)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
currentIndex()
protected Object
getConvertedValue(JRJsonNode node, JRField jrField)
protected String
getFieldExpression(JRField field)
Object
getFieldValue(JRField jrField)
Gets the field value for the current position.void
moveFirst()
Moves back to the first element in the data source.void
moveToRecord(int index)
boolean
next()
Tries to position the cursor on the next element in the data source.int
recordCount()
JsonQLDataSource
subDataSource()
JsonQLDataSource
subDataSource(String selectExpression)
-
Methods inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSource
convertNumber, convertStringValue, getConvertBean, getDatePattern, getLocale, getNumberPattern, getTextAttributes, getTimeZone, setDatePattern, setLocale, setLocale, setNumberPattern, setTextAttributes, setTextAttributes, setTimeZone, setTimeZone
-
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_NO_DATA
public static final String EXCEPTION_MESSAGE_KEY_NO_DATA
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_JSON_FIELD_VALUE_NOT_RETRIEVED
public static final String EXCEPTION_MESSAGE_KEY_JSON_FIELD_VALUE_NOT_RETRIEVED
- See Also:
- Constant Field Values
-
PROPERTY_FIELD_EXPRESSION
public static final String PROPERTY_FIELD_EXPRESSION
Property specifying the JSONQL expression for the dataset field.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JsonQLDataSource
public JsonQLDataSource(File file, String selectExpression) throws JRException
- Throws:
JRException
-
JsonQLDataSource
public JsonQLDataSource(File file) throws JRException
- Throws:
JRException
-
JsonQLDataSource
public JsonQLDataSource(InputStream jsonInputStream, String selectExpression) throws JRException
- Throws:
JRException
-
JsonQLDataSource
public JsonQLDataSource(InputStream jsonInputStream) throws JRException
- Throws:
JRException
-
JsonQLDataSource
public JsonQLDataSource(JasperReportsContext jasperReportsContext, String jsonSource, String selectExpression) throws JRException
- Throws:
JRException
-
JsonQLDataSource
public JsonQLDataSource(RepositoryContext repositoryContext, String jsonSource, String selectExpression) throws JRException
- Throws:
JRException
-
JsonQLDataSource
protected JsonQLDataSource(com.fasterxml.jackson.databind.JsonNode jacksonJsonTree, String selectExpression) throws JRException
- Throws:
JRException
-
JsonQLDataSource
protected JsonQLDataSource(JRJsonNode root, String selectExpression) throws JRException
- Throws:
JRException
-
-
Method Detail
-
moveFirst
public void moveFirst() throws JRException
Description copied from interface:JRRewindableDataSource
Moves back to the first element in the data source.- Specified by:
moveFirst
in interfaceJRRewindableDataSource
- Throws:
JRException
-
next
public boolean next() throws JRException
Description copied from interface:JRDataSource
Tries to position the cursor on the next element in the data source.- Specified by:
next
in interfaceJRDataSource
- Returns:
- true if there is a next record, false otherwise
- Throws:
JRException
- if any error occurs while trying to move to the next element
-
recordCount
public int recordCount()
- Specified by:
recordCount
in interfaceRandomAccessDataSource
-
currentIndex
public int currentIndex()
- Specified by:
currentIndex
in interfaceRandomAccessDataSource
-
moveToRecord
public void moveToRecord(int index) throws NoRecordAtIndexException
- Specified by:
moveToRecord
in interfaceRandomAccessDataSource
- Throws:
NoRecordAtIndexException
-
getFieldValue
public Object getFieldValue(JRField jrField) throws JRException
Description copied from interface:JRDataSource
Gets the field value for the current position.- Specified by:
getFieldValue
in interfaceJRDataSource
- Returns:
- an object containing the field value. The object type must be the field object type.
- Throws:
JRException
-
subDataSource
public JsonQLDataSource subDataSource() throws JRException
- Specified by:
subDataSource
in interfaceHierarchicalDataSource<JsonQLDataSource>
- Throws:
JRException
-
subDataSource
public JsonQLDataSource subDataSource(String selectExpression) throws JRException
- Specified by:
subDataSource
in interfaceHierarchicalDataSource<JsonQLDataSource>
- Throws:
JRException
-
getConvertedValue
protected Object getConvertedValue(JRJsonNode node, JRField jrField) throws JRException
- Throws:
JRException
-
-