Source:
private JSFunction createFunction(InputStream mappingConfig, String outputType) throws JSException { BufferedReader configReader = new BufferedReader(new InputStreamReader(mappingConfig, StandardCharsets.UTF_8)); String[] inputRootElementArray = inputRootelement.split(NAMESPACE_DELIMETER); String inputRootElement = inputRootElementArray[inputRootElementArray.length - 1]; inputRootElement = inputRootElement.replace(':', '_').replace('=', '_'). replace(',', '_').replace(HYPHEN, ENCODE_CHAR_HYPHEN); String[] outputRootElementArray = outputRootelement.split(NAMESPACE_DELIMETER); String outputRootElement = outputRootElementArray[outputRootElementArray.length - 1]; String jsFunctionBody; String propertiesPattern = "(DM_PROPERTIES.)([a-zA-Z_$][a-zA-Z_$0-9]*)\\['([a-zA-Z_$][a-zA-Z-_.$0-9]*)'\\]"; Pattern pattern = Pattern.compile(propertiesPattern); Matcher match; String fnName = FUNCTION_NAME_CONST_1 + inputRootElement + FUNCTION_NAME_CONST_2 + outputRootElement + BRACKET_OPEN + BRACKET_CLOSE; if (InputOutputDataType.JSON.toString().equals(outputType)) { fnName = JS_STRINGIFY + BRACKET_OPEN + fnName + BRACKET_CLOSE; } String configLine; StringBuilder configScriptBuilder = new StringBuilder(); try { while ((configLine = configReader.readLine()) != null) { configScriptBuilder.append(configLine); configScriptBuilder.append(NEW_LINE); } } catch (IOException e) { throw new JSException(e.getMessage()); } jsFunctionBody = configScriptBuilder.toString(); match = pattern.matcher(jsFunctionBody); while (match.find()) { propertiesList.add(match.group(2) + "['" + match.group(3) + "']"); } if (fnName != null) { return new JSFunction(fnName, jsFunctionBody); } else { throw new JSException("Could not find mapping JavaScript function."); } }

Target:
private JSFunction createFunction(InputStream mappingConfig, String outputType) throws JSException { BufferedReader configReader = new BufferedReader(new InputStreamReader(mappingConfig, StandardCharsets.UTF_8)); String[] inputRootElementArray = inputRootelement.split(NAMESPACE_DELIMETER); String inputRootElement = inputRootElementArray[inputRootElementArray.length - 1]; inputRootElement = inputRootElement.replaceAll("[:=,]", "_").replace(HYPHEN, ENCODE_CHAR_HYPHEN); String[] outputRootElementArray = outputRootelement.split(NAMESPACE_DELIMETER); String outputRootElement = outputRootElementArray[outputRootElementArray.length - 1]; String jsFunctionBody; String propertiesPattern = "(DM_PROPERTIES.)([a-zA-Z_$][a-zA-Z_$0-9]*)\\['([a-zA-Z_$][a-zA-Z-_.$0-9]*)'\\]"; Pattern pattern = Pattern.compile(propertiesPattern); Matcher match; String fnName = FUNCTION_NAME_CONST_1 + inputRootElement + FUNCTION_NAME_CONST_2 + outputRootElement + BRACKET_OPEN + BRACKET_CLOSE; if (InputOutputDataType.JSON.toString().equals(outputType)) { fnName = JS_STRINGIFY + BRACKET_OPEN + fnName + BRACKET_CLOSE; } String configLine; StringBuilder configScriptBuilder = new StringBuilder(); try { while ((configLine = configReader.readLine()) != null) { configScriptBuilder.append(configLine); configScriptBuilder.append(NEW_LINE); } } catch (IOException e) { throw new JSException(e.getMessage()); } jsFunctionBody = configScriptBuilder.toString(); match = pattern.matcher(jsFunctionBody); while (match.find()) { propertiesList.add(match.group(2) + "['" + match.group(3) + "']"); } if (fnName != null) { return new JSFunction(fnName, jsFunctionBody); } else { throw new JSException("Could not find mapping JavaScript function."); } }