PackageNamer { public static String packageFromUrl(final String uriString) throws MalformedURLException { final java.util.regex.Matcher m = PATTERN.matcher(uriString); if (m.matches()) { List<String> elements = removeEmptyElements(Arrays.asList(m.group(2).split("[\\.|/]")), true); elements.addAll(removeEmptyElements(Arrays.asList(m.group(3).split("[\\.|/]")), false)); elements = packageNameCleanup(elements); return StringUtils.join(elements, "."); } else { throw new MalformedURLException("Illegal IRI for ontology: " + uriString); } }  static String packageFromUrl(final String uriString);  }
@Test public void testGood() throws Exception { assertEquals("com.cambridgesemantics.ontologies._2012._07.extendeddocumentmetadata", PackageNamer.packageFromUrl(extendedDocumentMetadata)); assertEquals("com.lilly.www.ontologies._2015.sdp.lillycore", PackageNamer.packageFromUrl(lillyCore)); assertEquals("com.lilly.www.ontologies._2015.sdp.lillyservices", PackageNamer.packageFromUrl(lillyService)); }