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 @ 44139
History | View | Annotate | Download (772 Bytes)
1 |
package org.gvsig.expressionevaluator.impl.function.string; |
---|---|
2 |
|
3 |
import org.apache.commons.lang3.ArrayUtils; |
4 |
import org.apache.commons.lang3.Range; |
5 |
import org.gvsig.expressionevaluator.Interpreter; |
6 |
import org.gvsig.expressionevaluator.spi.AbstractFunction; |
7 |
|
8 |
public class FormatFunction extends AbstractFunction { |
9 |
|
10 |
public FormatFunction() {
|
11 |
super("String", "FORMAT", Range.between(2,Integer.MAX_VALUE)); |
12 |
} |
13 |
|
14 |
@Override
|
15 |
public boolean allowConstantFolding() { |
16 |
return true; |
17 |
} |
18 |
|
19 |
@Override
|
20 |
public Object call(Interpreter interpreter, Object[] args) throws Exception { |
21 |
String format = this.getStr(args, 0); |
22 |
ArrayUtils.shift(args, 1);
|
23 |
String value = String.format(format, args); |
24 |
return value;
|
25 |
} |
26 |
|
27 |
} |