public Object evaluate(Object object) { return evaluate(object, functionName.getReturn().getType()); }
@Override public Object visit(Function f, Object extraData) { FunctionName fn = f.getFunctionName(); if (fn != null && fn.getReturn() != null && fn.getReturn().getType() != Object.class) { return fn.getReturn().getType(); } else if (f instanceof FilterFunction_Convert) { // special case for the convert function, which has the return type as // a parameter return f.getParameters().get(1).evaluate(null, Class.class); } return null; }
@Override public Object visit(Function expression, Object extraData) { FunctionName name = expression.getFunctionName(); if (name != null && name.getReturn() != null) { return name.getReturn().getType(); } else { return Object.class; } }
@Override public Object visit(Function expression, Object extraData) { List old = expression.getParameters(); FunctionName functionName = expression.getFunctionName(); List<Parameter<?>> arguments = null; if (functionName != null) { arguments = functionName.getArguments(); } Expression[] args = new Expression[old.size()]; for (int i = 0; i < old.size(); i++) { Expression exp = (Expression) old.get(i); if (arguments != null && i < arguments.size()) { args[i] = optimize(exp, extraData, arguments.get(i).getType()); } else { args[i] = visit(exp, extraData); } } Function duplicate; if (expression instanceof InternalFunction) { duplicate = ((InternalFunction) expression).duplicate(args); } else { duplicate = getFactory(extraData).function(expression.getName(), args); } return duplicate; }
private Class<?> getFunctionReturnType(Function f) { Class<?> clazz = Object.class; if (f.getFunctionName() != null && f.getFunctionName().getReturn() != null) { clazz = f.getFunctionName().getReturn().getType(); } if (clazz == Object.class) { clazz = null; } return clazz; }
protected Class getFunctionReturnType(Function f) { Class clazz = Object.class; if (f.getFunctionName() != null && f.getFunctionName().getReturn() != null) { clazz = f.getFunctionName().getReturn().getType(); } if (clazz == Object.class) { clazz = null; } return clazz; }
Parameter<?> param = functionParamList.get(paramIndex); Class<?> type = param.getType(); if (type == Object.class) { parameters.add(ff.literal(""));
void check(Parameter p, String name, Class type, int min, int max) { assertEquals(name, p.getName()); assertEquals(type, p.getType()); assertEquals(min, p.getMinOccurs()); assertEquals(max, p.getMaxOccurs()); } }
public Object evaluate(Object object) { return evaluate(object, functionName.getReturn().getType()); }
/** * Gets the function type. * * @param functionName the function name * @return the function type */ @Override public Class<?> getFunctionType(String functionName) { FunctionName function = getFunction(functionName); if (function == null) { return null; } return function.getReturn().getType(); }
@Override public Object visit(Function f, Object extraData) { FunctionName fn = f.getFunctionName(); if (fn != null && fn.getReturn() != null && fn.getReturn().getType() != Object.class) { return fn.getReturn().getType(); } else if (f instanceof FilterFunction_Convert) { // special case for the convert function, which has the return type as // a parameter return f.getParameters().get(1).evaluate(null, Class.class); } return null; }
/** * Sets the data from a parameter. * * @param parameter the new parameter */ public void setParameter(Parameter<?> parameter) { expressionNodeParameter = parameter; if (parameter != null) { setType(parameter.getType()); setName(parameter.getName()); } }
/** * Returns the function return type, or {@link Object} if it could not be determined * * @param f */ Class getFunctionReturnType(Function f) { FunctionName name = f.getFunctionName(); if (name == null || name.getReturn() == null) { return Object.class; } return name.getReturn().getType(); }
@Override public Object visit(Function expression, Object data) { FunctionName name = expression.getFunctionName(); if (name != null && name.getArgumentCount() > 0) { List<Parameter<?>> argumentTypes = name.getArguments(); List<Expression> arguments = expression.getParameters(); for (int i = 0; i < Math.min(arguments.size(), argumentTypes.size()); i++) { Expression ex = arguments.get(i); String propertyName = getPropertyName(ex); Parameter<?> argumentType = argumentTypes.get(i); if (propertyName != null && argumentType != null) { aggregator.addType(propertyName, argumentType.getType()); } } } return super.visit(expression, data); }
Class getFunctionReturnType(Function f) { Class clazz = Object.class; if (f.getFunctionName() != null && f.getFunctionName().getReturn() != null) { clazz = f.getFunctionName().getReturn().getType(); } if (clazz == Object.class) { clazz = null; } return clazz; }
/** Sets the function impl. */ private void setFunctionImpl() { FunctionImpl functionExpression = (FunctionImpl) this.expression; FunctionName functionName = functionExpression.getFunctionName(); TypeManager.getInstance().setDataType(functionName.getReturn().getType()); int maxArgument = Math.abs(functionName.getArgumentCount()); for (int index = 0; index < maxArgument; index++) { ExpressionNode childNode = new ExpressionNode(); Parameter<?> parameter = functionName.getArguments().get(0); childNode.setType(parameter.getType()); childNode.setName(parameter.getName()); if (index < functionExpression.getParameters().size()) { childNode.setExpression(functionExpression.getParameters().get(index)); } this.insert(childNode, this.getChildCount()); } }
/** Sets the function. */ private void setFunction() { Function functionExpression = (Function) this.expression; FunctionName functionName = functionExpression.getFunctionName(); TypeManager.getInstance().setDataType(functionName.getReturn().getType()); int overallIndex = 0; for (Parameter<?> param : functionName.getArguments()) { if (param.getMinOccurs() == 0) { overallIndex = setFunctionOptional(functionExpression, overallIndex, param); } else { overallIndex = setFunctionFixed(functionExpression, overallIndex, param); } } }