KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > xpath > RandomFunction


1 package org.jbpm.bpel.data.xpath;
2
3 import java.util.List JavaDoc;
4
5 import org.jaxen.Context;
6 import org.jaxen.Function;
7 import org.jaxen.FunctionCallException;
8
9 /**
10  * Vendor library function to generate a number value greater than or equal to
11  * <code>0.0</code> and less than <code>1.0</code>.
12  * <p><code><i>number</i> jbpm:random()</code></p>
13  * @author Alejandro Guízar
14  * @version $Revision: 1.2 $ $Date: 2005/05/31 00:49:53 $
15  */

16 public class RandomFunction implements Function {
17
18   /** {@inheritDoc} */
19   public Object JavaDoc call(Context context, List JavaDoc args) throws FunctionCallException {
20     if (!args.isEmpty()) {
21       throw new FunctionCallException("random() takes no parameters");
22     }
23     return evaluate();
24   }
25   
26   public static Number JavaDoc evaluate() {
27     return new Double JavaDoc(Math.random());
28   }
29 }
30
Popular Tags