X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fquery%2FUriUtils.java;fp=bundles%2Forg.simantics.graph%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fquery%2FUriUtils.java;h=9c8f7d655f02935f48dde080eaefcb593f40cdeb;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;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 new file mode 100644 index 000000000..9c8f7d655 --- /dev/null +++ b/bundles/org.simantics.graph/src/org/simantics/graph/query/UriUtils.java @@ -0,0 +1,30 @@ +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; + } + +}