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 / string / InstrFunction.java @ 44592
History | View | Annotate | Download (781 Bytes)
1 | 43512 | jjdelcerro | package org.gvsig.expressionevaluator.impl.function.string; |
---|---|---|---|
2 | |||
3 | import org.apache.commons.lang3.Range; |
||
4 | 43521 | jjdelcerro | import org.gvsig.expressionevaluator.Interpreter; |
5 | 43512 | jjdelcerro | import org.gvsig.expressionevaluator.spi.AbstractFunction; |
6 | |||
7 | public class InstrFunction extends AbstractFunction { |
||
8 | |||
9 | public InstrFunction() {
|
||
10 | super("String", "INSTR", Range.between(2, 3)); |
||
11 | } |
||
12 | |||
13 | @Override
|
||
14 | 44009 | jjdelcerro | public boolean allowConstantFolding() { |
15 | return true; |
||
16 | } |
||
17 | |||
18 | @Override
|
||
19 | 43521 | jjdelcerro | public Object call(Interpreter interpreter, Object[] args) throws Exception { |
20 | 43512 | jjdelcerro | String str = getStr(args, 0); |
21 | String search = getStr(args, 1); |
||
22 | int start = 0; |
||
23 | if( args.length == 3 ) { |
||
24 | start = getInt(args, 2);
|
||
25 | } |
||
26 | return str.indexOf(search, start);
|
||
27 | } |
||
28 | |||
29 | |||
30 | } |