org.jfree.report.function

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » pentaho report » org.jfree.report.function 
org.jfree.report.function
The function package contains statefull functions and stateless expression for JFreeReport.

The following lines apply to both functions and expressions.

JFreeReport supports 2 kinds of userdefined calculations: Functions are statefull calculations, when the report proceedes they change their state, they sum up, calculate averages, count etc. Statefull means in that case, given you feed the same event multiple times into the function,you are not guaranteed to get the same result.

Expressions in contrast do not maintain a state, they calculate a value or change the report-elements depending on the current Event feed to them. If you feed the same Event into the Expression multiple times, you will always get the same result.

Common to both variants is: Data is fed into the function/expression by using a DataRow object. This object provides the (among others) these methods

  • Object get(String name);
  • Object get(int columnName);
to read the values of a function, expression, a column from the tablemodel or a ReportProperty.

Expressions are simple and easily explained: Expression have the method

Object getValue() which is called when the expression is queried. All expression have to override this method to perform the calculation and to return the value.

Functions are more complex:
Functions have several notification methods, where the system informs the function that a new event is processed.

  • public void pageStarted (ReportEvent event);
  • public void reportStarted (ReportEvent event);
  • public void groupStarted (ReportEvent event);
  • public void itemsStarted (ReportEvent event);
  • public void itemsAdvanced (ReportEvent event);
  • public void itemsFinished (ReportEvent event);
  • public void groupFinished (ReportEvent event);
  • public void reportFinished (ReportEvent event);
  • public void pageFinished (ReportEvent event);
By using the Event-object, you have access to the ReportState. The state can be used for getting the current group, current item and for gaining access to the dataRow. In case you want to manipulate the ReportElements, you also have access to the JFreeReport object.

Functions live in an own environment, separated from the outside world. Changing the original JFreeReport object does not affect the inner JFreeReport-Object. You are also unable to add new Functions or expressions to the report from inside, so all functions and expression have to be set before the report processing has begun.

All Functions have to be cloneable. It is not guaranteed that the report is processed in an linear order, but it is guaranteed that a single instance of a function does pass a reportstate only once.

That means: When processing the report, the system clones the functions on certain save-points (for instance whenever a page is finished). This saved copy can later be used to restart the report processing on that saved point. The copy-state made will never return to a previous save point, but it can (and certainly will occur) that this copy is used to process the report from that saved point on.

So when saving a state after page 2, it will never happen, that this page-2-copy gets used to process page 2 a second time, but it could happen that copies of this page-2-state process the page 3 again and again.

The best way to avoid cloning problems is to use Unmodifiable objects or primitive datatypes when storing a state. Using java.lang.String, one of the java.lang.Number implementers or any other unmodifiable object type is always save. If you use complex objects, lists or hashtables and you get weird results, try to implement a deep-object-copy in the clone() method of the function for these objects.

Using the functions

The function implementation is loaded via its default constructor by the report parser, all function implementations which should be used from within the xml-definitions must define a public default constructor. The functions implementation is defined by specifiying the "class" attribute of the "function" tag and is loaded by using the default class loader. Your function implementation must be in the classloaders classpath.

As with every function, a single function can return one value, something mathematicans express like y = f(x) where x is the data from your report processing.

A function is called several times, for every state change (whenever the report advances) one of the ReportListener methods are called (reportStarted, groupStarted etc). Expressions do not receive events, they just perform their computations based on the current state.

The functions value is returned by the "getValue()" function. You can return any Object, but make sure, that this object does not get modified anymore after it was returned to the caller. (A simple way to obey to this rule is to create a new object whenever the computed object changes).

Functions may reuse results from other functions by using and querying the DataRow object supplied in the report state or the function.

The order of the functions and the order for receiving events is undefined for functions of the same dependency level. So if you define a function which reads values from an other function, it is wise to define the dependencies for these functions.

Defining dependencies is easy: A function with an higher dependency is called before any function with a lower dependency. By default all user functions have the dependency of "0", the lowest possible level. The dependency is defined by specifying the "deplevel" attribute of the function or expression tag.

When using the API, the dependency level is read by "getDependencyLevel()" and can be set with "setDependencyLevel(int)".

