MCPcopy Create free account
hub / github.com/GateNLP/gate-core / shortenUriString

Method shortenUriString

src/main/java/gate/Utils.java:997–1014  ·  view source on GitHub ↗

Compact an URI String using base URI and namespace prefixes. The prefixes map, which maps name prefixes of the form "ns:" or the empty string to URI prefixes is searched for the first URI prefix in the value set that matches the beginning of the uriString. The corresponding name prefix is then used

(String uriString, Map<String, String> prefixes)

Source from the content-addressed store, hash-verified

995 * @return a shortened URI where the URI prefix is replaced with a prefix name or the empty string
996 */
997 public static String shortenUriString(String uriString, Map<String, String> prefixes) {
998 // get the URI prefixes
999 String uriPrefix = "";
1000 String namePrefix = "";
1001 for(Map.Entry<String,String> entry : prefixes.entrySet()) {
1002 String np = entry.getKey();
1003 String uri = entry.getValue();
1004 if(uriString.startsWith(uri)) {
1005 uriPrefix = uri;
1006 namePrefix = np;
1007 break;
1008 }
1009 }
1010 if(uriPrefix.equals("")) {
1011 throw new GateRuntimeException("No prefix found in prefixes map for "+uriString);
1012 }
1013 return namePrefix + uriString.substring(uriPrefix.length());
1014 }
1015
1016 /**
1017 * Get all the annotations from the source annotation set that start and end

Callers

nothing calls this directly

Calls 5

getKeyMethod · 0.65
getValueMethod · 0.65
equalsMethod · 0.65
entrySetMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected