Package com.google.refine.expr

Examples of com.google.refine.expr.EvalError


    @Override
    public Object call(Properties bindings, Object[] args) {
        if (args.length == 1 && args[0] != null && args[0] instanceof Number) {
            return Math.log10(((Number) args[0]).doubleValue());
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a number");
    }
View Full Code Here


        if (args.length == 2
                && args[0] != null && args[0] instanceof Number
                && args[1] != null && args[1] instanceof Number) {
            return LeastCommonMultiple.LCM(((Number) args[0]).doubleValue(), ((Number) args[1]).doubleValue());
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two numbers");
    }
View Full Code Here

                                sb.append(separator);
                            }
                            try {
                                sb.append(a.get(i).toString());
                            } catch (JSONException e) {
                                return new EvalError(ControlFunctionRegistry.getFunctionName(this) +
                                    " cannot retrieve element " + i + " of array");
                            }
                        }
                    } else {
                        for (Object o : ExpressionUtils.toObjectList(v)) {
                            if (o != null) {
                                if (sb.length() > 0) {
                                    sb.append(separator);
                                }
                                sb.append(o.toString());
                            }
                        }
                    }
                   
                    return sb.toString();
                }
            }
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects an array and a string");
    }
View Full Code Here

                args[1] != null && args[1] instanceof Number) {
            return Math.min(
                ((Number) args[0]).doubleValue(),
                ((Number) args[1]).doubleValue());
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 2 numbers");
    }
View Full Code Here

    @Override
    public Object call(Properties bindings, Object[] args) {
        if (args.length == 1 && args[0] != null && args[0] instanceof Number) {
            return Math.atan(((Number) args[0]).doubleValue());
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a number");
    }
View Full Code Here

public class Multinomial implements Function {

    @Override
    public Object call(Properties bindings, Object[] args) {
        if (args.length < 1) {
            return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects one or more numbers");
        }
        int sum = 0;
        int product = 1;
        for (int i = 0; i < args.length; i++){
            if (args[i] == null || !(args[i] instanceof Number)) {
                return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects parameter " + (i + 1) + " to be a number");
            }
            int num = ((Number) args[i]).intValue();
            sum += num;
            product *= FactN.factorial(num, 1);
        }
View Full Code Here

    @Override
    public Object call(Properties bindings, Object[] args) {
        if (args.length == 1 && args[0] != null && args[0] instanceof Number) {
            return Math.asin(((Number) args[0]).doubleValue());
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a number");
    }
View Full Code Here

    public Object call(Properties bindings, Object[] args) {
        if (args.length == 2 && args[0] != null && args[0] instanceof Number
                && args[1] != null && args[1] instanceof Number) {
            return Math.floor((((Number) args[0]).doubleValue() / ((Number) args[1]).doubleValue()));
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two numbers");
    }
View Full Code Here

                    Pattern pattern = (Pattern) o2;
                    return pattern.matcher(str).replaceAll((String) o3);
                }
            }
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 3 strings, or 1 string, 1 regex, and 1 string");
    }
View Full Code Here

public class FactN implements Function {

    @Override
    public Object call(Properties bindings, Object[] args) {
        if (args.length != 2) {
            return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two numbers");
        }
        if (args[0] == null || !(args[0] instanceof Number)) {
            return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects the first parameter to be a number");
        }
        if (args[1] == null || !(args[1] instanceof Number)) {
            return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects the second parameter to be a number");
        }

        return FactN.factorial(((Number) args[0]).intValue(), ((Number) args[1]).intValue());

    }
View Full Code Here

TOP

Related Classes of com.google.refine.expr.EvalError

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.