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 / programming / ListFunction.java @ 45213

History | View | Annotate | Download (1.47 KB)

1 44138 jjdelcerro
package org.gvsig.expressionevaluator.impl.function.programming;
2 43512 jjdelcerro
3 44138 jjdelcerro
import java.util.ArrayList;
4
import java.util.Arrays;
5 44857 jjdelcerro
import java.util.List;
6 43512 jjdelcerro
import org.apache.commons.lang3.Range;
7 45011 jjdelcerro
import org.gvsig.expressionevaluator.Code;
8
import org.gvsig.expressionevaluator.Codes;
9 44262 jjdelcerro
import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_LIST;
10 45011 jjdelcerro
import org.gvsig.expressionevaluator.Formatter;
11 43939 jjdelcerro
import org.gvsig.expressionevaluator.Function;
12 43521 jjdelcerro
import org.gvsig.expressionevaluator.Interpreter;
13 43512 jjdelcerro
import org.gvsig.expressionevaluator.spi.AbstractFunction;
14
15 44138 jjdelcerro
public class ListFunction extends AbstractFunction {
16
17
    public ListFunction() {
18
        super(Function.GROUP_PROGRAMMING,
19 44262 jjdelcerro
                FUNCTION_LIST,
20 44138 jjdelcerro
                Range.between(0, Integer.MAX_VALUE),
21 44098 jjdelcerro
                null,
22 44138 jjdelcerro
                null,
23
                null,
24
                "List",
25 44098 jjdelcerro
                false
26 43939 jjdelcerro
        );
27 43512 jjdelcerro
    }
28
29
    @Override
30 44138 jjdelcerro
    public boolean allowConstantFolding() {
31
        return false;
32 43939 jjdelcerro
    }
33 44138 jjdelcerro
34 43939 jjdelcerro
    @Override
35 43521 jjdelcerro
    public Object call(Interpreter interpreter, Object[] args) throws Exception {
36 44857 jjdelcerro
        List<Object> list = new ArrayList<>();
37 44138 jjdelcerro
        list.addAll(Arrays.asList(args));
38
        return list;
39 43939 jjdelcerro
    }
40 45011 jjdelcerro
41
    @Override
42
    public String toString(Codes args, Formatter<Code> formatter) {
43
        StringBuilder builder = new StringBuilder();
44 45153 jjdelcerro
        builder.append("ARRAY[ ");
45 45011 jjdelcerro
        builder.append(args.toString(formatter));
46
        builder.append(" ]");
47
        return builder.toString();
48
    }
49
50
51 43512 jjdelcerro
}