|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jfree.report.function.AbstractExpression
org.jfree.report.modules.misc.beanshell.BSHExpression
An expression that uses the BeanShell scripting framework to perform a scripted calculation. The expression itself is contained in a function called
Object getValue()
and this function is defined in the expression
property. You have to overwrite
the function getValue()
to begin and to end your expression, but you are free to
add your own functions to the script.
By default, base Java core and extension packages are imported for you. They are:
java.lang
java.io
java.util
java.net
java.awt
java.awt.event
javax.swing
javax.swing.event
An example in the XML format: (from report1.xml)
// you may import packages and classes or use the fully qualified name of the class import org.jfree.report.*; String userdefinedFunction (String parameter, Date date) { return parameter + " - the current date is " + date); } // use simple java code to perform the expression. You may use all classes // available in your classpath as if you write "real" java code in your favourite // IDE. // See the www.beanshell.org site for more information ... // // A return value of type "Object" is alway implied ... getValue () { return userdefinedFunction ("Hello World :) ", new Date()); }
Field Summary | |
static java.lang.String |
BSHHEADERFILE
The headerfile with the default initialisations. |
Fields inherited from interface org.jfree.report.function.Expression |
AUTOACTIVATE_PROPERTY |
Constructor Summary | |
BSHExpression()
default constructor, create a new BeanShellExpression. |
Method Summary | |
java.lang.Object |
clone()
Clones the expression and reinitializes the script. |
Expression |
getInstance()
Return a new instance of this expression. |
java.lang.Object |
getValue()
Evaluates the defined expression. |
void |
initialize()
Initializes the expression by executing the header file and the expression. |
Methods inherited from class org.jfree.report.function.AbstractExpression |
getDataRow, getDependencyLevel, getName, getProperties, getProperty, getProperty, isActive, setDataRow, setDependencyLevel, setName, setProperties, setProperty |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String BSHHEADERFILE
Constructor Detail |
public BSHExpression()
Method Detail |
public java.lang.Object getValue()
Expressions do not maintain a state and no assumptions about the order of evaluation can be made.
getValue
in interface Expression
public void initialize() throws FunctionInitializeException
Initialisations of the script can be put at the end of the script:
...... getValue () { return userdefinedFunction ("Hello World :) ", new Date()); } ... // script initialisations here System.out.println ("Script initialized @ " + new Date()); ...
initialize
in interface Expression
initialize
in class AbstractExpression
FunctionInitializeException
- if the expression has not been initialized correctly.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface Expression
clone
in class AbstractExpression
java.lang.CloneNotSupportedException
- this should never happen.public Expression getInstance()
getInstance
in interface Expression
getInstance
in class AbstractExpression
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |