org.jfree.report.function
Class PageFunction

java.lang.Object
  extended byorg.jfree.report.function.AbstractFunction
      extended byorg.jfree.report.function.PageFunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, PageEventListener, ReportListener, java.io.Serializable
Direct Known Subclasses:
PageTotalFunction

public class PageFunction
extends AbstractFunction
implements java.io.Serializable, PageEventListener

A report function that counts pages. This method is only useable when a report processor is used, which generated PageEvents. The PageableReportProcessor is one of them.

As with all page dependent functions: The function will only be active, when the page events get fired, this usually only happens during the last pagination run and the printing. The function level will be negative when this happens.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
PageFunction()
          Constructs an unnamed function.
PageFunction(java.lang.String name)
          Constructs a named function.
 
Method Summary
 java.lang.String getGroup()
          Returns the group name.
protected  int getPage()
          Returns the current page.
 int getStartPage()
          Returns the start page.
 java.lang.Object getValue()
          Returns the page number (function value).
 void groupStarted(ReportEvent event)
          Receives notification that a group has started.
 void initialize()
          Checks that the function has been correctly initialized.
 boolean isIgnorePageCancelEvents()
          Returns whether this function will ignore PageCancel events.
 void pageCanceled(ReportEvent event)
          Receives notification that a page was canceled by the ReportProcessor.
 void pageFinished(ReportEvent event)
          Receives notification that a page is completed.
 void pageStarted(ReportEvent event)
          Receives notification from the report engine that a new page is starting.
 void reportInitialized(ReportEvent event)
          Receives notification that the report has started.
 void setGroup(java.lang.String group)
          Sets the name of the group that the function acts upon.
protected  void setPage(int page)
          Sets the current page.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getInstance, getName, getProperties, getProperty, getProperty, groupFinished, isActive, itemsAdvanced, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted, setDataRow, setDependencyLevel, setName, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageFunction

public PageFunction()
Constructs an unnamed function.

This constructor is intended for use by the SAX handler class only.


PageFunction

public PageFunction(java.lang.String name)
Constructs a named function.

Parameters:
name - the function name.
Method Detail

pageStarted

public void pageStarted(ReportEvent event)
Receives notification from the report engine that a new page is starting. Grabs the page number from the report state and stores it.

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

pageCanceled

public void pageCanceled(ReportEvent event)
Receives notification that a page was canceled by the ReportProcessor.

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 group has started.

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

reportInitialized

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

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

getValue

public java.lang.Object getValue()
Returns the page number (function value).

Specified by:
getValue in interface Expression
Returns:
the page number.

initialize

public void initialize()
                throws FunctionInitializeException
Checks that the function has been correctly initialized. If there is a problem, this method throws a FunctionInitializeException.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractFunction
Throws:
FunctionInitializeException - if the function name is not set or the call to isInitialized returns false.

getGroup

public java.lang.String getGroup()
Returns the group name.

Returns:
the group name.

setGroup

public void setGroup(java.lang.String group)
Sets the name of the group that the function acts upon.

Parameters:
group - the group name.

getStartPage

public int getStartPage()
Returns the start page.

Returns:
the start page.

isIgnorePageCancelEvents

public boolean isIgnorePageCancelEvents()
Returns whether this function will ignore PageCancel events. This defaults to false, so that there will be no gaps between the generated pages.

Returns:
true, if canceled pages should be ignored, false otherwise.

getPage

protected int getPage()
Returns the current page.

Returns:
the current page.

setPage

protected void setPage(int page)
Sets the current page.

Parameters:
page - the page.