PrefixLib { public static String abbreviate(PrefixMapI pmap, String uriStr) { for ( PrefixEntry e : pmap ) { String prefix = e.getPrefix(); String prefixUri = e.getUri(); if ( uriStr.startsWith(prefixUri) ) { String ln = uriStr.substring(prefixUri.length()); if ( strSafeFor(ln, '/') && strSafeFor(ln, '#') && strSafeFor(ln, ':') ) return prefix + ":" + ln; } } return null; }  static String canonicalPrefix(String prefix); static Node canonicalGraphName(Node graphName); static boolean isNodeDefaultGraph(Node graphName); static String abbreviate(PrefixMapI pmap, String uriStr); static Pair<String, String> abbrev(PrefixMapI prefixes, String uriStr); static String expand(PrefixMapI prefixes, String prefixedName); static String expand(PrefixMapI prefixes, String prefix, String localName); boolean isSafeLocalPart(String localName);  }
@Test public void abbreviate_1() { PrefixMapI prefixes = create(); prefixes.add(pref1, "http: String x = PrefixLib.abbreviate(prefixes, "http: assertEquals("pref1:xyz", x); }
@Test public void abbreviate_2() { PrefixMapI prefixes = create(); prefixes.add(pref1, "http: String x = PrefixLib.abbreviate(prefixes, "http: assertNull(x); }