For the example above, the caller function would have the dependency level of '0' and the called function the level of '1' or higher.

Java Source File NameTypeComment
AbstractCompareExpression.javaClass The base class for all expressions that compare a value read from the datarow with another value.
AbstractElementFormatFunction.javaClass The AbstractElementFormatFunction provides a common base implementation for all functions that need to modify the report definition or the style of an report element or band during the report processing.
AbstractExpression.javaClass An abstract base class for implementing new report expressions.

Expressions are stateless functions which have access to the report's DataRow .

AbstractFunction.javaClass Base class for implementing new report functions.
AverageExpression.javaClass An expression that takes values from one or more fields and returns the average of them.
ColumnAggregationExpression.javaClass The base-class for all expressions that aggregate values from multiple columns.
ColumnAverageExpression.javaClass Computes the horizontal average over all columns specified in the field-list.
ColumnDifferenceExpression.javaClass Computes the difference between the given column values.
ColumnDivisionExpression.javaClass Divides all values read from the field-list.
ColumnMaximumExpression.javaClass Computes the maximum of all data-row columns defined in the field-list.
ColumnMinimumExpression.javaClass Computes the minimum of all data-row columns defined in the field-list.
ColumnMultiplyExpression.javaClass Multiplies all values read from the field-list.
ColumnSumExpression.javaClass Adds all values read from the field-list.
CompareFieldsExpression.javaClass Compares the values of two fields.
ConditionalItemSumFunction.javaClass A item sum function that only sums up the current value, if the value read from the conditionField is the same as the value from the conditionValue property.
ConvertToDateExpression.javaClass Parses a string into a date using the given date-format.
ConvertToNumberExpression.javaClass Parses a string into a number using the given decimal-format.
CountDistinctFunction.javaClass Counts the distinct occurences of an certain value of an column.
CreateGroupAnchorsFunction.javaClass Creates anchor objects for the current group.
CreateHyperLinksFunction.javaClass Adds hyperlinks to all elements with the name specified in 'element'.
DateCutExpression.javaClass Prunes a date in a calendar-unware way.
ElementColorFunction.javaClass A function that alternates between true and false for each item within a group.
ElementTrafficLightFunction.javaClass A function that performs basic traffic lighting based on a range of values and a given set of colors to use.
ElementVisibilityFunction.javaClass Triggers the visiblity of an element based on the boolean value read from the defined field.
ElementVisibilitySwitchFunction.javaClass A function that alternates between true and false for each item within a group.
EventMonitorFunction.javaClass A function that logs each event that it receives.
Expression.javaInterface An expression is a lightweight function that does not maintain a state.
ExpressionCollection.javaClass Collects all expressions used in the report.
ExpressionRuntime.javaInterface The expression runtime encapsulates all properties of the current report processing run that might be needed to successfully evaluate an expression.
ExpressionUtilities.javaClass A collection of utility methods which may be useful for expression-implementors.
FormulaExpression.javaClass The formula expression is used to evaluate a LibFormula/OpenFormula expression.
FormulaFunction.javaClass The formula function is a stateful version of the FormulaExpression and is used to evaluate a LibFormula/OpenFormula expression.
Function.javaInterface The interface for report functions.
FunctionInitializeException.javaClass An exception that indicates that a function has not been correctly initialised.
FunctionProcessingException.javaClass An exception that indicates that a function has not been correctly initialised.
FunctionUtilities.javaClass A collection of utility methods relating to functions.
GroupCountFunction.javaClass A report function that counts groups in a report.
HideElementByNameFunction.javaClass This function hides all elements with a given name, as long as the defined field does not contain the element name.
HideElementIfDataAvailableExpression.javaClass This functions checks the tablemodel and shows the named band, if there is no data available.
HideNullValuesFunction.javaClass Hides the specified elements if the given field contains empty strings or zero numbers.
HidePageBandForTableExportFunction.javaClass Hides the page header and footer if the export type is not pageable.
IsEmptyExpression.javaClass Checks, whether a field is empty.
IsNullExpression.javaClass Checks, whether a field contains a NULL value.
ItemAvgFunction.javaClass A report function that calculates the average of one field (column) from the TableModel.
ItemColumnQuotientExpression.javaClass A report function that calculates the quotient of two fields (columns) from the current row.

