]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph/src/org/simantics/graph/query/PathRoot.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / query / PathRoot.java
diff --git a/bundles/org.simantics.graph/src/org/simantics/graph/query/PathRoot.java b/bundles/org.simantics.graph/src/org/simantics/graph/query/PathRoot.java
new file mode 100644 (file)
index 0000000..31b92c7
--- /dev/null
@@ -0,0 +1,56 @@
+package org.simantics.graph.query;\r
+\r
+public class PathRoot implements Path {\r
+       public final String name;\r
+\r
+       public PathRoot(String name) {\r
+               this.name = name;\r
+       }\r
+       \r
+       @Override\r
+       public int hashCode() {\r
+               final int prime = 31;\r
+               int result = 1;\r
+               result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+               return result;\r
+       }\r
+\r
+\r
+       @Override\r
+       public boolean equals(Object obj) {\r
+               if (this == obj)\r
+                       return true;\r
+               if (obj == null)\r
+                       return false;\r
+               if (getClass() != obj.getClass())\r
+                       return false;\r
+               PathRoot other = (PathRoot) obj;\r
+               if (name == null) {\r
+                       if (other.name != null)\r
+                               return false;\r
+               } else if (!name.equals(other.name))\r
+                       return false;\r
+               return true;\r
+       }\r
+\r
+       @Override\r
+       public String toString() {\r
+               if(name.isEmpty())\r
+                       return "http:/";\r
+               else\r
+                       return name;\r
+       }\r
+       \r
+       @Override\r
+       public void toString(StringBuilder b) {\r
+               if(name.isEmpty())\r
+                       b.append("http:/");\r
+               else\r
+                       b.append(name);\r
+       }\r
+       \r
+       @Override\r
+       public Path child(String childName) {\r
+               return new PathChild(childName, this);\r
+       }       \r
+}\r