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 / string / FormatFunction.java @ 44262

History | View | Annotate | Download (816 Bytes)

1 43512 jjdelcerro
package org.gvsig.expressionevaluator.impl.function.string;
2
3 44139 jjdelcerro
import org.apache.commons.lang3.ArrayUtils;
4 43512 jjdelcerro
import org.apache.commons.lang3.Range;
5 43521 jjdelcerro
import org.gvsig.expressionevaluator.Interpreter;
6 43512 jjdelcerro
import org.gvsig.expressionevaluator.spi.AbstractFunction;
7
8 44139 jjdelcerro
public class FormatFunction extends AbstractFunction {
9 43512 jjdelcerro
10 44139 jjdelcerro
    public FormatFunction() {
11
        super("String", "FORMAT", Range.between(2,Integer.MAX_VALUE));
12 43512 jjdelcerro
    }
13
14
    @Override
15 44009 jjdelcerro
    public boolean allowConstantFolding() {
16
        return true;
17
    }
18
19
    @Override
20 43521 jjdelcerro
    public Object call(Interpreter interpreter, Object[] args) throws Exception {
21 44139 jjdelcerro
        String format = this.getStr(args, 0);
22 44253 jjdelcerro
        Object[] argsformat = ArrayUtils.subarray(args, 1, args.length);
23
        String value = String.format(format, argsformat);
24 44139 jjdelcerro
        return value;
25 43512 jjdelcerro
    }
26
27
}