@Test public void testRegexHandler() { Assert.assertEquals( BdxlLocator.handleRegex( "!^B-([0-9a-fA-F]+).sid.peppol.eu$!https: "B-eacf0eecc06f3fe1cff9e0e674201d99fc73affaf5aa6eccd3a30565.sid.peppol.eu" ), "https: ); Assert.assertEquals( BdxlLocator.handleRegex( "!^.*$!http: "B-eacf0eecc06f3fe1cff9e0e674201d99fc73affaf5aa6eccd3a30565.iso6523-actorid-upis." + "acc.edelivery.tech.ec.europa.eu" ), "http: ); }
public static String handleRegex(String naptrRegex, String hostname) { String[] regexp = naptrRegex.split("!"); if ("^.*$".equals(regexp[1])) return regexp[2]; Pattern pattern = Pattern.compile(regexp[1]); Matcher matcher = pattern.matcher(hostname); if (matcher.matches()) return matcher.replaceAll(regexp[2].replaceAll("\\\\{2}", "\\$")); return null; }
BdxlLocator extends AbstractLocator { public static String handleRegex(String naptrRegex, String hostname) { String[] regexp = naptrRegex.split("!"); if ("^.*$".equals(regexp[1])) return regexp[2]; Pattern pattern = Pattern.compile(regexp[1]); Matcher matcher = pattern.matcher(hostname); if (matcher.matches()) return matcher.replaceAll(regexp[2].replaceAll("\\\\{2}", "\\$")); return null; } }
BdxlLocator extends AbstractLocator { public static String handleRegex(String naptrRegex, String hostname) { String[] regexp = naptrRegex.split("!"); if ("^.*$".equals(regexp[1])) return regexp[2]; Pattern pattern = Pattern.compile(regexp[1]); Matcher matcher = pattern.matcher(hostname); if (matcher.matches()) return matcher.replaceAll(regexp[2].replaceAll("\\\\{2}", "\\$")); return null; } BdxlLocator(Mode mode); @SuppressWarnings("unused")  BdxlLocator(String hostname);  BdxlLocator(String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm, BaseEncoding encoding); }
BdxlLocator extends AbstractLocator { public static String handleRegex(String naptrRegex, String hostname) { String[] regexp = naptrRegex.split("!"); if ("^.*$".equals(regexp[1])) return regexp[2]; Pattern pattern = Pattern.compile(regexp[1]); Matcher matcher = pattern.matcher(hostname); if (matcher.matches()) return matcher.replaceAll(regexp[2].replaceAll("\\\\{2}", "\\$")); return null; } BdxlLocator(Mode mode); @SuppressWarnings("unused")  BdxlLocator(String hostname);  BdxlLocator(String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm, BaseEncoding encoding); @Override URI lookup(ParticipantIdentifier participantIdentifier); static String handleRegex(String naptrRegex, String hostname); }
BdxlLocator extends AbstractLocator { public static String handleRegex(String naptrRegex, String hostname) { String[] regexp = naptrRegex.split("!"); if ("^.*$".equals(regexp[1])) return regexp[2]; Pattern pattern = Pattern.compile(regexp[1]); Matcher matcher = pattern.matcher(hostname); if (matcher.matches()) return matcher.replaceAll(regexp[2].replaceAll("\\\\{2}", "\\$")); return null; } BdxlLocator(Mode mode); @SuppressWarnings("unused")  BdxlLocator(String hostname);  BdxlLocator(String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm, BaseEncoding encoding); @Override URI lookup(ParticipantIdentifier participantIdentifier); static String handleRegex(String naptrRegex, String hostname);  }