@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 FunctionNameImpl(FunctionName copy) { super(copy); this.functionName = copy.getFunctionName(); this.ret = copy.getReturn(); this.args = copy.getArguments(); }
public Object evaluate(Object object) { return evaluate(object, functionName.getReturn().getType()); }
public AbstractHSLFunction(String name) { this.functionName = new FunctionNameImpl(name, NAME.getReturn(), NAME.getArguments()); }
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 void testFunctionName() throws Exception { FunctionName fn = FunctionImpl.functionName( "foo", "bar:Integer", "a", "x:String:1,1", "y:MultiPolygon", "z:java.util.Date:1,"); assertEquals("foo", fn.getName()); check(fn.getReturn(), "bar", Integer.class, 1, 1); check(fn.getArguments().get(0), "a", Object.class, 1, 1); check(fn.getArguments().get(1), "x", String.class, 1, 1); check(fn.getArguments().get(2), "y", MultiPolygon.class, 1, 1); check(fn.getArguments().get(3), "z", Date.class, 1, -1); fn = FunctionImpl.functionName("foo", "a", "geom::1,1", "b:Object:,"); check(fn.getArguments().get(0), "geom", Geometry.class, 1, 1); check(fn.getArguments().get(1), "b", Object.class, -1, -1); fn = FunctionImpl.functionName("foo", "value", "geom::,"); check(fn.getArguments().get(0), "geom", Geometry.class, -1, -1); }
@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 FunctionNameImpl( FunctionName copy ) { super( copy ); this.functionName = copy.getFunctionName(); this.ret = copy.getReturn(); this.args = copy.getArguments(); }
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 boolean accept(FunctionName functionName) { if (functionName != null) { // Check return type if (allowedGeometryTypeList.contains(functionName.getReturn().getType())) { return false; } // Check all parameters for (Parameter<?> parameter : functionName.getArguments()) { if (allowedGeometryTypeList.contains(parameter.getType())) { return false; } } // Check to see if function name is on the banned list if (disallowedFunctionNameList.contains(functionName.getName())) { return false; } } return true; } }
/** * 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; }
/** 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); } } }
FunctionName name = f.getFunctionName(); if (name != null) { Parameter<?> result = name.getReturn(); if (result != null) { if (GridCoverage2D.class.isAssignableFrom(result.getType())) {