Statistics
| Revision:

svn-gvsig-desktop / 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 / IFNULLFunction.java @ 44207

History | View | Annotate | Download (1.46 KB)

1 44138 jjdelcerro
package org.gvsig.expressionevaluator.impl.function.programming;
2 43512 jjdelcerro
3
import org.apache.commons.lang3.Range;
4 44138 jjdelcerro
import org.gvsig.expressionevaluator.Codes;
5 43939 jjdelcerro
import org.gvsig.expressionevaluator.Function;
6 43521 jjdelcerro
import org.gvsig.expressionevaluator.Interpreter;
7 43512 jjdelcerro
import org.gvsig.expressionevaluator.spi.AbstractFunction;
8
9 44138 jjdelcerro
10 44038 jjdelcerro
public class IFNULLFunction extends AbstractFunction {
11 43512 jjdelcerro
12 44038 jjdelcerro
    public IFNULLFunction() {
13 44138 jjdelcerro
        super(Function.GROUP_BOOLEAN,
14 44038 jjdelcerro
                "IFNULL",
15 43939 jjdelcerro
                Range.is(3),
16 44038 jjdelcerro
                "The IFNULL() function tests if a specified value is null and returns one of two values, based on whether the value is null was true or false.",
17
                "IFNULL( {{value}}, true, false )",
18
                null,
19
                "Object",
20
                true
21 43939 jjdelcerro
        );
22 43512 jjdelcerro
    }
23
24
    @Override
25 43939 jjdelcerro
    public boolean useArgumentsInsteadObjects() {
26
        return true;
27
    }
28
29
    @Override
30 44138 jjdelcerro
    public boolean allowConstantFolding() {
31
        return false;
32
    }
33
34
    @Override
35 43521 jjdelcerro
    public Object call(Interpreter interpreter, Object[] args) throws Exception {
36 44038 jjdelcerro
        throw new UnsupportedOperationException("Not supported yet.");
37 43939 jjdelcerro
    }
38
39
    @Override
40 44138 jjdelcerro
    public Object call(Interpreter interpreter, Codes args) throws Exception {
41 44038 jjdelcerro
        Object value = getObject(interpreter, args, 0);
42
        if( value == null ) {
43 43939 jjdelcerro
            value = getObject(interpreter, args, 1);
44
        } else {
45
            value = getObject(interpreter, args, 2);
46 43512 jjdelcerro
        }
47 43939 jjdelcerro
        return value;
48 43512 jjdelcerro
    }
49
50
}