|
|
@ -45,27 +45,24 @@ public class FunctionFactory { |
|
|
|
* @see #FUNCTIONS |
|
|
|
* @see #FUNCTIONS |
|
|
|
* @see Function |
|
|
|
* @see Function |
|
|
|
* |
|
|
|
* |
|
|
|
* @param pathFragment |
|
|
|
* @param name |
|
|
|
* The path fragment that is currently being processed which is believed to be the name of a function |
|
|
|
* The name of the function |
|
|
|
* |
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
* The implementation of a function |
|
|
|
* The implementation of a function |
|
|
|
* |
|
|
|
* |
|
|
|
* @throws InvalidPathException |
|
|
|
* @throws InvalidPathException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static Function newFunction(String pathFragment) throws InvalidPathException { |
|
|
|
public static Function newFunction(String name) throws InvalidPathException { |
|
|
|
Function result = new PassthruFunction(); |
|
|
|
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))) { |
|
|
|
if (null != name && FUNCTIONS.containsKey(name) && Function.class.isAssignableFrom(FUNCTIONS.get(name))) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
result = (Function)FUNCTIONS.get(name).newInstance(); |
|
|
|
result = (Function)FUNCTIONS.get(name).newInstance(); |
|
|
|
} catch (InstantiationException e) { |
|
|
|
} catch (InstantiationException e) { |
|
|
|
throw new InvalidPathException("Function of name: " + name + " cannot be created", e); |
|
|
|
throw new InvalidPathException("Function of name: " + name + " cannot be created", e); |
|
|
|
} catch (IllegalAccessException e) { |
|
|
|
} catch (IllegalAccessException e) { |
|
|
|
throw new InvalidPathException("Function of name: " + name + " cannot be created", e); |
|
|
|
throw new InvalidPathException("Function of name: " + name + " cannot be created", e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|