@Test public void multiLineReport() throws Exception { String filterDef = "filter = [{from: UID}\n{from: LED}\n{OBVIOUSLYNOTAFILTER {}}]"; String message = null; int lineNumber = -1; Bundle bundle = new ListBundle(); try { FilterHolder filterHolder = Configs.decodeObject(FilterHolder.class, filterDef); filterHolder.filter.filter(bundle); } catch (ConfigException ex) { ConfigOrigin exceptionOrigin = ex.origin(); message = ex.getMessage(); if (exceptionOrigin != null) { lineNumber = exceptionOrigin.lineNumber(); } } catch (JsonProcessingException ex) { JsonLocation jsonLocation = ex.getLocation(); if (jsonLocation != null) { lineNumber = jsonLocation.getLineNr(); message = "Line: " + lineNumber + " "; } message += ex.getOriginalMessage(); if (ex instanceof JsonMappingException) { String pathReference = ((JsonMappingException) ex).getPathReference(); if (pathReference != null) { message += " referenced via: " + pathReference; } } } catch (Exception other) { message = other.toString(); } JSONArray lineColumns = new JSONArray(); JSONArray lineErrors = new JSONArray(); lineErrors.put(lineNumber); log.debug("cols {} lines {} lineNum {} es.mess {}", lineColumns, lineErrors, lineNumber, message); Assert.assertEquals(3, lineNumber); }
@Override public boolean filter(Bundle row) { boolean returnValue = true; if (row != null) { if (ifCondition != null && ifCondition.filter(row)) { if (ifDo != null) { boolean result = ifDo.filter(row); returnValue = returnFilter ? result : returnValue; } } else { if (elseDo != null) { boolean result = elseDo.filter(row); returnValue = returnFilter ? result : returnValue; } } } return returnValue; }
BundleFilterCondition implements BundleFilter { @Override public boolean filter(Bundle row) { boolean returnValue = true; if (row != null) { if (ifCondition != null && ifCondition.filter(row)) { if (ifDo != null) { boolean result = ifDo.filter(row); returnValue = returnFilter ? result : returnValue; } } else { if (elseDo != null) { boolean result = elseDo.filter(row); returnValue = returnFilter ? result : returnValue; } } } return returnValue; } }
BundleFilterCondition implements BundleFilter { @Override public boolean filter(Bundle row) { boolean returnValue = true; if (row != null) { if (ifCondition != null && ifCondition.filter(row)) { if (ifDo != null) { boolean result = ifDo.filter(row); returnValue = returnFilter ? result : returnValue; } } else { if (elseDo != null) { boolean result = elseDo.filter(row); returnValue = returnFilter ? result : returnValue; } } } return returnValue; } BundleFilterCondition();  BundleFilterCondition(@JsonProperty("if")   BundleFilter ifCondition,
                                 @JsonProperty("then") BundleFilter ifDo,
                                 @JsonProperty("else") BundleFilter elseDo); }
BundleFilterCondition implements BundleFilter { @Override public boolean filter(Bundle row) { boolean returnValue = true; if (row != null) { if (ifCondition != null && ifCondition.filter(row)) { if (ifDo != null) { boolean result = ifDo.filter(row); returnValue = returnFilter ? result : returnValue; } } else { if (elseDo != null) { boolean result = elseDo.filter(row); returnValue = returnFilter ? result : returnValue; } } } return returnValue; } BundleFilterCondition();  BundleFilterCondition(@JsonProperty("if")   BundleFilter ifCondition,
                                 @JsonProperty("then") BundleFilter ifDo,
                                 @JsonProperty("else") BundleFilter elseDo); @Override boolean filter(Bundle row); }
BundleFilterCondition implements BundleFilter { @Override public boolean filter(Bundle row) { boolean returnValue = true; if (row != null) { if (ifCondition != null && ifCondition.filter(row)) { if (ifDo != null) { boolean result = ifDo.filter(row); returnValue = returnFilter ? result : returnValue; } } else { if (elseDo != null) { boolean result = elseDo.filter(row); returnValue = returnFilter ? result : returnValue; } } } return returnValue; } BundleFilterCondition();  BundleFilterCondition(@JsonProperty("if")   BundleFilter ifCondition,
                                 @JsonProperty("then") BundleFilter ifDo,
                                 @JsonProperty("else") BundleFilter elseDo); @Override boolean filter(Bundle row);  }