org.jfree.report.function
Class LevelledExpressionList

java.lang.Object
  extended byorg.jfree.report.function.LevelledExpressionList
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, LayoutListener, PageEventListener, ReportListener

public final class LevelledExpressionList
extends java.lang.Object
implements ReportListener, java.lang.Cloneable, LayoutListener, PageEventListener

A list of expressions/functions and associated levels. This class listens for report events, then passes these events on to the expressions and functions in *descending* level order.

Author:
Thomas Morgner

Constructor Summary
protected LevelledExpressionList()
          DefaultConstructor.
  LevelledExpressionList(ExpressionCollection ec, ExpressionCollection fc)
          Creates a new list.
 
Method Summary
protected  void addError(java.lang.Exception e)
          Adds the error to the current list of errors.
protected  void clearError()
          Clears the error list.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 void firePrepareEvent(ReportEvent event)
          Fires a prepare event.
protected  void firePrepareEventLayoutListener(ReportEvent event)
          Fires a prepare event layout listeners.
 DataRow getDataRow()
          Returns the currently connected dataRow.
 java.util.List getErrors()
          Returns the list of errors, that occured during the last event handling.
 Expression getExpression(int index)
          Returns an expression.
 int getLevel()
          Gets the current level.
 java.util.Iterator getLevelsAscending()
          Returns an iterator that provides access to the levels in ascending order.
 java.util.Iterator getLevelsDescending()
          Returns an iterator that provides access to the levels in descending order.
 LevelledExpressionList getPreviewInstance()
          Returns the preview instance of the levelled expression list.
 java.lang.Object getValue(int index)
          Returns the values of an expression.
 void groupFinished(ReportEvent event)
          Receives notification that a group is finished.
 void groupStarted(ReportEvent event)
          Receives notification that a new group has started.
 boolean hasErrors()
          Returns true, if this list has detected at least one error in the last operation.
 void itemsAdvanced(ReportEvent event)
          Receives notification that a new row has been read.
 void itemsFinished(ReportEvent event)
          Receives notification that a group of item bands has been completed.
 void itemsStarted(ReportEvent event)
          Receives notification that a group of item bands is about to be processed.
 void layoutComplete(LayoutEvent event)
          Receives notification that the band layouting has completed.
 void pageCanceled(ReportEvent event)
          Receives notification that a new page is being started.
 void pageFinished(ReportEvent event)
          Receives notification that a page is completed.
 void pageStarted(ReportEvent event)
          Receives notification that a new page is being started.
 void reportDone(ReportEvent event)
          Receives notification that report generation has completed, the report footer was printed, no more output is done.
 void reportFinished(ReportEvent event)
          Receives notification that report generation has finished (the last record is read and all groups are closed).
 void reportInitialized(ReportEvent event)
          Receives notification that report generation has started.
 void reportStarted(ReportEvent event)
          Receives notification that report generation has started.
 void setDataRow(DataRow dr)
          Connects the given datarow to the expression collection and all expressions contained in this collection.
 void setLevel(int level)
          Sets the level.
 int size()
          Size does not change, so it is cached.
 void updateDataRow(DataRow dr)
          Updates the datarow for all expressions.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LevelledExpressionList

protected LevelledExpressionList()
DefaultConstructor.


LevelledExpressionList

public LevelledExpressionList(ExpressionCollection ec,
                              ExpressionCollection fc)
Creates a new list.

Parameters:
ec - the expressions from the report definition.
fc - the functions from the report definition.
Method Detail

reportStarted

public void reportStarted(ReportEvent event)
Receives notification that report generation has started.

The event carries a ReportState.Started state. Use this to prepare the report header.

Specified by:
reportStarted in interface ReportListener
Parameters:
event - the event.

reportInitialized

public void reportInitialized(ReportEvent event)
Receives notification that report generation has started.

The event carries a ReportState.Started state. Use this to initialize the report.

Specified by:
reportInitialized in interface ReportListener
Parameters:
event - the event.

reportFinished

public void reportFinished(ReportEvent event)
Receives notification that report generation has finished (the last record is read and all groups are closed).

Specified by:
reportFinished in interface ReportListener
Parameters:
event - the event.

pageStarted

public void pageStarted(ReportEvent event)
Receives notification that a new page is being started.

Specified by:
pageStarted in interface PageEventListener
Parameters:
event - the event.

pageCanceled

public void pageCanceled(ReportEvent event)
Receives notification that a new page is being started.

Specified by:
pageCanceled in interface PageEventListener
Parameters:
event - the event.

