--- /dev/null
+package org.simantics.graph.query;\r
+\r
+import org.simantics.databoard.util.URIStringUtils;\r
+\r
+\r
+public class PathChild implements Path {\r
+ public final String name;\r
+ public final Path parent;\r
+ \r
+ public PathChild(String name, Path parent) {\r
+ if(parent == null)\r
+ System.out.println("ERR");\r
+ this.name = name;\r
+ this.parent = parent;\r
+ }\r
+ \r
+ @Override\r
+ public int hashCode() {\r
+ return name.hashCode() + (parent == null ? 0 : 31 * parent.hashCode());\r
+ }\r
+ \r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null || getClass() != obj.getClass())\r
+ return false;\r
+ PathChild other = (PathChild) obj;\r
+ return name.equals(other.name) &&\r
+ (parent == null ? other.parent == null : parent.equals(other.parent)); \r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ StringBuilder b = new StringBuilder();\r
+ toString(b);\r
+ return b.toString();\r
+ }\r
+\r
+ public void toString(StringBuilder b) {\r
+ if(parent == null)\r
+ b.append("http:/");\r
+ else\r
+ parent.toString(b);\r
+ b.append("/");\r
+ b.append(URIStringUtils.escape(name));\r
+ }\r
+ \r
+ @Override\r
+ public Path child(String childName) {\r
+ return new PathChild(childName, this);\r
+ }\r
+}\r