public BinaryExpression buildDivideExpression() throws CQLException { Expression right = this.resultStack.popExpression(); Expression left = this.resultStack.popExpression(); return filterFactory.divide(left, right); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return filterfactory.divide( (Expression) node.getChildValue(0), (Expression) node.getChildValue(1)); } }
@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.divide( left, right ); } }
public void testTimestampHistogram() throws Exception { // buckets with a size of one day, the function returns an integer from 0 onwards, which // is a zero based bucket number in the bucket sequence FilterFactory ff = dataStore.getFilterFactory(); PropertyName pn = ff.property(aname("last_update")); Date baseDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-06-03 00:00:00"); Expression difference = ff.function("dateDifference", pn, ff.literal(baseDate)); int dayInMs = 1000 * 60 * 60 * 24; Expression expression = ff.function("floor", ff.divide(difference, ff.literal(dayInMs))); FilterCapabilities capabilities = dataStore.getFilterCapabilities(); boolean expectOptimized = capabilities.supports(FilterFunction_floor.class) && capabilities.supports(DateDifferenceFunction.class); List<Object[]> value = genericGroupByTestTest(Query.ALL, Aggregate.COUNT, expectOptimized, expression); assertNotNull(value); assertEquals(5, value.size()); checkValueContains(value, "0", "3"); // 2016-06-03 checkValueContains(value, "2", "1"); // 2016-06-05 checkValueContains(value, "3", "2"); // 2016-06-06 checkValueContains(value, "4", "3"); // 2016-06-07 checkValueContains(value, "12", "3"); // 2016-06-15 }
public void testNumericHistogram() throws Exception { // buckets with a size of 100, the function returns an integer from 0 onwards, which // is a zero based bucket number in the bucket sequence FilterFactory ff = dataStore.getFilterFactory(); PropertyName pn = ff.property(aname("energy_consumption")); Expression expression = ff.function("floor", ff.divide(pn, ff.literal(100))); boolean expectOptimized = dataStore.getFilterCapabilities().supports(FilterFunction_floor.class); List<Object[]> value = genericGroupByTestTest(Query.ALL, Aggregate.COUNT, expectOptimized, expression); assertNotNull(value); assertEquals(value.size(), 3); checkValueContains(value, "0", "10"); checkValueContains(value, "1", "1"); checkValueContains(value, "5", "1"); }
public BinaryExpression buildDivideExpression() throws CQLException { Expression right = this.resultStack.popExpression(); Expression left = this.resultStack.popExpression(); return filterFactory.divide(left, right); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return filterfactory.divide((Expression) node.getChildValue(0), (Expression) node.getChildValue(1)); } }
public FilterBuilder divide(Expression right) { Expression left = expr(); return build( ff.divide( left, right ) ); } /**
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return filterfactory.divide((Expression) node.getChildValue(0), (Expression) node.getChildValue(1)); } }
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; }