Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.


A function can be used everywhere within the rule engine (condition expression, nls text). A predefined set of functions already exists.
To register the own function, open the "Preferences" dialog in the XUI Editor ("View" menu) and add a new function. After adding/modifying the functions, the XUI Edtior needs to be closed and started again. Image Removed


Image Added


Implementing an own function means to extend the "com.jaxfront.core.jep.JaxfrontMathCommand" class . In the field "Implementation Class" enter the class name which extends this class. In the field "Category" add an existing category name or a new one. You will see all categories when using the formula engine. Image Removed


Image Added

The class needs to extend the "com.jaxfront.core.jep.JaxfrontMathCommand" class:

Name

Description

run(Stack)

Each function should use it's own run() method for evaluating the function. This includes popping off the parameters from the stack, and pushing the result back on the stack.

...

Hinweis
See class com.jaxfront.demo.api.OwnFunction


This function checks if the passed node values is a future date.

Codeblock
themeEclipse
languagejava
linenumberstrue
public class OwnFunction extends SuperTypeNode {

...


public void run(Stack stack) throws ParseException {

...


// Check if stack is null

...


checkStack(stack);

...


Object param = null;

...


String xPath = null;

...


boolean isFutureDate = false;

...

 
if (curNumberOfParameters == 1) {

...


Type baseType = getCommunicator().getRootType();

...

 
param = stack.pop();

...


if (param == NULL._null) {

...


stack.push(NULL._null);

...


return;

...


} else if (param instanceof Type) {

...


baseType = (Type) param;

...


} else if (param instanceof String) {

...


xPath = (String) param;

...


}

...

 
Type resultType = null;

...


if (xPath != null && xPath.length() > 0) {

...


resultType =

...


TypePathExecuter.getInstance().getTypeForXPath(

...


baseType,

...


xPath.trim(),

...


true,

...


true);

...


} else

...


resultType = baseType;

...

 
if (resultType != null) {

...


if (resultType.isSimple()) {

...


SimpleType simpleType = (SimpleType)resultType;

...


String dateString = simpleType.getValue();

...

 
if (dateString != null) {

...


try {

...


SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

...


Date inputDate = format.parse(dateString);

...


Date currentDate = new Date();

...

 
isFutureDate = inputDate.compareTo(currentDate) > 0;

...


}

...


catch (java.text.ParseException ex) {

...


//do nothing

...


}

...


}

...


} else {

...


throw new ParseException(this.getClass() + " Invalid target type (must be simple)");

...


}

...


}

...


if (isFutureDate) {

...


stack.push(SuperTypeNode.isTrue);

...


}

...


else {

...


stack.push(SuperTypeNode.isFalse);

...


}

...

 
} else {

...


throw new ParseException(this.getClass() + " Invalid parameter type");

...


}

...


}

...


}