public BinaryExpression buildAddExpression() throws CQLException { Expression right = this.resultStack.popExpression(); Expression left = this.resultStack.popExpression(); return filterFactory.add(left, right); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return filterfactory.add( (Expression) node.getChildValue(0), (Expression) node.getChildValue(1)); } }
public void testExpression() throws Exception { Add a = filterFac.add(filterFac.property("testAttr"), filterFac.literal(5)); encoder.encode(a); assertEquals("testAttr + 5", output.toString()); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { // <xsd:element ref="se:StringValue"/> Expression string = (Expression) node.getChildValue("StringValue"); // <xsd:element minOccurs="0" ref="se:Position"/> Expression position = (Expression) node.getChildValue("Position"); // function is one based position = filterFactory.subtract(position, filterFactory.literal(1)); // <xsd:element minOccurs="0" ref="se:Length"/> Expression length = (Expression) node.getChildValue("Length"); // our strSubstring function works with begin,end rather than begin,length Expression end = filterFactory.add(position, length); return filterFactory.function("strSubstring", string, position, end); } }
/** Test for {@link DataUtilities#attributeNames(Expression, FeatureType)} */ public void testAttributeExpressionFilterFeatureType() { FilterFactory factory = CommonFactoryFinder.getFilterFactory(null); Expression expression = factory.add(factory.property("geom"), factory.property("gml:name")); String[] names; names = DataUtilities.attributeNames(expression, roadType); assertEquals(2, names.length); List namesList = Arrays.asList(names); assertTrue(namesList.contains("geom")); assertTrue(namesList.contains("name")); }
public void testNumberEscapes() throws Exception { Add a = filterFac.add(filterFac.property("testAttr"), filterFac.literal(5)); PropertyIsEqualTo equal = filterFac.equal(filterFac.property("testAttr"), a, false); StringWriter output = new StringWriter(); FilterToSQL encoder = new FilterToSQL(output); // this test must pass even when the target feature type is not known // encoder.setFeatureType(integerFType); encoder.encode(equal); assertEquals("WHERE testAttr = testAttr + 5", output.toString()); }
/** Test for {@link DataUtilities#attributeNames(Filter, FeatureType)} */ public void testAttributeNamesFilterFeatureType() { FilterFactory factory = CommonFactoryFinder.getFilterFactory(null); Filter filter = factory.equals( factory.property("id"), factory.add(factory.property("geom"), factory.property("gml:name"))); String[] names; names = DataUtilities.attributeNames(filter, roadType); assertEquals(3, names.length); List namesList = Arrays.asList(names); assertTrue(namesList.contains("id")); assertTrue(namesList.contains("geom")); assertTrue(namesList.contains("name")); }
@Test public void testNonLiteralDefaultValue() { // System.out.println(" non-literal default value"); int x = 21; Expression defaultExpr = ff.add(ff.literal(x), ff.literal(x)); Object result = ff.function("env", ff.literal("doesnotexist"), defaultExpr).evaluate(null); int value = ((Number) result).intValue(); assertEquals(x + x, value); }
@Test public void testNumbers() { Add add = ff.add(ff.literal(Byte.valueOf((byte) 1)), ff.property("s")); assertEquals(Short.class, add.accept(visitor, null)); Multiply mul = ff.multiply(ff.property("l"), ff.property("s")); assertEquals(Long.class, mul.accept(visitor, null)); Divide div = ff.divide(ff.literal(new BigInteger("10")), ff.property("s")); assertEquals(BigInteger.class, div.accept(visitor, null)); Subtract sub = ff.subtract(ff.literal(new BigInteger("10")), ff.property("d")); assertEquals(BigDecimal.class, sub.accept(visitor, null)); }
public Object build() { assertCompleted(); stack.pop(); return ff.add( left, right ); } }
public void testConversionFilter() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo f = ff.equals( ff.property(aname("doubleProperty")), ff.add(ff.property(aname("intProperty")), ff.literal("0.1"))); assertEquals(1, featureSource.getCount(new Query(null, f))); }
public FilterBuilder add(Expression right) { Expression left = expr(); return build(ff.add(left, right)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return filterfactory.add((Expression) node.getChildValue(0), (Expression) node.getChildValue(1)); } }
public BinaryExpression buildAddExpression() throws CQLException { Expression right = this.resultStack.popExpression(); Expression left = this.resultStack.popExpression(); return filterFactory.add(left, right); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return filterfactory.add((Expression) node.getChildValue(0), (Expression) node.getChildValue(1)); } }
/** * Update font size. * * @param updatedFontSize the font size to update tp */ public void updateFontSize(int updatedFontSize) { if (font != null) { Expression fontSize = font.getSize(); if (!(String.valueOf(updatedFontSize).equals(fontSize.toString()))) { if (fontSize instanceof LiteralExpressionImpl) { int updatedSize = Double.valueOf(fontSize.toString()).intValue() + updatedFontSize; // Make sure we don't get negative sized fonts! if (updatedSize < 1) { updatedSize = 1; } Expression exp = ff.literal(updatedSize); font.setSize(exp); } else if ((fontSize instanceof FunctionExpression) || (fontSize instanceof MathExpressionImpl) || (fontSize instanceof ConstantExpression) || (fontSize instanceof AttributeExpressionImpl)) { Expression updatedSize = ff.add(fontSize, ff.literal(updatedFontSize)); font.setSize(updatedSize); } } } } }
org.opengis.filter.expression.Expression mathExpression(Class type) throws ExpressionException { try { org.opengis.filter.expression.Expression right = expression(); org.opengis.filter.expression.Expression left = expression(); org.opengis.filter.expression.Expression e; if(Add.class == type){ e = factory.add(left, right); }else if(Subtract.class == type){ e = factory.subtract(left, right); }else if(Divide.class == type){ e = factory.divide(left, right); }else if(Multiply.class == type){ e = factory.multiply(left, right); }else{ throw new IllegalArgumentException(); } return e; } catch (IllegalFilterException ife) { throw new ExpressionException("Exception building MathExpression",getToken(0),ife); } }
private org.opengis.filter.expression.BinaryExpression buildBinaryExpression( int nodeType) throws CQLException { org.opengis.filter.expression.Expression right = resultStack .popExpression(); org.opengis.filter.expression.Expression left = resultStack .popExpression(); org.opengis.filter.expression.BinaryExpression expr = null; switch (nodeType) { case JJTADDNODE: expr = filterFactory.add(left, right); break; case JJTSUBTRACTNODE: expr = filterFactory.subtract(left, right); break; case JJTMULNODE: expr = filterFactory.multiply(left, right); break; case JJTDIVNODE: expr = filterFactory.divide(left, right); break; default: break; } return expr; }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { //<xsd:element ref="se:StringValue"/> Expression string = (Expression) node.getChildValue("StringValue"); //<xsd:element minOccurs="0" ref="se:Position"/> Expression position = (Expression) node.getChildValue("Position"); //function is one based position = filterFactory.subtract(position, filterFactory.literal(1)); //<xsd:element minOccurs="0" ref="se:Length"/> Expression length = (Expression) node.getChildValue("Length"); //our strSubstring function works with begin,end rather than begin,length Expression end = filterFactory.add(position, length); return filterFactory.function("strSubstring", string, position, end); }
FunctionManager.getInstance().createExpression(angleFunction, rotationArgumentList); if (isSourceArrow) { graphic.setRotation(ff.add(ff.literal(DEGREES_180), rotation)); } else { graphic.setRotation(rotation);