1 package org.simantics.graph.query;
3 import org.simantics.databoard.util.URIStringUtils;
5 public class UriUtils {
7 public static Path uriToPath(String uri) {
10 if(uri.startsWith("http:/")) {
13 segments = uri.substring(7).split("/");
17 int p = uri.indexOf('/');
19 return new PathRoot(uri);
21 segments = uri.substring(p+1).split("/");
22 cur = new PathRoot(uri.substring(0, p));
26 for(String segment : segments)
27 cur = new PathChild(segment, cur);
31 public static Path uriToPathUnescaped(String uri) {
34 if(uri.startsWith("http:/")) {
37 segments = uri.substring(7).split("/");
41 int p = uri.indexOf('/');
43 return new PathRoot(URIStringUtils.unescape(uri));
45 segments = uri.substring(p+1).split("/");
46 cur = new PathRoot(URIStringUtils.unescape(uri.substring(0, p)));
50 for(String segment : segments)
51 cur = new PathChild(URIStringUtils.unescape(segment), cur);