|
Random number function in XPath for BusinessWorks |
|
Facts -
Tibco
|
|
Thursday, 05 November 2009 20:40 |
|
The following java class implements a random number function in XPath for the input mappers of BusinessWorks tasks. Compile this java class and add it to your BusinessWorks project using a Java Custom Function. If you use the prefix "custommath" in the Java Custom Function then you can call this function from XPath with custommath:uniformRandom()
package com.tibco;
public class XpathMathExtension
{
// compute a random number between 0 and one
public static double uniformRandom()
{
return Math.random();
}
// the help information, will be shown in the XPath Formula Builder
public static final String[][] HELP_STRINGS ={
{"uniformRandom", "Returns a uniformly distributed random number between 0 and 1.",
"Example", "uniformRandom()"}
};
}
|