@Test public void testParseReplace() throws Exception { assertThrows(ConfigurationErrorException.class, () -> FunctionFactory.parse(new ConfigThingy("REPLACE", "\"abc\" \"abc\""), funcLib, dialogLib, context)); assertThrows(ConfigurationErrorException.class, () -> FunctionFactory.parse(new ConfigThingy("REPLACE", "\"abc\" \"[\" \"def\""), funcLib, dialogLib, context)); }
private static Function parseREPLACE(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { if (conf.count() != 3) throw new ConfigurationErrorException(L.m( "Funktion vom Typ \"REPLACE\" erfordert genau 3 Parameter, nicht %1", conf.count())); Function strFun; Function reFun; Function repFun; Iterator<ConfigThingy> iter = conf.iterator(); strFun = parse(iter.next(), funcLib, dialogLib, context); reFun = parse(iter.next(), funcLib, dialogLib, context); repFun = parse(iter.next(), funcLib, dialogLib, context); String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new ReplaceFunction(strFun, p, repFun); }
FunctionFactory { private static Function parseREPLACE(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { if (conf.count() != 3) throw new ConfigurationErrorException(L.m( "Funktion vom Typ \"REPLACE\" erfordert genau 3 Parameter, nicht %1", conf.count())); Function strFun; Function reFun; Function repFun; Iterator<ConfigThingy> iter = conf.iterator(); strFun = parse(iter.next(), funcLib, dialogLib, context); reFun = parse(iter.next(), funcLib, dialogLib, context); repFun = parse(iter.next(), funcLib, dialogLib, context); String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new ReplaceFunction(strFun, p, repFun); } }
FunctionFactory { private static Function parseREPLACE(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { if (conf.count() != 3) throw new ConfigurationErrorException(L.m( "Funktion vom Typ \"REPLACE\" erfordert genau 3 Parameter, nicht %1", conf.count())); Function strFun; Function reFun; Function repFun; Iterator<ConfigThingy> iter = conf.iterator(); strFun = parse(iter.next(), funcLib, dialogLib, context); reFun = parse(iter.next(), funcLib, dialogLib, context); repFun = parse(iter.next(), funcLib, dialogLib, context); String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new ReplaceFunction(strFun, p, repFun); } private  FunctionFactory(); }
FunctionFactory { private static Function parseREPLACE(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { if (conf.count() != 3) throw new ConfigurationErrorException(L.m( "Funktion vom Typ \"REPLACE\" erfordert genau 3 Parameter, nicht %1", conf.count())); Function strFun; Function reFun; Function repFun; Iterator<ConfigThingy> iter = conf.iterator(); strFun = parse(iter.next(), funcLib, dialogLib, context); reFun = parse(iter.next(), funcLib, dialogLib, context); repFun = parse(iter.next(), funcLib, dialogLib, context); String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new ReplaceFunction(strFun, p, repFun); } private  FunctionFactory(); static Function alwaysTrueFunction(); static Function parseGrandchildren(ConfigThingy conf,
      FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context); static Function parseChildren(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static Function parse(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static FunctionLibrary parseFunctions(ConfigThingy conf,
      DialogLibrary dialogLib, Map<Object, Object> context, FunctionLibrary baselib); static FunctionLibrary parseFunctions(FunctionLibrary funcs,
      ConfigThingy conf, String section, DialogLibrary dialogLib,
      Map<Object, Object> context); static Map<String, Function> parseTrafos(ConfigThingy trafoConf, String nodeName, FunctionLibrary funcLib, DialogLibrary dialogLib,
      Map<Object, Object> context); }
FunctionFactory { private static Function parseREPLACE(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { if (conf.count() != 3) throw new ConfigurationErrorException(L.m( "Funktion vom Typ \"REPLACE\" erfordert genau 3 Parameter, nicht %1", conf.count())); Function strFun; Function reFun; Function repFun; Iterator<ConfigThingy> iter = conf.iterator(); strFun = parse(iter.next(), funcLib, dialogLib, context); reFun = parse(iter.next(), funcLib, dialogLib, context); repFun = parse(iter.next(), funcLib, dialogLib, context); String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new ReplaceFunction(strFun, p, repFun); } private  FunctionFactory(); static Function alwaysTrueFunction(); static Function parseGrandchildren(ConfigThingy conf,
      FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context); static Function parseChildren(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static Function parse(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static FunctionLibrary parseFunctions(ConfigThingy conf,
      DialogLibrary dialogLib, Map<Object, Object> context, FunctionLibrary baselib); static FunctionLibrary parseFunctions(FunctionLibrary funcs,
      ConfigThingy conf, String section, DialogLibrary dialogLib,
      Map<Object, Object> context); static Map<String, Function> parseTrafos(ConfigThingy trafoConf, String nodeName, FunctionLibrary funcLib, DialogLibrary dialogLib,
      Map<Object, Object> context);  }