All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gnu.jel.Library

java.lang.Object
   |
   +----gnu.jel.Library

public class Library
extends Object
A Library of the methods, callable from compiled expressions.

There are following constraints on the functions in the library classes:


Constructor Index

 o Library(Class[], Class[])
Creates a library for JEL.

Method Index

 o isStateless(Method)
Used to check if the given method is stateless.
 o main(String[])
Performs unitary test of the library.
 o markStateDependent(String, Class[])
This function is itended for marking static function as having the internal state.
 o test(Tester)
Performs unitary test of the library.

Constructors

 o Library
 public Library(Class staticLib[],
                Class dynamicLib[])
Creates a library for JEL.

The following should be kept in mind when constructing a library:

  1. This constructor may throw IllegalArgumentException if it does not like something in Your library. The requirements to the method names are somewhat more strict, than in Java as the class.method(..) syntax is not used.
  2. When calling the CompiledExpression.evaluate(Object[] dynalib) of the expression, using dynamic library methods it is needed to pass as dynalib parameter the array of objects, of the classes _exactly_ in the same order as they are appearing in the dynamicLib parameter of this constructor. If You do not allow to call dynamic methods (there is no sense, then, to use a compiler) it is possible to pass null istead of dynalib.
  3. Generally speaking, this class should not let You to create wrong libraries. It's methods will throw exceptions, return false's , ignore Your actions,... ;)
If methods in the library classes conflict with each other, the last conflicting method will be skipped. You will not get any messages unless debugging is ON (see gnu.jel.debug.Debug.enabled). This is done to avoid unnecessary error messages in the production code of the compiler.

Parameters:
staticLib - is the array of classes, whose public static methods are exported.
dynamicLib - is the array of classes, whose public virutal methods are exported.

Methods

 o markStateDependent
 public void markStateDependent(String name,
                                Class params[]) throws NoSuchMethodException
This function is itended for marking static function as having the internal state.

If You include java.lang.Math into the library it is necessary to mark java.lang.random() as having the state. This can be done by calling markStateDependent("random",null)

Please specify parameters as close as possible, otherwise You can accidentally mark another function.

Parameters:
name - is the function name.
params - are the possible invocation parameters of the function.
Throws: NoSuchMethodException
if the method can't be resolved
 o isStateless
 public boolean isStateless(Method m)
Used to check if the given method is stateless.

Parameters:
m - is the method to check.
Returns:
true if the method is stateless and can be invoked at compile time.
 o main
 public static void main(String args[])
Performs unitary test of the library.

Parameters:
args - ignored.
 o test
 public static void test(Tester t)
Performs unitary test of the library.

Used if all package is being tested and not just codegen.

Parameters:
t - Tester to report test results.

All Packages  Class Hierarchy  This Package  Previous  Next  Index