]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ComponentConnectionDescriptor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / variables / ComponentConnectionDescriptor.java
index f12c5f11a1baf66bfcc99ac660fb2f4f8bbf3d68..0222fe50aae6a16fda30e5d6dd3682a98c78fd15 100644 (file)
@@ -1,79 +1,79 @@
-package org.simantics.structural2.variables;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;\r
-import org.simantics.db.common.request.UnaryRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.Variable;\r
-\r
-public class ComponentConnectionDescriptor extends AbstractVariableConnectionPointDescriptor {\r
-       \r
-       public Variable component;\r
-       public Resource cp;\r
-       \r
-       public ComponentConnectionDescriptor(Variable component, Resource cp) {\r
-               this.component = component;\r
-               this.cp = cp;\r
-       }\r
-       @Override\r
-       public int hashCode() {\r
-               return component.hashCode() + 31*cp.hashCode();\r
-       }\r
-       @Override\r
-       public boolean equals(Object object) {\r
-        if (this == object)\r
-            return true;\r
-        else if (object == null)\r
-            return false;\r
-        else if (!(object instanceof ComponentConnectionDescriptor))\r
-            return false;\r
-        ComponentConnectionDescriptor r = (ComponentConnectionDescriptor)object;\r
-        if(!r.cp.equals(cp)) return false;\r
-        if(!r.component.equals(component)) return false;\r
-        return true;\r
-       }\r
-\r
-       static class ComputeVariable extends UnaryRead<ComponentConnectionDescriptor, Variable> {\r
-\r
-               public ComputeVariable(ComponentConnectionDescriptor desc) {\r
-                       super(desc);\r
-               }\r
-\r
-               @Override\r
-               public Variable perform(ReadGraph graph) throws DatabaseException {\r
-                       return parameter.component.getProperty(graph, parameter.cp);\r
-               }\r
-               \r
-       }\r
-       @Override\r
-       public Variable getVariable(ReadGraph graph) throws DatabaseException {\r
-               return graph.syncRequest(new ComputeVariable(this), TransientCacheAsyncListener.<Variable>instance());\r
-       }\r
-       public String getURI(ReadGraph graph) throws DatabaseException {\r
-               return getVariable(graph).getURI(graph);\r
-       }\r
-       @Override\r
-       public Resource getConnectionPointResource(ReadGraph graph) throws DatabaseException {\r
-               return getVariable(graph).getPossiblePredicateResource(graph);\r
-       }\r
-       \r
-       @Override\r
-       public boolean isFlattenedFrom(ReadGraph graph, Variable possiblyStructuralCp) throws DatabaseException {\r
-\r
-               Variable parent = possiblyStructuralCp.getParent(graph);\r
-               \r
-               String descURI = getURI(graph);\r
-               String parentURI = parent.getURI(graph);\r
-               if(descURI.startsWith(parentURI)) {\r
-                       // Children are in substructure\r
-                       if('/' == descURI.charAt(parentURI.length())) return true;\r
-                       // Otherwise require exact match\r
-                       return descURI.endsWith(possiblyStructuralCp.getName(graph));\r
-               } else {\r
-                       return false;\r
-               }\r
-               \r
-       }\r
-       \r
+package org.simantics.structural2.variables;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
+import org.simantics.db.common.request.UnaryRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+
+public class ComponentConnectionDescriptor extends AbstractVariableConnectionPointDescriptor {
+       
+       public Variable component;
+       public Resource cp;
+       
+       public ComponentConnectionDescriptor(Variable component, Resource cp) {
+               this.component = component;
+               this.cp = cp;
+       }
+       @Override
+       public int hashCode() {
+               return component.hashCode() + 31*cp.hashCode();
+       }
+       @Override
+       public boolean equals(Object object) {
+        if (this == object)
+            return true;
+        else if (object == null)
+            return false;
+        else if (!(object instanceof ComponentConnectionDescriptor))
+            return false;
+        ComponentConnectionDescriptor r = (ComponentConnectionDescriptor)object;
+        if(!r.cp.equals(cp)) return false;
+        if(!r.component.equals(component)) return false;
+        return true;
+       }
+
+       static class ComputeVariable extends UnaryRead<ComponentConnectionDescriptor, Variable> {
+
+               public ComputeVariable(ComponentConnectionDescriptor desc) {
+                       super(desc);
+               }
+
+               @Override
+               public Variable perform(ReadGraph graph) throws DatabaseException {
+                       return parameter.component.getProperty(graph, parameter.cp);
+               }
+               
+       }
+       @Override
+       public Variable getVariable(ReadGraph graph) throws DatabaseException {
+               return graph.syncRequest(new ComputeVariable(this), TransientCacheAsyncListener.<Variable>instance());
+       }
+       public String getURI(ReadGraph graph) throws DatabaseException {
+               return getVariable(graph).getURI(graph);
+       }
+       @Override
+       public Resource getConnectionPointResource(ReadGraph graph) throws DatabaseException {
+               return getVariable(graph).getPossiblePredicateResource(graph);
+       }
+       
+       @Override
+       public boolean isFlattenedFrom(ReadGraph graph, Variable possiblyStructuralCp) throws DatabaseException {
+
+               Variable parent = possiblyStructuralCp.getParent(graph);
+               
+               String descURI = getURI(graph);
+               String parentURI = parent.getURI(graph);
+               if(descURI.startsWith(parentURI)) {
+                       // Children are in substructure
+                       if('/' == descURI.charAt(parentURI.length())) return true;
+                       // Otherwise require exact match
+                       return descURI.endsWith(possiblyStructuralCp.getName(graph));
+               } else {
+                       return false;
+               }
+               
+       }
+       
 }
\ No newline at end of file