This function expects its input values to be java.lang.Number instances.

The function undestands two parameters.

ItemCountFunction.javaClass A report function that counts items in a report.
ItemHideFunction.javaClass The ItemHideFunction hides equal values in a group.
ItemMaxFunction.javaClass A report function that calculates the maximum value of one field (column) from the data-row.

The function can be used in two ways:

  • to calculate a maximum value for the entire report;
  • to calculate a maximum value within a particular group;
This function expects its input values to be either java.lang.Number instances or Strings that can be parsed to java.lang.Number instances using a java.text.DecimalFormat.

The function undestands two parameters, the field parameter is required and denotes the name of an ItemBand-field which gets summed up.

The parameter group denotes the name of a group.

ItemMinFunction.javaClass A report function that calculates the minimum value of one field (column) from the data-row.
ItemPercentageFunction.javaClass Calculates the percentage value of a numeric field.
ItemSumFunction.javaClass A report function that calculates the sum of one field (column) from the data-row.
NegativeNumberPaintChangeFunction.javaClass This function changes the color of the named elements according to the current value of a numeric field.
OutputFunction.javaInterface A simple tagging interface for the transition from function-based layouting back to explicit layouting.
PageFunction.javaClass A report function that counts pages.
PageItemCountFunction.javaClass An ItemCount function, that is reset to zero on every new page.
PageItemSumFunction.javaClass An ItemSum function, that is reset to zero on every new page.
PageOfPagesFunction.javaClass A report function that combines PageFunction and PageTotalFunction .
PageTotalFunction.javaClass Prints the total number of pages of an report.
PaintComponentFunction.javaClass Paints a AWT or Swing Component, fitting the component into the element bounds.
PaintDynamicComponentFunction.javaClass Paints a AWT or Swing Component.
PercentageExpression.javaClass Computes the percentage for a column in relation to a base column.

The function undestands two parameters.

ProcessingContext.javaInterface The processing context hold information about the progress of the report processing and contains global properties used during the report processing.
ReportFormulaContext.javaClass The report formula context is a FormulaContext implementation that connects the formula evaluator with the current data-row of the report process.

This is an internal class used by the FormulaExpression and FormulaFunction.

RowBandingFunction.javaClass A function that alternates the background-color for each item-band within a group.
ShowElementByNameFunction.javaClass This function hiddes the elements with the name specified in the 'element' parameter, if the given field has one of the values specified in the values array.
ShowElementIfDataAvailableExpression.javaClass This functions checks the tablemodel and hides the named elements, if there is no data available.
StructureFunction.javaInterface A structure function is a annonymous function that modifes the structure of the report or computes changes to the report definition on the current report.

Structure functions are considered to be part of the initial master-report.

TextFormatExpression.javaClass A TextFormatExpression uses a java.text.MessageFormat to concat and format one or more values evaluated from an expression, function or report datasource.

The TextFormatExpression uses the pattern property to define the global format-pattern used when evaluating the expression.

TotalCalculationFunction.javaClass A report function that stores the result of a calculation for a group or the complete report.
TotalGroupCountFunction.javaClass A report function that counts the total of groups in a report.
TotalGroupSumFunction.javaClass A report function that calculates the sum of one field (column) from the Data-Row.
TotalGroupSumQuotientFunction.javaClass A report function that calculates the quotient of two summed fields (columns) from the report's data row.
TotalGroupSumQuotientPercentFunction.javaClass A report function that calculates the quotient of two summed fields (columns) from the data-row.
TotalItemCountFunction.javaClass A report function that counts the total number of items contained in groups in a report.
TotalItemMaxFunction.javaClass A report function that pre-computes the largest item in a group.
TotalItemMinFunction.javaClass A report function that pre-computes the smallest item in a group.
TotalPageItemCountFunction.javaClass A report function that counts the total number of items contained in groups in a report.
TriggerPageFooterFunction.javaClass This function enables a "PageFooter only on last page" functionality.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.