]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/RelativeReference.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / RelativeReference.java
index 3629644b94c4fbc50264afd8ff897db1417b201f..3cb855da4c2c27fcf7863e8434178802e7208545 100644 (file)
@@ -1,58 +1,58 @@
-package org.simantics.db.layer0.util;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.databoard.util.URIStringUtils;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.uri.UnescapedChildMapOfResource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-\r
-public class RelativeReference {\r
-    public final Resource base;\r
-    public final String path;\r
-    \r
-    public RelativeReference(Resource base, String path) {\r
-        this.base = base;\r
-        this.path = path;\r
-    }\r
-    \r
-    public Resource resolve(ReadGraph graph) throws DatabaseException {\r
-        return resolve(graph, base, path);\r
-    }\r
-\r
-    public static Resource resolve(ReadGraph graph, \r
-            Resource base, \r
-            String path) throws DatabaseException {\r
-        String[] splitPath = path.split("/");\r
-        for(String name : splitPath) {            \r
-            base = graph.syncRequest(new UnescapedChildMapOfResource(base)).get(\r
-                    URIStringUtils.unescape(name)\r
-                    );\r
-            if(base == null)\r
-                return null;                    \r
-        }\r
-        return base;\r
-    }\r
-    \r
-    public static RelativeReference createReference(ReadGraph graph, Resource baseType, Resource resource) throws DatabaseException {\r
-        ArrayList<String> path = new ArrayList<String>();\r
-        Layer0 L0 = Layer0.getInstance(graph);\r
-        try {\r
-            while(!graph.isInstanceOf(resource, baseType)) {\r
-                path.add((String)graph.getRelatedValue(resource, L0.HasName));\r
-                resource = graph.getSingleObject(resource, L0.PartOf);\r
-            }\r
-        } catch(DatabaseException e) {\r
-            return null;\r
-        }\r
-        StringBuilder b = new StringBuilder();\r
-        for(int i=path.size()-1;i>=0;--i) {\r
-            b.append(URIStringUtils.escape(path.get(i)));\r
-            if(i > 0)\r
-                b.append('/');\r
-        }\r
-        return new RelativeReference(resource, b.toString());\r
-    }\r
-}\r
+package org.simantics.db.layer0.util;
+
+import java.util.ArrayList;
+
+import org.simantics.databoard.util.URIStringUtils;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.uri.UnescapedChildMapOfResource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+
+public class RelativeReference {
+    public final Resource base;
+    public final String path;
+    
+    public RelativeReference(Resource base, String path) {
+        this.base = base;
+        this.path = path;
+    }
+    
+    public Resource resolve(ReadGraph graph) throws DatabaseException {
+        return resolve(graph, base, path);
+    }
+
+    public static Resource resolve(ReadGraph graph, 
+            Resource base, 
+            String path) throws DatabaseException {
+        String[] splitPath = path.split("/");
+        for(String name : splitPath) {            
+            base = graph.syncRequest(new UnescapedChildMapOfResource(base)).get(
+                    URIStringUtils.unescape(name)
+                    );
+            if(base == null)
+                return null;                    
+        }
+        return base;
+    }
+    
+    public static RelativeReference createReference(ReadGraph graph, Resource baseType, Resource resource) throws DatabaseException {
+        ArrayList<String> path = new ArrayList<String>();
+        Layer0 L0 = Layer0.getInstance(graph);
+        try {
+            while(!graph.isInstanceOf(resource, baseType)) {
+                path.add((String)graph.getRelatedValue(resource, L0.HasName));
+                resource = graph.getSingleObject(resource, L0.PartOf);
+            }
+        } catch(DatabaseException e) {
+            return null;
+        }
+        StringBuilder b = new StringBuilder();
+        for(int i=path.size()-1;i>=0;--i) {
+            b.append(URIStringUtils.escape(path.get(i)));
+            if(i > 0)
+                b.append('/');
+        }
+        return new RelativeReference(resource, b.toString());
+    }
+}