public FunctionName getFunctionName() { return delegate.getFunctionName(); } }
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; }
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; }
@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; } }
private FunctionName getFunctionName(Function function) { String name = function.getName(); FunctionName functionName = function.getFunctionName(); if (functionName == null && function instanceof FunctionExpressionImpl) { functionName = function.getFunctionName(); } if (functionName == null) { int argc; argc = function.getParameters().size(); functionName = filterFactory.functionName(name, argc); if (!functionName.getName().equals(name)) { LOGGER.warning( function.getClass() + " FunctionName was null, used for etArgumentCount(): " + functionName); } } else { if (!functionName.getName().equals(name)) { LOGGER.warning( function.getClass() + " has name conflict betwee '" + name + "' and '" + functionName.getName() + "'"); } } return functionName; }
List<Parameter<?>> arguments = function.getFunctionName().getArguments(); Parameter<?> lastArgument = arguments.isEmpty() ? null : arguments.get(arguments.size() - 1);
@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; }
@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; }
public void testCountFunctionDescription() throws Exception { // Create instance of function to get hold of the filter capabilities PropertyName exp = ff.property("foo"); Function func = ff.function("Collection_Count", exp); // Expecting one function parameter assertEquals(func.getParameters().size(), 1); // Test return parameter assertEquals(func.getFunctionName().getReturn().toString(), "count:Number"); }
public FunctionName getFunctionName() { return delegate.getFunctionName(); } }
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; }
private FunctionName getFunctionName( Function function ){ String name = function.getName(); FunctionName functionName = function.getFunctionName(); if( functionName == null && function instanceof FunctionExpressionImpl){ functionName = function.getFunctionName(); } if( functionName == null ){ int argc; if( function instanceof FunctionExpression ){ argc = ((FunctionExpression)function).getArgCount(); } else { argc = function.getParameters().size(); } functionName = filterFactory.functionName(name, argc ); } else { if( !functionName.getName().equals(name )){ LOGGER.warning( function.getClass() +" has name conflict betwee '"+name+"' and '"+functionName.getName()+"'"); } } return functionName; } private Map<Name,FunctionDescriptor> loadFunctions() {
/** * 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(); }
Expression e = parameters.get( i ); Object context = function.getFunctionName().getArguments().get(i).getType(); e.accept(this, context);
@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); }
/** * Extract function attribute. * * @param foundList the found list * @param function the function * @return the class */ private Class<?> extractFunctionAttribute(List<String> foundList, Function function) { Class<?> returnType; FunctionName functionName = function.getFunctionName(); List<Parameter<?>> argumentList = functionName.getArguments(); int index = 0; for (Expression parameterExpression : function.getParameters()) { Parameter<?> parameter = argumentList.get(index); extractAttribute(parameter.getType(), parameterExpression, foundList); if (index < argumentList.size()) { index++; } if (index >= argumentList.size()) { index = argumentList.size() - 1; } } returnType = functionName.getReturn().getType(); return returnType; }
@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; }
} else if (expression instanceof Function) { Function functionExpression = (Function) expression; FunctionName function = functionExpression.getFunctionName();
/** 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); } } }
if (tx instanceof Function) { Function f = (Function) tx; FunctionName name = f.getFunctionName(); if (name != null) { Parameter<?> result = name.getReturn();