]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph/src/org/simantics/graph/query/UriUtils.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / query / UriUtils.java
1 package org.simantics.graph.query;
2
3
4 public class UriUtils {
5
6         public static Path uriToPath(String uri) {
7                 String[] segments;
8                 Path cur;
9                 if(uri.startsWith("http:/")) {
10                         if(uri.length() == 6)
11                                 return Paths.Root;
12                         segments = uri.substring(7).split("/");
13                         cur = Paths.Root;
14                 }
15                 else {
16                         int p = uri.indexOf('/');
17                         if(p == -1)
18                                 return new PathRoot(uri);
19                         else {
20                                 segments = uri.substring(p+1).split("/");
21                                 cur = new PathRoot(uri.substring(0, p));
22                         }
23                 }
24
25                 for(String segment : segments)
26                         cur = new PathChild(segment, cur);
27                 return cur;
28         }
29         
30 }