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 / operator / GtOperator.java @ 43521

History | View | Annotate | Download (1.19 KB)

1 43512 jjdelcerro
package org.gvsig.expressionevaluator.impl.function.operator;
2
3 43521 jjdelcerro
import org.apache.commons.lang3.ObjectUtils;
4
import org.apache.commons.math.util.MathUtils;
5
import org.gvsig.expressionevaluator.Function;
6
import org.gvsig.expressionevaluator.Interpreter;
7
8 43512 jjdelcerro
public class GtOperator extends AbstractBinaryOperator {
9
10
    public GtOperator() {
11 43521 jjdelcerro
        super(Function.GROUP_BOOLEAN,">");
12 43512 jjdelcerro
    }
13
14
    @Override
15 43521 jjdelcerro
    public Object call(Interpreter interpreter, Object op1, Object op2) {
16
        Double accuracy = interpreter.getAccuracy();
17
        if( accuracy!=null ) {
18
            if( op1!=null && op2!= null && (
19
                op1 instanceof Double || op2 instanceof Double ||
20
                op1 instanceof Float || op2 instanceof Float) ) {
21
                boolean value = MathUtils.compareTo(((Number)op1).doubleValue(), ((Number)op2).doubleValue(), accuracy) > 0;
22
                return value;
23
            }
24
        }
25 43512 jjdelcerro
        if( op2 instanceof Comparable && op2 instanceof Comparable ) {
26 43521 jjdelcerro
            boolean value = ObjectUtils.compare((Comparable)op1,(Comparable)op2) > 0;
27 43512 jjdelcerro
            return value;
28
        }
29
        throw new IllegalArgumentException("Types not allowed in '"+name()+"' operand.");
30
    }
31
32
33
}