Revision 45213 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/function/programming/IIFFunction.java
IIFFunction.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.apache.commons.lang3.Range; |
4 | 4 |
import org.gvsig.expressionevaluator.Codes; |
5 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
5 | 6 |
import org.gvsig.expressionevaluator.Function; |
6 | 7 |
import org.gvsig.expressionevaluator.Interpreter; |
7 | 8 |
import org.gvsig.expressionevaluator.spi.AbstractFunction; |
8 | 9 |
|
9 | 10 |
public class IIFFunction extends AbstractFunction { |
10 |
|
|
11 |
public static final String NAME = "IFF"; |
|
12 | 11 |
|
13 | 12 |
public IIFFunction() { |
14 | 13 |
super(Function.GROUP_BOOLEAN, |
15 |
NAME,
|
|
14 |
ExpressionBuilder.FUNCTION_IIF,
|
|
16 | 15 |
Range.between(2,3), |
17 |
"The IFF() function tests a specified numeric expression and returns one of two values, based on whether the expression tested was true or false.",
|
|
16 |
ExpressionBuilder.FUNCTION_IIF+"() function tests a specified numeric expression and returns one of two values, based on whether the expression tested was true or false.",
|
|
18 | 17 |
"IF {{condition}} THEN\n PASS\nELSE\n PASS;\nEND IF\n", |
19 | 18 |
null, |
20 | 19 |
"Object", |
... | ... | |
24 | 23 |
|
25 | 24 |
@Override |
26 | 25 |
public boolean useArgumentsInsteadObjects() { |
27 |
return true;
|
|
26 |
return false;
|
|
28 | 27 |
} |
29 | 28 |
|
30 | 29 |
@Override |
... | ... | |
34 | 33 |
|
35 | 34 |
@Override |
36 | 35 |
public Object call(Interpreter interpreter, Object[] args) throws Exception { |
37 |
throw new UnsupportedOperationException("Not supported yet."); |
|
36 |
boolean condition = getBoolean(args, 0); |
|
37 |
|
|
38 |
if (condition) { |
|
39 |
return args[1]; |
|
40 |
} else { |
|
41 |
return args[2]; |
|
42 |
} |
|
43 |
|
|
38 | 44 |
} |
39 | 45 |
|
40 | 46 |
@Override |
Also available in: Unified diff