Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libExpressions / src / main / java / org / gvsig / operators / Sqrt.java @ 23299

History | View | Annotate | Download (1.65 KB)

1
package org.gvsig.operators;
2

    
3
import org.apache.bsf.BSFException;
4
import org.apache.bsf.BSFManager;
5
import org.gvsig.baseclasses.AbstractOperator;
6
import org.gvsig.baseclasses.IOperator;
7
import org.gvsig.expresions.EvalOperatorsTask;
8

    
9
import com.iver.andami.PluginServices;
10

    
11
/**
12
 * @author Vicente Caballero Navarro
13
 */
14
public class Sqrt extends AbstractOperator{
15

    
16
        public String addText(String s) {
17
                return toString()+"("+s+")";
18
        }
19
        public String toString() {
20
                return "sqrt";
21
        }
22
        public void eval(BSFManager interpreter) throws BSFException {
23
//                interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double sqrt(double value){return java.lang.Math.sqrt(value);};");
24
                interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def sqrt(value):\n" +
25
                                "  import java.lang.Math\n" +
26
                                "  return java.lang.Math.sqrt(value)");
27
        }
28
        public boolean isEnable() {
29
                return (getType()==IOperator.NUMBER);
30
        }
31
        public String getDescription() {
32
        return PluginServices.getText(this, "parameter") + ": " +
33
        PluginServices.getText(this, "numeric_value") + "\n" +
34
        PluginServices.getText(this, "returns") + ": " +
35
        PluginServices.getText(this, "numeric_value") + "\n" +
36
        PluginServices.getText(this, "description") + ": " +
37
        "Returns the correctly rounded positive square root of a double value. Special cases:\n" +
38
        "* If the argument is NaN or less than zero, then the result is NaN.\n" +
39
        "* If the argument is positive infinity, then the result is positive infinity.\n" +
40
        "* If the argument is positive zero or negative zero, then the result is the same as the argument.";
41
    }
42
}