Package com.googlecode.aviator.exception

Examples of com.googlecode.aviator.exception.ExpressionRuntimeException


        throw new ExpressionRuntimeException("Could not div " + this.desc(env) + " with " + other.desc(env));
    }


    public AviatorObject mult(AviatorObject other, Map<String, Object> env) {
        throw new ExpressionRuntimeException("Could not mult " + this.desc(env) + " with " + other.desc(env));
    }
View Full Code Here


    }


    public Number numberValue(Map<String, Object> env) {
        if (!(this.getValue(env) instanceof Number)) {
            throw new ExpressionRuntimeException(this.desc(env) + " is not a number value");
        }
        return (Number) this.getValue(env);
    }
View Full Code Here

    }


    public String stringValue(Map<String, Object> env) {
        if (!(this.getValue(env) instanceof String) && !(this.getValue(env) instanceof Character)) {
            throw new ExpressionRuntimeException(this.desc(env) + " is not a string value");
        }
        return String.valueOf(this.getValue(env));
    }
View Full Code Here

    }


    public boolean booleanValue(Map<String, Object> env) {
        if (!(this.getValue(env) instanceof Boolean)) {
            throw new ExpressionRuntimeException(this.desc(env) + " is not a boolean value");
        }
        return (Boolean) this.getValue(env);
    }
View Full Code Here

        Expression compiledExpression = compile(expression, cached);
        if (compiledExpression != null) {
            return compiledExpression.execute(env);
        }
        else {
            throw new ExpressionRuntimeException("Null compiled expression for " + expression);
        }
    }
View Full Code Here


    public static Object getJavaObject(int index, AviatorObject[] args, Map<String, Object> env) {
        final AviatorObject arg = args[index];
        if (!(arg instanceof AviatorJavaType)) {
            throw new ExpressionRuntimeException(arg.desc(env) + " is not a javaType");
        }
        return env.get(((AviatorJavaType) arg).getName());
    }
View Full Code Here


    public static AviatorFunction getFunction(int index, AviatorObject[] args, Map<String, Object> env, int arity) {
        final AviatorObject arg = args[index];
        if (!(arg instanceof AviatorJavaType)) {
            throw new ExpressionRuntimeException(arg.desc(env) + " is not a function");
        }
        // special processing for "-" operator
        String name = ((AviatorJavaType) arg).getName();
        if (name.equals("-")) {
            if (arity == 2) {
View Full Code Here

        }
        else {
            env = new HashMap<String, Object>(env);
            for (String variableName : env.keySet()) {
                if (AviatorEvaluator.FUNC_MAP.containsKey(variableName)) {
                    throw new ExpressionRuntimeException(variableName
                            + " is a function name,please don't use it as variable");
                }
            }
            env.putAll(AviatorEvaluator.FUNC_MAP);
        }
        try {
            return this.runMethod.invoke(null, env);
        }
        catch (InvocationTargetException e) {
            if (e.getCause() != null) {
                throw new ExpressionRuntimeException("Execute expression error", e.getCause());
            }
            else {
                throw new ExpressionRuntimeException("Execute expression error", e);
            }
        }
        catch (Throwable e) {
            throw new ExpressionRuntimeException("Execute expression error", e);
        }
    }
View Full Code Here

            throw new IllegalArgumentException("filter(seq,pred)");
        }
        Object first = args[0].getValue(env);
        AviatorFunction fun = FunctionUtils.getFunction(1, args, env, 1);
        if (fun == null) {
            throw new ExpressionRuntimeException("There is no function named " + ((AviatorJavaType) args[1]).getName());
        }
        if (first == null) {
            throw new NullPointerException("null seq");
        }
        Class<?> clazz = first.getClass();
View Full Code Here

        case GE:
            return args[0].compare(value, env) >= 0 ? AviatorBoolean.TRUE : AviatorBoolean.FALSE;
        case GT:
            return args[0].compare(value, env) > 0 ? AviatorBoolean.TRUE : AviatorBoolean.FALSE;
        default:
            throw new ExpressionRuntimeException(getName() + " is not a relation operator");
        }
    }
View Full Code Here

TOP

Related Classes of com.googlecode.aviator.exception.ExpressionRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.