public Add add(Expression expr1, Expression expr2) { return new AddImpl(expr1, expr2); }
protected void setUp() throws Exception { FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); Expression e1 = ff.literal(1); Expression e2 = ff.literal(2); add = new AddImpl(e1, e2); }
public void testIncompleteMathExpression() throws IllegalFilterException { Expression testAttribute1 = new LiteralExpressionImpl(Integer.valueOf(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) { } }
switch (convertType) { case ExpressionType.MATH_ADD: curExprssn = new AddImpl(null, null); break; case ExpressionType.MATH_SUBTRACT:
public Add add(Expression expr1, Expression expr2) { return new AddImpl(expr1,expr2); }
public Add add(Expression expr1, Expression expr2) { return new AddImpl(expr1,expr2); }
public void testExpressionMath() { 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(Integer.valueOf(4)); testExp4 = new LiteralExpressionImpl(Integer.valueOf(4)); testMath2.setExpression1(testExp3); assertTrue(!testMath1.equals(testMath2)); testMath1.setExpression1(testExp4); assertTrue(testMath1.equals(testMath2)); testMath1 = new SubtractImpl(null, null); testMath1.setExpression1(testExp4); testMath1.setExpression1(testExp2); assertTrue(!testMath1.equals(testMath2)); assertTrue(!testMath1.equals("Random Object that happens to be a string")); } catch (IllegalFilterException e) { LOGGER.warning("bad filter: " + e.getMessage()); } }
MathExpressionImpl mathTest = new AddImpl(null, null); mathTest.setExpression1(testAttribute1); mathTest.setExpression2(testAttribute2);
MathExpressionImpl mathTest = new AddImpl(null, null); mathTest.setExpression1(testAttribute1); mathTest.setExpression2(testAttribute2);
/** * Gets the expression. * * @return the expression */ public Expression getExpression() { Expression expression = null; String selectedItem = (String) comboBox.getSelectedItem(); if (selectedItem != null) { if (selectedItem.equals(ADD)) { expression = new AddImpl(null, null); } else if (selectedItem.equals(SUBTRACT)) { expression = new SubtractImpl(null, null); } else if (selectedItem.equals(MULTIPLY)) { expression = new MultiplyImpl(null, null); } else if (selectedItem.equals(DIVIDE)) { expression = new DivideImpl(null, null); } } return expression; } }
/** * Creates a Math Expression of the given type. * * @param expressionType must be a math expression type. * * @return The new Math Expression. * * @throws IllegalFilterException if there were creation problems. */ public MathExpression createMathExpression(short expressionType) throws IllegalFilterException { switch(expressionType) { case ExpressionType.MATH_ADD: return new AddImpl(null,null); case ExpressionType.MATH_SUBTRACT: return new SubtractImpl(null,null); case ExpressionType.MATH_MULTIPLY: return new MultiplyImpl(null,null); case ExpressionType.MATH_DIVIDE: return new DivideImpl(null,null); } throw new IllegalFilterException("Unsupported math expression"); }
/** * Creates a Math Expression of the given type. * * @param expressionType must be a math expression type. * * @return The new Math Expression. * * @throws IllegalFilterException if there were creation problems. */ public MathExpression createMathExpression(short expressionType) throws IllegalFilterException { switch(expressionType) { case ExpressionType.MATH_ADD: return new AddImpl(null,null); case ExpressionType.MATH_SUBTRACT: return new SubtractImpl(null,null); case ExpressionType.MATH_MULTIPLY: return new MultiplyImpl(null,null); case ExpressionType.MATH_DIVIDE: return new DivideImpl(null,null); } throw new IllegalFilterException("Unsupported math expression"); }