root / trunk / libraries / libExpressions / src / main / java / org / gvsig / operators / Abs.java @ 23299
History | View | Annotate | Download (1.49 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 |
/**
|
10 |
*
|
11 |
* @author Vicente Caballero Navarro
|
12 |
*/
|
13 |
public class Abs extends AbstractOperator { |
14 |
public String addText(String s) { |
15 |
return toString() + "(" + s + ")"; |
16 |
} |
17 |
|
18 |
public String toString() { |
19 |
return "abs"; |
20 |
} |
21 |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
23 |
interpreter.exec(EvalOperatorsTask.JYTHON, null, -1, -1, |
24 |
"def abs(value):\n" + " import java.lang.Math\n" |
25 |
+ " return java.lang.Math.abs(value)\n");
|
26 |
} |
27 |
|
28 |
public boolean isEnable() { |
29 |
return (getType() == IOperator.NUMBER);
|
30 |
} |
31 |
|
32 |
public double abs(double value) { |
33 |
return java.lang.Math.abs(value);
|
34 |
} |
35 |
|
36 |
public String getDescription() { |
37 |
return "parameter" |
38 |
+ ": "
|
39 |
+ "numeric_value"
|
40 |
+ "\n"
|
41 |
+ "returns"
|
42 |
+ ": "
|
43 |
+ "numeric_value"
|
44 |
+ "\n"
|
45 |
+ "description"
|
46 |
+ ": "
|
47 |
+ "Returns the absolute value of a double value. If the argument is not negative, the argument is returned. "
|
48 |
+ "If the argument is negative, the negation of the argument is returned.\n "
|
49 |
+ "Special cases:\n"
|
50 |
+ "* If the argument is positive zero or negative zero, the result is positive zero.\n"
|
51 |
+ "* If the argument is infinite, the result is positive infinity.\n"
|
52 |
+ "* If the argument is NaN, the result is NaN.";
|
53 |
} |
54 |
} |