@Test public void testEvaluate() { FilterFunction_listMultiply func = (FilterFunction_listMultiply) ff.function("listMultiply", ff.literal(2), ff.literal("1 2 3")); Object evaluate = func.evaluate(null); assertTrue(evaluate instanceof String); assertEquals("2.0 4.0 6.0", evaluate.toString()); }
@Override public Object evaluate(Object feature) { Number arg0; String arg1; try { Object o = getExpression(0).evaluate(feature); if (o instanceof String) { arg0 = Double.valueOf((String) o); } else { arg0 = (Number) o; } } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #0 - expected type Double (" + e.getMessage() + ")"); } try { final Expression exprArg1 = getExpression(1); if (exprArg1 == null) { return null; } Object data = exprArg1.evaluate(feature); if (data instanceof Number) { return ((Number) data).doubleValue() * arg0.doubleValue(); } arg1 = (String) data; } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #1 - expected type String (" + e.getMessage() + ")"); } if (arg1 == null || arg1.isEmpty()) { return null; } String[] values = WHITE_SPACE_SPLIT.split(arg1); StringBuilder b = new StringBuilder(); for (int i = 0; i < values.length; i++) { if ("".equals(values[i])) { continue; } if (b.length() != 0) { b.append(" "); } b.append(Double.valueOf(values[i]) * arg0.doubleValue()); } return b.toString(); }
FilterFunction_listMultiply extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { Number arg0; String arg1; try { Object o = getExpression(0).evaluate(feature); if (o instanceof String) { arg0 = Double.valueOf((String) o); } else { arg0 = (Number) o; } } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #0 - expected type Double (" + e.getMessage() + ")"); } try { final Expression exprArg1 = getExpression(1); if (exprArg1 == null) { return null; } Object data = exprArg1.evaluate(feature); if (data instanceof Number) { return ((Number) data).doubleValue() * arg0.doubleValue(); } arg1 = (String) data; } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #1 - expected type String (" + e.getMessage() + ")"); } if (arg1 == null || arg1.isEmpty()) { return null; } String[] values = WHITE_SPACE_SPLIT.split(arg1); StringBuilder b = new StringBuilder(); for (int i = 0; i < values.length; i++) { if ("".equals(values[i])) { continue; } if (b.length() != 0) { b.append(" "); } b.append(Double.valueOf(values[i]) * arg0.doubleValue()); } return b.toString(); } }
FilterFunction_listMultiply extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { Number arg0; String arg1; try { Object o = getExpression(0).evaluate(feature); if (o instanceof String) { arg0 = Double.valueOf((String) o); } else { arg0 = (Number) o; } } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #0 - expected type Double (" + e.getMessage() + ")"); } try { final Expression exprArg1 = getExpression(1); if (exprArg1 == null) { return null; } Object data = exprArg1.evaluate(feature); if (data instanceof Number) { return ((Number) data).doubleValue() * arg0.doubleValue(); } arg1 = (String) data; } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #1 - expected type String (" + e.getMessage() + ")"); } if (arg1 == null || arg1.isEmpty()) { return null; } String[] values = WHITE_SPACE_SPLIT.split(arg1); StringBuilder b = new StringBuilder(); for (int i = 0; i < values.length; i++) { if ("".equals(values[i])) { continue; } if (b.length() != 0) { b.append(" "); } b.append(Double.valueOf(values[i]) * arg0.doubleValue()); } return b.toString(); } FilterFunction_listMultiply(); }
FilterFunction_listMultiply extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { Number arg0; String arg1; try { Object o = getExpression(0).evaluate(feature); if (o instanceof String) { arg0 = Double.valueOf((String) o); } else { arg0 = (Number) o; } } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #0 - expected type Double (" + e.getMessage() + ")"); } try { final Expression exprArg1 = getExpression(1); if (exprArg1 == null) { return null; } Object data = exprArg1.evaluate(feature); if (data instanceof Number) { return ((Number) data).doubleValue() * arg0.doubleValue(); } arg1 = (String) data; } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #1 - expected type String (" + e.getMessage() + ")"); } if (arg1 == null || arg1.isEmpty()) { return null; } String[] values = WHITE_SPACE_SPLIT.split(arg1); StringBuilder b = new StringBuilder(); for (int i = 0; i < values.length; i++) { if ("".equals(values[i])) { continue; } if (b.length() != 0) { b.append(" "); } b.append(Double.valueOf(values[i]) * arg0.doubleValue()); } return b.toString(); } FilterFunction_listMultiply(); @Override Object evaluate(Object feature); }
FilterFunction_listMultiply extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { Number arg0; String arg1; try { Object o = getExpression(0).evaluate(feature); if (o instanceof String) { arg0 = Double.valueOf((String) o); } else { arg0 = (Number) o; } } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #0 - expected type Double (" + e.getMessage() + ")"); } try { final Expression exprArg1 = getExpression(1); if (exprArg1 == null) { return null; } Object data = exprArg1.evaluate(feature); if (data instanceof Number) { return ((Number) data).doubleValue() * arg0.doubleValue(); } arg1 = (String) data; } catch (Exception e) { throw new IllegalArgumentException( "Filter Function problem for function listMultiply argument #1 - expected type String (" + e.getMessage() + ")"); } if (arg1 == null || arg1.isEmpty()) { return null; } String[] values = WHITE_SPACE_SPLIT.split(arg1); StringBuilder b = new StringBuilder(); for (int i = 0; i < values.length; i++) { if ("".equals(values[i])) { continue; } if (b.length() != 0) { b.append(" "); } b.append(Double.valueOf(values[i]) * arg0.doubleValue()); } return b.toString(); } FilterFunction_listMultiply(); @Override Object evaluate(Object feature); static FunctionName NAME; }