net.sf.jasperreports.engine
Class JRResultSetDataSource

java.lang.Object
  extended by net.sf.jasperreports.engine.JRResultSetDataSource
All Implemented Interfaces:
JRDataSource

public class JRResultSetDataSource
extends Object
implements JRDataSource

An implementation of a data source that uses a supplied ResultSet.

Version:
$Id: JRResultSetDataSource.java 5180 2012-03-29 13:23:12Z teodord $
Author:
Teodor Danciu (teodord@users.sourceforge.net)

Constructor Summary
JRResultSetDataSource(JasperReportsContext jasperReportsContext, ResultSet resultSet)
           
JRResultSetDataSource(ResultSet resultSet)
           
 
Method Summary
protected  String clobToString(Clob clob)
           
protected  Calendar createFieldCalendar(JRField field)
           
protected  CharArrayReader getArrayReader(Reader reader, long size)
           
protected  Calendar getFieldCalendar(JRField field)
           
 Object getFieldValue(JRField field)
          Gets the field value for the current position.
 boolean next()
          Tries to position the cursor on the next element in the data source.
protected  byte[] readBytes(InputStream is, long size)
           
protected  byte[] readBytes(Integer columnIndex)
           
protected  Object readDate(Integer columnIndex, JRField field)
           
protected  Object readTime(Integer columnIndex, JRField field)
           
protected  Object readTimestamp(Integer columnIndex, JRField field)
           
protected  Integer searchColumnByLabel(String fieldName)
           
protected  Integer searchColumnByName(String fieldName)
           
 void setTimeZone(TimeZone timeZone, boolean override)
          Sets the default time zone to be used for retrieving date/time values from the result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRResultSetDataSource

public JRResultSetDataSource(JasperReportsContext jasperReportsContext,
                             ResultSet resultSet)

JRResultSetDataSource

public JRResultSetDataSource(ResultSet resultSet)
See Also:
JRResultSetDataSource(JasperReportsContext, ResultSet)
Method Detail

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 interface JRDataSource
Returns:
true if there is a next record, false otherwise
Throws:
JRException - if any error occurs while trying to move to the next element

getFieldValue

public Object getFieldValue(JRField field)
                     throws JRException
Description copied from interface: JRDataSource
Gets the field value for the current position.

Specified by:
getFieldValue in interface JRDataSource
Returns:
an object containing the field value. The object type must be the field object type.
Throws:
JRException

readDate

protected Object readDate(Integer columnIndex,
                          JRField field)
                   throws SQLException
Throws:
SQLException

readTimestamp

protected Object readTimestamp(Integer columnIndex,
                               JRField field)
                        throws SQLException
Throws:
SQLException

readTime

protected Object readTime(Integer columnIndex,
                          JRField field)
                   throws SQLException
Throws:
SQLException

searchColumnByName

protected Integer searchColumnByName(String fieldName)
                              throws SQLException
Throws:
SQLException

searchColumnByLabel

protected Integer searchColumnByLabel(String fieldName)
                               throws SQLException
Throws:
SQLException

clobToString

protected String clobToString(Clob clob)
                       throws JRException
Throws:
JRException

getArrayReader

protected CharArrayReader getArrayReader(Reader reader,
                                         long size)
                                  throws IOException
Throws:
IOException

readBytes

protected byte[] readBytes(Integer columnIndex)
                    throws SQLException,
                           IOException
Throws:
SQLException
IOException

readBytes

protected byte[] readBytes(InputStream is,
                           long size)
                    throws IOException
Throws:
IOException

setTimeZone

public void setTimeZone(TimeZone timeZone,
                        boolean override)
Sets the default time zone to be used for retrieving date/time values from the result set. In most cases no explicit time zone conversion would be required for retrieving date/time values from the DB, and this parameter should be null.

Parameters:
timeZone - the default time zone
override - whether the default time zone overrides time zones specified as field-level properties
See Also:
JRJdbcQueryExecuterFactory.PROPERTY_TIME_ZONE

getFieldCalendar

protected Calendar getFieldCalendar(JRField field)

createFieldCalendar

protected Calendar createFieldCalendar(JRField field)


Copyright © 2012. All Rights Reserved.