/** * The provided arguments are evaulated with respect to the FeatureCollection. * * <p>For an aggregate function (like median) please use the WFS mandated XPath syntax to refer * to featureMember content. * * <p>To refer to all 'X': <code>featureMember/asterisk/X</code> * * @param args DOCUMENT ME! * @throws IllegalArgumentException DOCUMENT ME! */ public void setParameters(List args) { // if we see "featureMembers/*/ATTRIBUTE" change to "ATTRIBUTE" org.opengis.filter.expression.Expression expr = (org.opengis.filter.expression.Expression) args.get(0); expr = (org.opengis.filter.expression.Expression) expr.accept(new CollectionFeatureMemberFilterVisitor(), null); args.set(0, expr); super.setParameters(args); }
/** * Creates a String representation of this Function with the function name and the arguments. * The String created should be good for most subclasses */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append(getName()); sb.append("("); List<org.opengis.filter.expression.Expression> params = getParameters(); if (params != null) { org.opengis.filter.expression.Expression exp; for (Iterator<org.opengis.filter.expression.Expression> it = params.iterator(); it.hasNext(); ) { exp = it.next(); sb.append("["); sb.append(exp); sb.append("]"); if (it.hasNext()) { sb.append(", "); } } } sb.append(")"); return sb.toString(); }
@Override public Object accept(ExpressionVisitor visitor, Object extraData) { if (visitor instanceof FilterAttributeExtractor) { // we explicitly handle the attribute extractor filter return visitor.visit((PropertyName) this, extraData); } // proceed with the normal behavior return super.accept(visitor, extraData); } }
public void testGetName() { FunctionExpressionImpl anonymous = new FunctionExpressionImpl( FunctionExpressionImpl.functionName("testFunction", "text:String")) {}; assertEquals("testFunction", anonymous.getName()); }
public void testGetArgs() { final List expected = Collections.singletonList(new LiteralExpressionImpl(10d)); function.setParameters(expected); List<Expression> actual = function.getParameters(); assertEquals(expected, actual); }
/** * Utility method for subclasses to ask for an argument at a given index * * @param index * @return */ protected org.opengis.filter.expression.Expression getExpression(int index) { org.opengis.filter.expression.Expression exp; exp = getParameters().get(index); return exp; }
public void testGetArgCount() { final List expected = Collections.singletonList(new LiteralExpressionImpl(10d)); function.setParameters(expected); assertEquals(1, function.getFunctionName().getArgumentCount()); }
public synchronized FunctionName getFunctionName() { if( functionName == null ){ functionName = new FunctionNameImpl( getName(), getArgCount() ); } return functionName; }
public synchronized FunctionName getFunctionName() { if (functionName == null) { functionName = new FunctionNameImpl(getName(), functionName.getArgumentCount()); } return functionName; }
@Test public void testHigherCardinality() { FunctionName name = new FunctionNameImpl( "test", parameter("result", Double.class), parameter("double", Double.class, 2, 2)); FunctionExpressionImpl f = new FunctionExpressionImpl(name) {}; assertEquals(2, f.getFunctionName().getArgumentCount()); }
/** * Sets the function parameters. */ public void setParameters(List params) { if(params == null){ throw new NullPointerException("params can't be null"); } final int argCount = getArgCount(); final int paramsSize = params.size(); if(argCount != paramsSize){ throw new IllegalArgumentException("Expected " + argCount + " arguments, got " + paramsSize); } this.params = new ArrayList(params); }
public void testGetParameters() { final List expected = Collections.singletonList(new LiteralExpressionImpl(10d)); // do not try this at home function.params = expected; assertEquals(expected, function.getParameters()); }
@Test public void testVariableArgCount() { FunctionName name = new FunctionNameImpl( "test", parameter("result", Double.class), parameter("double", Double.class, 2, Integer.MAX_VALUE)); FunctionExpressionImpl f = new FunctionExpressionImpl(name) {}; assertEquals(-2, f.getFunctionName().getArgumentCount()); }
/** * Sets the function parameters. */ public void setParameters(List params) { if(params == null){ throw new NullPointerException("Function parameters required"); } final int argCount = getArgCount(); final int paramsSize = params.size(); if(argCount > 0 && argCount != paramsSize){ throw new IllegalArgumentException("Function "+name+" expected " + argCount + " arguments, got " + paramsSize); } this.params = new ArrayList(params); }
/** * The provided arguments are evaulated with respect to the FeatureCollection. * * <p>For an aggregate function (like unique) please use the WFS mandated XPath syntax to refer * to featureMember content. * * <p>To refer to all 'X': <code>featureMember/asterisk/X</code> * * @param args DOCUMENT ME! * @throws IllegalArgumentException DOCUMENT ME! */ public void setParameters(List args) { // if we see "featureMembers/*/ATTRIBUTE" change to "ATTRIBUTE" org.opengis.filter.expression.Expression expr = (org.opengis.filter.expression.Expression) args.get(0); expr = (org.opengis.filter.expression.Expression) expr.accept(new CollectionFeatureMemberFilterVisitor(), null); args.set(0, expr); super.setParameters(args); }
public boolean equals(Object obj) { if( obj == null || !(obj instanceof Function)){ return false; } Function other = (Function) obj; if( ( getName() == null && other.getName() != null ) || (getName() != null && !getName().equalsIgnoreCase( other.getName() ))){ return false; } if( getParameters() == null && other.getClass() != null ){ return false; } return getParameters() != null && getParameters().equals( other.getParameters() ); } }
/** * Utility method for subclasses to ask for an argument at a given index * * @param index * @return */ protected org.opengis.filter.expression.Expression getExpression(int index){ org.opengis.filter.expression.Expression exp; exp = (org.opengis.filter.expression.Expression) getParameters().get(index); return exp; }
@Test public void testSimpleArguments() { FunctionName name = new FunctionNameImpl( "test", parameter("result", Double.class), parameter("one", Double.class), parameter("two", Double.class)); FunctionExpressionImpl f = new FunctionExpressionImpl(name) {}; assertEquals(2, f.getFunctionName().getArgumentCount()); } }
@Override public Object accept(ExpressionVisitor visitor, Object extraData) { if (visitor instanceof FilterAttributeExtractor) { // we explicitly handle the attribute extractor filter return visitor.visit((PropertyName) this, extraData); } // proceed with the normal behavior return super.accept(visitor, extraData); } }
/** * The provided arguments are evaulated with respect to the FeatureCollection. * * <p>For an aggregate function (like sum) please use the WFS mandated XPath syntax to refer to * featureMember content. * * <p>To refer to all 'X': <code>featureMember/asterisk/X</code> * * @param args DOCUMENT ME! * @throws IllegalArgumentException DOCUMENT ME! */ public void setParameters(List args) { // if we see "featureMembers/*/ATTRIBUTE" change to "ATTRIBUTE" org.opengis.filter.expression.Expression expr = (org.opengis.filter.expression.Expression) args.get(0); expr = (org.opengis.filter.expression.Expression) expr.accept(new CollectionFeatureMemberFilterVisitor(), null); args.set(0, expr); super.setParameters(args); }