use of pcgen.base.formula.library.GenericFunction in project pcgen by PCGen.
the class UserFunction method setFunction.
/**
* Sets the Function for this UserFunction to the function defined by the
* given UserExpression.
*
* @param expression
* The expression to be parsed into a Function.
*/
public void setFunction(String expression) {
if (expression == null) {
throw new IllegalArgumentException("Cannot make formula from null String");
}
origExpression = expression;
try {
SimpleNode root = new FormulaParser(new StringReader(expression)).query();
function = new GenericFunction(getKeyName(), root);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
Aggregations