It is possible for users to define and implement their own functions.
The declaration of such functions is done in an XML file named “userJarsDef.xml”. The format of the file is:
[set the jars variable for your book] <indexFunction jarFilename="c:\dev\uuid\userJar.jar" implClass="EvalSubstring" function="UserPrivateSubstring" /> </jars>
The function implementation is expected to be found in the specified JAR file. The specified class should extend the class:
com.eurekify.matcher.indexer.evalfunctions. EvalFunc
The default-constructor of the class should define the number parameters this function accepts:
numberOfParameters = 1;
The class should implement the method:
public void run(Stack<Object> stack) throws eurekifyEvaluationException
First the stack needs to be checked with the function
checkTheStack(stack);
The parameters passed to the function are retrieved from the stack using:
String strParam = getStringParam(stack);
Or:
int intParam = getIntParam(stack);
The result of the function should be pushed back to the stack using
stack.push(result);
Example implementation class:
import java.util.Stack;
import com.eurekify.matcher.indexer.evalfunctions.*;
public classEvalSubstring extends EvalFunc {
public EvalSubstring() {
numberOfParameters = 3;
}
public void run(Stack<Object> inStack) throws eurekifyEvaluationException
{
// check the stack
checkTheStack(inStack);
// get the parameter from the stack
int to = getIntParam(inStack);
int from = getIntParam(inStack);
String str = getStringParam(inStack);
String result = str.substring(from, to);
// push the result on the stack
inStack.push(result);
}
}
|
Copyright © 2014 CA.
All rights reserved.
|
|