Changeset 98 for java/main/src/main/java/com/framsticks/core/Path.java
- Timestamp:
- 07/08/13 23:04:56 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/core/Path.java
r97 r98 58 58 public Path appendParam(CompositeParam param) { 59 59 assert isResolved(); 60 return appendNode(new Node( param, null));60 return appendNode(new Node(tree, param, null)); 61 61 } 62 62 … … 99 99 public PathBuilder setLast(Object object) { 100 100 Node n = nodes.pollLast(); 101 nodes.add(new Node(n.get Param(), object));101 nodes.add(new Node(n.getTree(), n.getParam(), object)); 102 102 return this; 103 103 } … … 130 130 } 131 131 132 132 133 public PathBuilder resolve(@Nonnull Tree tree, String textual) { 133 134 … … 136 137 this.tree = tree; 137 138 138 nodes.add(tree.getRoot());139 Node current = tree.getRoot();139 Node current = tree.getAssignedRoot(); 140 nodes.add(current); 140 141 141 142 StringBuilder b = new StringBuilder(); 142 143 Iterator<String> i = splitPath(textual); 143 144 while (i.hasNext() && current.getObject() != null) { 144 AccessInterface access = tree.prepareAccess(current.getParam()); 145 if (access == null) { 146 break; 147 } 145 AccessInterface access = TreeOperations.bindAccess(current);// tree.prepareAccess(current.getParam()); 148 146 String e = i.next(); 149 147 Param p = access.getParam(e); … … 155 153 b.append("/").append(e); 156 154 access.select(current.getObject()); 157 current = new Node(c , getKnownChild(tree, access, c));155 current = new Node(current.getTree(), c, getKnownChild(tree, access, c)); 158 156 nodes.add(current); 159 157 } … … 218 216 assert Dispatching.isThreadSafe(); 219 217 return this.textual.equals(textual); 218 } 219 220 public final boolean isTheSameTextually(Path path) { 221 assert Dispatching.isThreadSafe(); 222 return (tree == path.getTree()) && textual.equals(path.getTextual()); 220 223 } 221 224 … … 242 245 return Path.build().resolve(tree, "/").finish(); 243 246 } 244 Object child = getKnownChild(tree, TreeOperations.bindAccess( tree,getUnder()), getTop().getParam());247 Object child = getKnownChild(tree, TreeOperations.bindAccess(getUnder()), getTop().getParam()); 245 248 if (child == null) { 246 249 return this; … … 249 252 } 250 253 251 public boolean matches(Path p) {252 assert Dispatching.isThreadSafe();253 assert tree == p.tree;254 Iterator<Node> a = nodes.iterator();255 Iterator<Node> b = p.nodes.iterator();256 while (a.hasNext() && b.hasNext()) {257 Node an = a.next();258 Node bn = b.next();259 if (an.object != bn.object) {260 return false;261 }262 }263 return a.hasNext() == b.hasNext();264 }265 254 266 255 public String getLastElement() { … … 278 267 } 279 268 280 public voidassureResolved() {269 public Path assureResolved() { 281 270 if (!isResolved()) { 282 271 throw new FramsticksException().msg("path is not resolved").arg("path", this); 283 272 } 273 return this; 284 274 } 285 275 … … 287 277 return Path.build().resolve(tree, textual).finish(); 288 278 } 279 280 public boolean isTheSameObjects(Path path) { 281 if (tree != path.getTree()) { 282 return false; 283 } 284 if (size() != path.size()) { 285 return false; 286 } 287 if (!getTextual().equals(path.getTextual())) { 288 return false; 289 } 290 Iterator<Node> a = nodes.iterator(); 291 Iterator<Node> b = path.getNodes().iterator(); 292 while (a.hasNext()) { 293 assert b.hasNext(); 294 if (a.next() != b.next()) { 295 return false; 296 } 297 } 298 return true; 299 } 300 301 302 // public boolean isEmpty() { 303 // return nodes.isEmpty(); 304 // } 289 305 } 290 306
Note: See TracChangeset
for help on using the changeset viewer.