PrefixLib { public static Pair<String, String> abbrev(PrefixMapI prefixes, String uriStr) { for ( PrefixEntry e : prefixes ) { String uriForPrefix = e.getUri(); if ( uriStr.startsWith(uriForPrefix) ) return Pair.create(e.getPrefix(), uriStr.substring(uriForPrefix.length())); } 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 abbrev_1() { PrefixMapI prefixes = create(); prefixes.add(pref1, "http: Pair<String, String> x = PrefixLib.abbrev(prefixes, "http: assertEquals("pref1", x.getLeft()); assertEquals("xyz", x.getRight()); }
@Test public void abbrev_2() { PrefixMapI prefixes = create(); prefixes.add(pref1, "http: Pair<String, String> x = PrefixLib.abbrev(prefixes, "http: assertNull(x); }