From a4c4cd58fa47e6b5a14f204cba36398e68c4d3db Mon Sep 17 00:00:00 2001 From: Matt Greenwood Date: Sat, 27 Jun 2015 21:06:19 -0400 Subject: [PATCH] Removed the need for parsing the path - its no longer the path, its now the function name --- .../internal/function/FunctionFactory.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/function/FunctionFactory.java b/json-path/src/main/java/com/jayway/jsonpath/internal/function/FunctionFactory.java index f224d679..35104ab3 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/function/FunctionFactory.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/function/FunctionFactory.java @@ -45,27 +45,24 @@ public class FunctionFactory { * @see #FUNCTIONS * @see Function * - * @param pathFragment - * The path fragment that is currently being processed which is believed to be the name of a function + * @param name + * The name of the function * * @return * The implementation of a function * * @throws InvalidPathException */ - public static Function newFunction(String pathFragment) throws InvalidPathException { + public static Function newFunction(String name) throws InvalidPathException { Function result = new PassthruFunction(); - if (null != pathFragment) { - String name = pathFragment.replaceAll("['%\\]\\[\\(\\)]", "").trim().toLowerCase(); - if (null != name && FUNCTIONS.containsKey(name) && Function.class.isAssignableFrom(FUNCTIONS.get(name))) { - try { - result = (Function)FUNCTIONS.get(name).newInstance(); - } catch (InstantiationException e) { - throw new InvalidPathException("Function of name: " + name + " cannot be created", e); - } catch (IllegalAccessException e) { - throw new InvalidPathException("Function of name: " + name + " cannot be created", e); - } + if (null != name && FUNCTIONS.containsKey(name) && Function.class.isAssignableFrom(FUNCTIONS.get(name))) { + try { + result = (Function)FUNCTIONS.get(name).newInstance(); + } catch (InstantiationException e) { + throw new InvalidPathException("Function of name: " + name + " cannot be created", e); + } catch (IllegalAccessException e) { + throw new InvalidPathException("Function of name: " + name + " cannot be created", e); } } return result;