Example usage for org.apache.commons.jxpath.ri Compiler FUNCTION_STRING

List of usage examples for org.apache.commons.jxpath.ri Compiler FUNCTION_STRING

Introduction

In this page you can find the example usage for org.apache.commons.jxpath.ri Compiler FUNCTION_STRING.

Prototype

int FUNCTION_STRING

To view the source code for org.apache.commons.jxpath.ri Compiler FUNCTION_STRING.

Click Source Link

Usage

From source file:com.w20e.socrates.model.ExpressionCompiler.java

/**
 * Only implemented to return true/false functions.
 * /* w ww  .  ja v a 2 s . c om*/
 * @param arg0
 *            numeric argument specifying function
 * @param arg1
 *            dunno
 * @return new XBoolean
 */
@Override
public Object function(final int arg0, final Object[] arg1) {

    //System.out.print(arg0);

    if (arg0 == ExpressionCompiler.TRUE) {
        return new XBoolean(true);
    } else if (arg0 == ExpressionCompiler.RND) {
        Round rnd = new Round();
        Vector<Expression> v = new Vector<Expression>();
        if (arg1 != null) {
            for (Object arg : arg1) {
                v.add((Expression) arg);
            }
        }
        rnd.setOperands(v.toArray(new Expression[v.size()]));
        return rnd;
    } else if (arg0 == ExpressionCompiler.FLOOR) {
        Floor floor = new Floor();
        floor.setLeftOperand((Expression) arg1[0]);
        return floor;
    } else if (arg0 == ExpressionCompiler.NOT) {
        Not not = new Not();
        not.setLeftOperand((Expression) arg1[0]);
        return not;
    } else if (arg0 == ExpressionCompiler.SUM) {
        return this.sum(0, arg1);
    } else if (arg0 == Compiler.FUNCTION_STRING) {
        // only with mandatory parameter is implemented!
        return new XVar(arg1[0].toString()); // throws exception if args1
        // == null
    } else {
        return new XBoolean(false);
    }
}