Package org.geotools.filter.expression

Examples of org.geotools.filter.expression.AddImpl


    public Within within(Expression geometry1, Expression geometry2, MatchAction matchAction) {
        return new WithinImpl(geometry1, geometry2, matchAction );
    }
   
    public Add add(Expression expr1, Expression expr2) {
        return new AddImpl(expr1,expr2);
    }
View Full Code Here


            // sub expressions, otherwise just instantiate the main expression
            if (DefaultExpression.isMathExpression(convertType)) {
                expFactory = new ExpressionSAXParser(schema);
                switch(convertType) {
                case ExpressionType.MATH_ADD:
                    curExprssn =  new AddImpl(null,null);
                    break;
                case ExpressionType.MATH_SUBTRACT:
                    curExprssn =  new SubtractImpl(null,null);
                    break;
                case ExpressionType.MATH_MULTIPLY:
View Full Code Here

  }

  public void testIncompleteMathExpression() throws IllegalFilterException {
    Expression testAttribute1 = new LiteralExpressionImpl(new Integer(4));

    MathExpressionImpl mathTest = new AddImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    try {
      mathTest.evaluate(testFeature);
      fail("math expressions should not work if right hand side is not set");
    } catch (IllegalArgumentException ife) {
    }
    mathTest = new AddImpl(null, null);
    mathTest.setExpression2(testAttribute1);
    try {
      mathTest.evaluate(testFeature);
      fail("math expressions should not work if left hand side is not set");
    } catch (IllegalArgumentException ife) {
    }
  }
View Full Code Here

    // Test integer attribute
    Expression testAttribute1 = new LiteralExpressionImpl(new Integer(4));
    Expression testAttribute2 = new LiteralExpressionImpl(new Integer(2));

    // Test addition
    MathExpressionImpl mathTest = new AddImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);
    LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
        + " + " + testAttribute2.evaluate(testFeature) + " = "
        + mathTest.evaluate(testFeature));
    assertEquals(new Integer(6), mathTest.evaluate(testFeature,
        Integer.class));

    // Test subtraction
    mathTest = new SubtractImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);
    LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
        + " - " + testAttribute2.evaluate(testFeature) + " = "
        + mathTest.evaluate(testFeature));
    assertEquals(new Integer(2), mathTest.evaluate(testFeature,
        Integer.class));

    // Test multiplication
    mathTest = new MultiplyImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);
    LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
        + " * " + testAttribute2.evaluate(testFeature) + " = "
        + mathTest.evaluate(testFeature));
    assertEquals(new Integer(8), mathTest.evaluate(testFeature,
        Integer.class));

    // Test division
    mathTest = new DivideImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);
    LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
        + " / " + testAttribute2.evaluate(testFeature) + " = "
        + mathTest.evaluate(testFeature));
    assertEquals(new Double(2), mathTest.evaluate(testFeature));
  }
View Full Code Here

        new Integer(4));
    org.opengis.filter.expression.Expression testAttribute2 = new LiteralExpressionImpl(
        new Integer(2));

    // Test addition
    MathExpressionImpl mathTest = new AddImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);

    assertEquals(new Integer(6), mathTest.evaluate(testObject,
        Integer.class));

    // Test subtraction
    mathTest = new SubtractImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);

    assertEquals(new Integer(2), mathTest.evaluate(testObject,
        Integer.class));

    // Test multiplication
    mathTest = new MultiplyImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);

    assertEquals(new Integer(8), mathTest.evaluate(testObject,
        Integer.class));

    // Test division
    mathTest = new DivideImpl(null, null);
    mathTest.setExpression1(testAttribute1);
    mathTest.setExpression2(testAttribute2);

    assertEquals(new Double(2), mathTest.evaluate(testObject));
  }
View Full Code Here

        try {
      MathExpressionImpl testMath1;
      MathExpressionImpl testMath2;
      testExp1 = new LiteralExpressionImpl(new Double(5));
      testExp2 = new LiteralExpressionImpl(new Double(5));
      testMath1 = new AddImpl(null,null);
      testMath1.setExpression1(testExp1);
      testMath1.setExpression2(testExp2);
      testMath2 =  new AddImpl(null,null);
      testMath2.setExpression1(testExp2);
      testMath2.setExpression2(testExp1);
      assertTrue(testMath1.equals(testMath2));
      testExp3 = new LiteralExpressionImpl(new Integer(4));
      testExp4 = new LiteralExpressionImpl(new Integer(4));
View Full Code Here

TOP

Related Classes of org.geotools.filter.expression.AddImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.