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 / typeconversion / ToIntegerFunction.java @ 46104
History | View | Annotate | Download (1017 Bytes)
1 | 44139 | jjdelcerro | package org.gvsig.expressionevaluator.impl.function.typeconversion; |
---|---|---|---|
2 | 43512 | jjdelcerro | |
3 | import org.apache.commons.lang3.Range; |
||
4 | 44198 | jjdelcerro | import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TOINTEGER; |
5 | 43521 | jjdelcerro | import org.gvsig.expressionevaluator.Interpreter; |
6 | 43512 | jjdelcerro | import org.gvsig.expressionevaluator.spi.AbstractFunction; |
7 | 44139 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
8 | import org.gvsig.tools.dataTypes.DataTypes; |
||
9 | 44669 | jjdelcerro | import org.gvsig.tools.dataTypes.Coercion; |
10 | 43512 | jjdelcerro | |
11 | 44198 | jjdelcerro | public class ToIntegerFunction extends AbstractFunction { |
12 | 43512 | jjdelcerro | |
13 | 44198 | jjdelcerro | public ToIntegerFunction() {
|
14 | 46104 | omartinez | super(GROUP_CONVERSION, FUNCTION_TOINTEGER, Range.is(1),null,null, null,"Integer",true); |
15 | 43512 | jjdelcerro | } |
16 | |||
17 | @Override
|
||
18 | 44009 | jjdelcerro | public boolean allowConstantFolding() { |
19 | return true; |
||
20 | } |
||
21 | |||
22 | @Override
|
||
23 | 43521 | jjdelcerro | public Object call(Interpreter interpreter, Object[] args) throws Exception { |
24 | 44217 | jjdelcerro | Coercion toInt = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.INT); |
25 | 46104 | omartinez | Object obj = this.getObject(args, 0); |
26 | Object value = toInt.coerce(obj);
|
||
27 | 44139 | jjdelcerro | return value;
|
28 | 43512 | jjdelcerro | } |
29 | |||
30 | } |