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 / obj / WhileFunction.java @ 44098

History | View | Annotate | Download (1.41 KB)

1
package org.gvsig.expressionevaluator.impl.function.obj;
2

    
3
import org.apache.commons.lang3.Range;
4
import org.gvsig.expressionevaluator.Code.Caller.Arguments;
5
import org.gvsig.expressionevaluator.Function;
6
import org.gvsig.expressionevaluator.Interpreter;
7
import org.gvsig.expressionevaluator.spi.AbstractFunction;
8

    
9
public class WhileFunction extends AbstractFunction {
10

    
11
    public WhileFunction() {
12
        super(
13
                Function.GROUP_OTHER, 
14
                "WHILE", 
15
                Range.is(2),
16
                "The while() function evaluate expression while the condition is true.",
17
                "WHILE( condition, expression )",
18
                null,
19
                "Object",
20
                false
21
        );
22
    }
23

    
24
    @Override
25
    public boolean useArgumentsInsteadObjects() {
26
        return true;
27
    }
28

    
29
    @Override
30
    public Object call(Interpreter interpreter, Object[] args) throws Exception {
31
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
32
    }
33
    
34
    @Override
35
    public Object call(Interpreter interpreter, Arguments args) throws Exception {
36
        Object body = null;
37
        boolean condition = getBoolean(interpreter, args, 0);
38
        while( condition ) {
39
            body = getObject(interpreter, args, 1);
40
            condition = getBoolean(interpreter, args, 0);
41
        }
42
        return body;
43
    }
44
    
45
}