pageFinished

public void pageFinished(ReportEvent event)
Receives notification that a page is completed.

Specified by:
pageFinished in interface PageEventListener
Parameters:
event - the event.

groupStarted

public void groupStarted(ReportEvent event)
Receives notification that a new group has started.

The group can be determined by the report state's getCurrentGroup() function.

Specified by:
groupStarted in interface ReportListener
Parameters:
event - the event.

groupFinished

public void groupFinished(ReportEvent event)
Receives notification that a group is finished.

The group can be determined by the report state's getCurrentGroup() function.

Specified by:
groupFinished in interface ReportListener
Parameters:
event - the event.

itemsStarted

public void itemsStarted(ReportEvent event)
Receives notification that a group of item bands is about to be processed.

The next events will be itemsAdvanced events until the itemsFinished event is raised.

Specified by:
itemsStarted in interface ReportListener
Parameters:
event - the event.

itemsFinished

public void itemsFinished(ReportEvent event)
Receives notification that a group of item bands has been completed.

The itemBand is finished, the report starts to close open groups.

Specified by:
itemsFinished in interface ReportListener
Parameters:
event - the event.

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Receives notification that a new row has been read.

This event is raised before an ItemBand is printed.

Specified by:
itemsAdvanced in interface ReportListener
Parameters:
event - the event.

layoutComplete

public void layoutComplete(LayoutEvent event)
Receives notification that the band layouting has completed.

The event carries the current report state.

Specified by:
layoutComplete in interface LayoutListener
Parameters:
event - The event.

reportDone

public void reportDone(ReportEvent event)
Receives notification that report generation has completed, the report footer was printed, no more output is done. This is a helper event to shut down the output service.

Specified by:
reportDone in interface ReportListener
Parameters:
event - The event.

setDataRow

public void setDataRow(DataRow dr)
Connects the given datarow to the expression collection and all expressions contained in this collection.

Parameters:
dr - the datarow to be connected (null not permitted).
Throws:
java.lang.IllegalStateException - if there is a datarow already connected.
java.lang.NullPointerException - if the given datarow is null.

updateDataRow

public void updateDataRow(DataRow dr)
Updates the datarow for all expressions. Does not perform validity checks, so use this function with care.

Parameters:
dr - the datarow to be connected.
Throws:
java.lang.NullPointerException - if the given datarow is null.
java.lang.IllegalStateException - if there is no datarow connected.

getDataRow

public DataRow getDataRow()
Returns the currently connected dataRow.

Returns:
the dataRow.

size

public int size()
Size does not change, so it is cached.

Returns:
the size.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object.

The cloned LevelledExpressionList will no longer be connected to a datarow.

Returns:
a clone of this instance.
Throws:
java.lang.CloneNotSupportedException - if the object's class does not support the Cloneable interface.
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

getPreviewInstance

public LevelledExpressionList getPreviewInstance()
Returns the preview instance of the levelled expression list. This list does no longer contain any Function instances.

Returns:
the preview (expressions only) instance of the levelled expression list.

setLevel

public void setLevel(int level)
Sets the level.

Parameters:
level - the level.

getLevel

public int getLevel()
Gets the current level.

Returns:
the current level.

getLevelsDescending

public java.util.Iterator getLevelsDescending()
Returns an iterator that provides access to the levels in descending order.

Returns:
the iterator.

getLevelsAscending

public java.util.Iterator getLevelsAscending()
Returns an iterator that provides access to the levels in ascending order.

Returns:
the iterator.

getValue

public java.lang.Object getValue(int index)
Returns the values of an expression.

Parameters:
index - the function/expression index.
Returns:
the value.

getExpression

public Expression getExpression(int index)
Returns an expression.

Parameters:
index - the function/expression index.
Returns:
the function/expression.

getErrors

public java.util.List getErrors()
Returns the list of errors, that occured during the last event handling.

Returns:
the list of errors.

hasErrors

public boolean hasErrors()
Returns true, if this list has detected at least one error in the last operation.

Returns:
true, if there were errors, false otherwise.

addError

protected void addError(java.lang.Exception e)
Adds the error to the current list of errors.

Parameters:
e - the new exception that occured during the event dispatching.

clearError

protected void clearError()
Clears the error list.


firePrepareEvent

public void firePrepareEvent(ReportEvent event)
Fires a prepare event.

Parameters:
event - the event.

firePrepareEventLayoutListener

protected void firePrepareEventLayoutListener(ReportEvent event)
Fires a prepare event layout listeners.

Parameters:
event - the event.