]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/utils/StatementInfo.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.debug.browser / src / org / simantics / debug / browser / utils / StatementInfo.java
index 606a6048f3dc627d4eff3b2ba3207873a613b7a9..6853803b88ee66619d802b7c721b3cb59daf107c 100644 (file)
@@ -1,72 +1,72 @@
-/*******************************************************************************\r
- * Copyright (c) 2016 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     THTH ry - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.debug.browser.utils;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Statement;\r
-import org.simantics.db.VirtualGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.service.VirtualGraphSupport;\r
-\r
-public class StatementInfo implements Comparable<StatementInfo> {\r
-    public final ResourceInfo subject; // null, if not asserted\r
-    public final ResourceInfo object;\r
-    public final ResourceInfo[] objectTypes;\r
-    public final String graph; // null, if in DB\r
-    \r
-    public StatementInfo(ReadGraph graph, Resource defaultSubject, Statement statement) throws DatabaseException {\r
-        Resource subject = statement.getSubject();\r
-        Resource predicate = statement.getPredicate();\r
-        Resource object = statement.getObject();\r
-        Collection<Resource> objectTypes = graph.getPrincipalTypes(object);\r
-        \r
-        if(subject.equalsResource(defaultSubject))\r
-            this.subject = null;\r
-        else\r
-            this.subject = new ResourceInfo(graph, subject);\r
-        this.object = new ResourceInfo(graph, object);\r
-        if(objectTypes.isEmpty())\r
-            this.objectTypes = null;\r
-        else\r
-            this.objectTypes = mapTypes(graph, objectTypes);\r
-        this.graph = getGraphName(graph, subject, predicate, object);\r
-    }\r
-    \r
-\r
-    private static ResourceInfo[] mapTypes(ReadGraph graph, Collection<Resource> types) throws DatabaseException {\r
-        ResourceInfo[] result = new ResourceInfo[types.size()];\r
-        int i=0;\r
-        for(Resource type : types)\r
-            result[i++] = new ResourceInfo(graph, type);\r
-        Arrays.sort(result);\r
-        return result;\r
-    }\r
-\r
-\r
-    public static String getGraphName(ReadGraph graph, Resource s, Resource p, Resource o) throws DatabaseException {\r
-        VirtualGraphSupport vgs = graph.getService(VirtualGraphSupport.class);\r
-        VirtualGraph vg = vgs.getGraph(graph, s, p, o);\r
-        if(vg != null)\r
-            return vg.toString();\r
-        else\r
-            return null;\r
-    }\r
-\r
-    @Override\r
-    public int compareTo(StatementInfo o) {\r
-        return object.compareTo(o.object);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2016 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     THTH ry - initial API and implementation
+ *******************************************************************************/
+package org.simantics.debug.browser.utils;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.Statement;
+import org.simantics.db.VirtualGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.VirtualGraphSupport;
+
+public class StatementInfo implements Comparable<StatementInfo> {
+    public final ResourceInfo subject; // null, if not asserted
+    public final ResourceInfo object;
+    public final ResourceInfo[] objectTypes;
+    public final String graph; // null, if in DB
+    
+    public StatementInfo(ReadGraph graph, Resource defaultSubject, Statement statement) throws DatabaseException {
+        Resource subject = statement.getSubject();
+        Resource predicate = statement.getPredicate();
+        Resource object = statement.getObject();
+        Collection<Resource> objectTypes = graph.getPrincipalTypes(object);
+        
+        if(subject.equalsResource(defaultSubject))
+            this.subject = null;
+        else
+            this.subject = new ResourceInfo(graph, subject);
+        this.object = new ResourceInfo(graph, object);
+        if(objectTypes.isEmpty())
+            this.objectTypes = null;
+        else
+            this.objectTypes = mapTypes(graph, objectTypes);
+        this.graph = getGraphName(graph, subject, predicate, object);
+    }
+    
+
+    private static ResourceInfo[] mapTypes(ReadGraph graph, Collection<Resource> types) throws DatabaseException {
+        ResourceInfo[] result = new ResourceInfo[types.size()];
+        int i=0;
+        for(Resource type : types)
+            result[i++] = new ResourceInfo(graph, type);
+        Arrays.sort(result);
+        return result;
+    }
+
+
+    public static String getGraphName(ReadGraph graph, Resource s, Resource p, Resource o) throws DatabaseException {
+        VirtualGraphSupport vgs = graph.getService(VirtualGraphSupport.class);
+        VirtualGraph vg = vgs.getGraph(graph, s, p, o);
+        if(vg != null)
+            return vg.toString();
+        else
+            return null;
+    }
+
+    @Override
+    public int compareTo(StatementInfo o) {
+        return object.compareTo(o.object);
+    }
+}