Package com.google.refine.expr

Examples of com.google.refine.expr.EvalError


        if (args.length == 1 && args[0] != null) {
            Object o = args[0];
            String s = (o instanceof String) ? (String) o : o.toString();
            return DigestUtils.md5Hex(s);
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string");
    }
View Full Code Here


            Object o1 = args[0];
            if (o1 != null) {
                try {
                    return new JSONTokener(o1.toString()).nextValue();
                } catch (JSONException e) {
                    return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed: " + e.getMessage());
                }
            }
        }
        return null;
    }
View Full Code Here

        if (args.length == 1 && args[0] != null) {
            Object o = args[0];
            String s = (o instanceof String) ? (String) o : o.toString();
            return DigestUtils.shaHex(s);
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string");
    }
View Full Code Here

                } else if ("url".equals(mode)) {
                    try {
                        return URLDecoder.decode(s,"UTF-8");
                    } catch (UnsupportedEncodingException e) {}
                } else {
                    return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " does not recognize mode '" + mode + "'.");
                }
            }
        }
        return null;
    }
View Full Code Here

            if (o1 != null && o2 != null && o3 != null && o2 instanceof String && o3 instanceof String) {
                String str = (o1 instanceof String) ? (String) o1 : o1.toString();
                return StringUtils.replaceChars(str, (String) o2, (String) o3);
            }
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 3 strings");
    }
View Full Code Here

            Object s1 = args[0];
            if (s1 != null && s1 instanceof String) {
                return CharMatcher.WHITESPACE.trimFrom((String) s1);
            }
        }
        return new EvalError("Invalid parameters");
    }
View Full Code Here

            Object s2 = args[1];
            if (s1 != null && s2 != null && s1 instanceof String && s2 instanceof String) {
                return ((String) s1).endsWith((String) s2);
            }
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 2 strings");
    }
View Full Code Here

    public Object call(Properties bindings, Object[] args) {
        if(args.length==1){
            String s = args[0].toString();
            if(s.isEmpty()){
              return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " Cannot urlify empty string");
            }
            s = s.toLowerCase().replaceAll("\\s+", "-").replaceAll("[^-a-zA-Z0-9]", "").replaceAll("\\-\\-+", "-");
            return s;
        }
        return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 1 string");
    }
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.