class 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);
        }
    }

}