net.sf.jasperreports.engine.fill
Class BaseFillHandle

java.lang.Object
  extended by net.sf.jasperreports.engine.fill.BaseFillHandle
All Implemented Interfaces:
FillHandle
Direct Known Subclasses:
AsynchronousFillHandle

public abstract class BaseFillHandle
extends java.lang.Object
implements FillHandle

Base class used to perform report filling asychronously.

An instance of this type can be used as a handle to an asychronous fill process. The main benefit of this method is that the filling process can be cancelled.

Version:
$Id: BaseFillHandle.java 5050 2012-03-12 10:11:26Z teodord $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
protected  class BaseFillHandle.ReportFiller
           
 
Field Summary
protected  boolean cancelled
           
protected  java.sql.Connection conn
           
protected  JRDataSource dataSource
           
protected  JRBaseFiller filler
           
protected  JasperReport jasperReport
           
protected  JasperReportsContext jasperReportsContext
           
protected  java.util.List<AsynchronousFilllListener> listeners
           
protected  java.lang.Object lock
           
protected  java.util.Map<java.lang.String,java.lang.Object> parameters
           
protected  boolean running
           
protected  boolean started
           
 
Constructor Summary
protected BaseFillHandle(JasperReportsContext jasperReportsContext, JasperReport jasperReport, java.util.Map<java.lang.String,java.lang.Object> parameters, JRDataSource dataSource, java.sql.Connection conn)
           
 
Method Summary
 void addFillListener(FillListener listener)
          Adds a fill listener to the filling process.
 void addListener(AsynchronousFilllListener listener)
          Adds a listener to the filling process.
 void cancellFill()
          Cancels the fill started by the handle.
protected abstract  java.util.concurrent.Executor getReportExecutor()
           
 boolean isPageFinal(int pageIdx)
          Determines wheter a page generated by the fill process is final or not.
protected  void notifyCancel()
           
protected  void notifyError(java.lang.Throwable e)
           
protected  void notifyFinish(JasperPrint print)
           
 boolean removeListener(AsynchronousFilllListener listener)
          Removes a listener from the filling process.
 void startFill()
          Starts the filling process asychronously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jasperReportsContext

protected final JasperReportsContext jasperReportsContext

jasperReport

protected final JasperReport jasperReport

parameters

protected final java.util.Map<java.lang.String,java.lang.Object> parameters

dataSource

protected final JRDataSource dataSource

conn

protected final java.sql.Connection conn

filler

protected final JRBaseFiller filler

listeners

protected final java.util.List<AsynchronousFilllListener> listeners

started

protected boolean started

running

protected boolean running

cancelled

protected boolean cancelled

lock

protected final java.lang.Object lock
Constructor Detail

BaseFillHandle

protected BaseFillHandle(JasperReportsContext jasperReportsContext,
                         JasperReport jasperReport,
                         java.util.Map<java.lang.String,java.lang.Object> parameters,
                         JRDataSource dataSource,
                         java.sql.Connection conn)
                  throws JRException
Throws:
JRException
Method Detail

addListener

public void addListener(AsynchronousFilllListener listener)
Description copied from interface: FillHandle
Adds a listener to the filling process.

Specified by:
addListener in interface FillHandle
Parameters:
listener - the listener to be added

addFillListener

public void addFillListener(FillListener listener)
Description copied from interface: FillHandle
Adds a fill listener to the filling process. The fill listener is notified of intermediate events that occur during the report generation.

Specified by:
addFillListener in interface FillHandle
Parameters:
listener - the listener to add

removeListener

public boolean removeListener(AsynchronousFilllListener listener)
Description copied from interface: FillHandle
Removes a listener from the filling process.

Specified by:
removeListener in interface FillHandle
Parameters:
listener - the listener to be removed
Returns:
true if the listener was found and removed

startFill

public void startFill()
Description copied from interface: FillHandle
Starts the filling process asychronously.

The filling can be launched on a new thread and the method exits after the execution is started.

When the filling finishes either in success or failure, the listeners are notified.

Specified by:
startFill in interface FillHandle

getReportExecutor

protected abstract java.util.concurrent.Executor getReportExecutor()

cancellFill

public void cancellFill()
                 throws JRException
Description copied from interface: FillHandle
Cancels the fill started by the handle.

The method sends a cancel signal to the filling process. When the filling process will end, the listeners will be notified that the filling has been cancelled.

Specified by:
cancellFill in interface FillHandle
Throws:
JRException

notifyFinish

protected void notifyFinish(JasperPrint print)

notifyCancel

protected void notifyCancel()

notifyError

protected void notifyError(java.lang.Throwable e)

isPageFinal

public boolean isPageFinal(int pageIdx)
Description copied from interface: FillHandle
Determines wheter a page generated by the fill process is final or not.

Specified by:
isPageFinal in interface FillHandle
Parameters:
pageIdx - the page index
Returns:
whether the page at the specified index is final or can be subject to future changes
See Also:
FillListener.pageUpdated(JasperPrint, int)


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com