Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extExpressionField / src / com / iver / cit / gvsig / project / documents / table / operators / Pow.java @ 27752

History | View | Annotate | Download (5.55 KB)

1
package com.iver.cit.gvsig.project.documents.table.operators;
2

    
3
import org.apache.bsf.BSFException;
4
import org.apache.bsf.BSFManager;
5

    
6
import com.iver.andami.PluginServices;
7
import com.iver.cit.gvsig.ExpressionFieldExtension;
8
import com.iver.cit.gvsig.project.documents.table.AbstractOperator;
9
import com.iver.cit.gvsig.project.documents.table.IOperator;
10

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

    
16
        public String addText(String s) {
17
                return toString()+"("+s+", )";
18
        }
19

    
20
        public void eval(BSFManager interpreter) throws BSFException {
21
//                interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double pow(double value1,double value2){return java.lang.Math.pow(value1,value2);};");
22
                interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def pow(value1, value2):\n" +
23
                                "  import java.lang.Math\n" +
24
                                "  return java.lang.Math.pow(value1,value2)");
25
        }
26
        public String toString() {
27
                return "pow";
28
        }
29
        public boolean isEnable() {
30
                return (getType()==IOperator.NUMBER);
31
        }
32
        public String getTooltip(){
33
                return PluginServices.getText(this,"operator")+":  "+ toString()+ "(" +PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")\n"+getDescription();
34
        }
35
        public String getDescription() {
36
        return PluginServices.getText(this, "parameter") + "1"+": " +
37
        PluginServices.getText(this, "numeric_value") + "\n"+
38
        PluginServices.getText(this, "parameter") + "2"+": " +
39
        PluginServices.getText(this, "numeric_value") + "\n"+
40
        PluginServices.getText(this, "returns") + ": " +
41
        PluginServices.getText(this, "numeric_value") + "\n" +
42
        PluginServices.getText(this, "description") + ": " +
43
        "Returns the value of the first argument raised to the power of the second argument. Special cases:\n" +
44
        "* If the second argument is positive or negative zero, then the result is 1.0.\n" +
45
        "* If the second argument is 1.0, then the result is the same as the first argument.\n" +
46
        "* If the second argument is NaN, then the result is NaN.\n" +
47
        "* If the first argument is NaN and the second argument is nonzero, then the result is NaN.\n" +
48
        "* If\n" +
49
        "   - the absolute value of the first argument is greater than 1 and the second argument is positive infinity, or\n" +
50
        "   - the absolute value of the first argument is less than 1 and the second argument is negative infinity,\n" +
51
        "then the result is positive infinity.\n" +
52
        "* If\n" +
53
        "   - the absolute value of the first argument is greater than 1 and the second argument is negative infinity, or\n" +
54
        "   - the absolute value of the first argument is less than 1 and the second argument is positive infinity,\n" +
55
        "then the result is positive zero.\n" +
56
        "* If the absolute value of the first argument equals 1 and the second argument is infinite, then the result is NaN.\n" +
57
        "* If\n" +
58
        "   - the first argument is positive zero and the second argument is greater than zero, or\n" +
59
        "   - the first argument is positive infinity and the second argument is less than zero,\n" +
60
        "then the result is positive zero.\n" +
61
        "* If\n" +
62
        "   - the first argument is positive zero and the second argument is less than zero, or\n" +
63
        "   - the first argument is positive infinity and the second argument is greater than zero,\n" +
64
        "then the result is positive infinity.\n" +
65
        "* If\n" +
66
        "   - the first argument is negative zero and the second argument is greater than zero but not a finite odd integer, or\n" +
67
        "   - the first argument is negative infinity and the second argument is less than zero but not a finite odd integer,\n" +
68
        "then the result is positive zero.\n" +
69
        "* If\n" +
70
        "   - the first argument is negative zero and the second argument is a positive finite odd integer, or\n" +
71
        "   - the first argument is negative infinity and the second argument is a negative finite odd integer,\n" +
72
        "then the result is negative zero.\n" +
73
        "* If\n" +
74
        "   - the first argument is negative zero and the second argument is less than zero but not a finite odd integer, or\n" +
75
        "   - the first argument is negative infinity and the second argument is greater than zero but not a finite odd integer,\n" +
76
        "then the result is positive infinity.\n" +
77
        "* If\n" +
78
        "   - the first argument is negative zero and the second argument is a negative finite odd integer, or\n" +
79
        "   - the first argument is negative infinity and the second argument is a positive finite odd integer,\n" +
80
        "then the result is negative infinity.\n" +
81
        "* If the first argument is finite and less than zero\n" +
82
        "   - if the second argument is a finite even integer, the result is equal to the result of raising the absolute value of the first argument to the power of the second argument\n" +
83
        "   - if the second argument is a finite odd integer, the result is equal to the negative of the result of raising the absolute value of the first argument to the power of the second argument\n" +
84
        "   - if the second argument is finite and not an integer, then the result is NaN.\n" +
85
        "* If both arguments are integers, then the result is exactly equal to the mathematical result of raising the first argument to the power of the second argument if that result can in fact be represented exactly as a double value.";
86
    }
87
}