JessUserFunctions
rete.addUserfunction(new MyFunction?()); rete.addUserpackage(new MyPackage?()); (load-function "myfunction") (load-package "mypackage")
import jess.*;
public class MyUpcase? implements Userfunction
{
// The name method returns the integer representation of the name.
// This function will be called by Jess.
public int name() { return RU.putAtom("my-upcase"); }
public Value call(ValueVector? vv, Context context) throws ReteException?
{
return new Value(vv.get(1).stringValue().toUpperCase(), RU.STRING);
}
}
// Add the 'my-upcase' command to Jess
rete.addUserfunction(new MyUpcase?());
// Exceute some Jess code that calls this function
rete.executeCommand("(printout t (my-upcase foo) crlf)");
[JessInJava | JessAndAgents | NrcPammAgents]