]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph/src/org/simantics/graph/query/UriUtils.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / query / UriUtils.java
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 (file)
index 0000000..9c8f7d6
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.graph.query;\r
+\r
+\r
+public class UriUtils {\r
+\r
+       public static Path uriToPath(String uri) {\r
+               String[] segments;\r
+               Path cur;\r
+               if(uri.startsWith("http:/")) {\r
+                       if(uri.length() == 6)\r
+                               return Paths.Root;\r
+                       segments = uri.substring(7).split("/");\r
+                       cur = Paths.Root;\r
+               }\r
+               else {\r
+                       int p = uri.indexOf('/');\r
+                       if(p == -1)\r
+                               return new PathRoot(uri);\r
+                       else {\r
+                               segments = uri.substring(p+1).split("/");\r
+                               cur = new PathRoot(uri.substring(0, p));\r
+                       }\r
+               }\r
+\r
+               for(String segment : segments)\r
+                       cur = new PathChild(segment, cur);\r
+               return cur;\r
+       }\r
+       \r
+}\r