X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fquery%2FUriUtils.java;h=6911f782d75e24a902476187fd428f2a7bd2f404;hb=69d8f2b115a832560eca0d56903c8977178b71ab;hp=9c8f7d655f02935f48dde080eaefcb593f40cdeb;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graph/src/org/simantics/graph/query/UriUtils.java b/bundles/org.simantics.graph/src/org/simantics/graph/query/UriUtils.java index 9c8f7d655..6911f782d 100644 --- a/bundles/org.simantics.graph/src/org/simantics/graph/query/UriUtils.java +++ b/bundles/org.simantics.graph/src/org/simantics/graph/query/UriUtils.java @@ -1,30 +1,55 @@ -package org.simantics.graph.query; - - -public class UriUtils { - - public static Path uriToPath(String uri) { - String[] segments; - Path cur; - if(uri.startsWith("http:/")) { - if(uri.length() == 6) - return Paths.Root; - segments = uri.substring(7).split("/"); - cur = Paths.Root; - } - else { - int p = uri.indexOf('/'); - if(p == -1) - return new PathRoot(uri); - else { - segments = uri.substring(p+1).split("/"); - cur = new PathRoot(uri.substring(0, p)); - } - } - - for(String segment : segments) - cur = new PathChild(segment, cur); - return cur; - } - -} +package org.simantics.graph.query; + +import org.simantics.databoard.util.URIStringUtils; + +public class UriUtils { + + public static Path uriToPath(String uri) { + String[] segments; + Path cur; + if(uri.startsWith("http:/")) { + if(uri.length() == 6) + return Paths.Root; + segments = uri.substring(7).split("/"); + cur = Paths.Root; + } + else { + int p = uri.indexOf('/'); + if(p == -1) + return new PathRoot(uri); + else { + segments = uri.substring(p+1).split("/"); + cur = new PathRoot(uri.substring(0, p)); + } + } + + for(String segment : segments) + cur = new PathChild(segment, cur); + return cur; + } + + public static Path uriToPathUnescaped(String uri) { + String[] segments; + Path cur; + if(uri.startsWith("http:/")) { + if(uri.length() == 6) + return Paths.Root; + segments = uri.substring(7).split("/"); + cur = Paths.Root; + } + else { + int p = uri.indexOf('/'); + if(p == -1) + return new PathRoot(URIStringUtils.unescape(uri)); + else { + segments = uri.substring(p+1).split("/"); + cur = new PathRoot(URIStringUtils.unescape(uri.substring(0, p))); + } + } + + for(String segment : segments) + cur = new PathChild(URIStringUtils.unescape(segment), cur); + return cur; + } + +}