@Test public void testTransform() throws Throwable { userRegexPatterns.add("s/\\s/_/g"); groupRegexPatterns.add("s/\\s/_/g"); userNameRegEx.populateReplacementPatterns(userNameBaseProperty, userRegexPatterns); groupNameRegEx.populateReplacementPatterns(groupNameBaseProperty, groupRegexPatterns); assertEquals("test_user", userNameRegEx.transform("test user")); assertEquals("ldap_grp", groupNameRegEx.transform("ldap grp")); }
@Override public String transform (String attrValue) { String result = attrValue; try { if (replacementPattern != null && !replacementPattern.isEmpty()) { for (String matchPattern : replacementPattern.keySet()) { Pattern p = Pattern.compile(matchPattern); Matcher m = p.matcher(result); if (m.find()) { String replacement = replacementPattern.get(matchPattern); if (replacement != null) { result = m.replaceAll(replacement); } } } } } catch (Throwable t) { logger.error("Failed to transform " + attrValue, t.fillInStackTrace()); } return result; }
RegEx extends AbstractMapper { @Override public String transform (String attrValue) { String result = attrValue; try { if (replacementPattern != null && !replacementPattern.isEmpty()) { for (String matchPattern : replacementPattern.keySet()) { Pattern p = Pattern.compile(matchPattern); Matcher m = p.matcher(result); if (m.find()) { String replacement = replacementPattern.get(matchPattern); if (replacement != null) { result = m.replaceAll(replacement); } } } } } catch (Throwable t) { logger.error("Failed to transform " + attrValue, t.fillInStackTrace()); } return result; } }
RegEx extends AbstractMapper { @Override public String transform (String attrValue) { String result = attrValue; try { if (replacementPattern != null && !replacementPattern.isEmpty()) { for (String matchPattern : replacementPattern.keySet()) { Pattern p = Pattern.compile(matchPattern); Matcher m = p.matcher(result); if (m.find()) { String replacement = replacementPattern.get(matchPattern); if (replacement != null) { result = m.replaceAll(replacement); } } } } } catch (Throwable t) { logger.error("Failed to transform " + attrValue, t.fillInStackTrace()); } return result; }  }
RegEx extends AbstractMapper { @Override public String transform (String attrValue) { String result = attrValue; try { if (replacementPattern != null && !replacementPattern.isEmpty()) { for (String matchPattern : replacementPattern.keySet()) { Pattern p = Pattern.compile(matchPattern); Matcher m = p.matcher(result); if (m.find()) { String replacement = replacementPattern.get(matchPattern); if (replacement != null) { result = m.replaceAll(replacement); } } } } } catch (Throwable t) { logger.error("Failed to transform " + attrValue, t.fillInStackTrace()); } return result; }  LinkedHashMap<String, String> getReplacementPattern(); @Override void init(String baseProperty); @Override String transform(String attrValue); }
RegEx extends AbstractMapper { @Override public String transform (String attrValue) { String result = attrValue; try { if (replacementPattern != null && !replacementPattern.isEmpty()) { for (String matchPattern : replacementPattern.keySet()) { Pattern p = Pattern.compile(matchPattern); Matcher m = p.matcher(result); if (m.find()) { String replacement = replacementPattern.get(matchPattern); if (replacement != null) { result = m.replaceAll(replacement); } } } } } catch (Throwable t) { logger.error("Failed to transform " + attrValue, t.fillInStackTrace()); } return result; }  LinkedHashMap<String, String> getReplacementPattern(); @Override void init(String baseProperty); @Override String transform(String attrValue);  }