sb.append(path.getLastSegment().getString(context.getNamespaceRegistry())); } else { sb.append("/");
@Test public void shouldCreateParentReferenceSegmentIfPassedParentReferenceStringRegardlessOfIndex() { segment = factory.createSegment(Path.PARENT); assertThat(segment.getIndex(), is(Path.DEFAULT_INDEX)); assertThat(segment.hasIndex(), is(false)); assertThat(segment.isSelfReference(), is(false)); assertThat(segment.isParentReference(), is(true)); assertThat(segment.getName().getLocalName(), is(Path.PARENT)); assertThat(segment.getName().getNamespaceUri().length(), is(0)); segment = factory.createSegment(Path.PARENT, 1); assertThat(segment.getIndex(), is(Path.DEFAULT_INDEX)); assertThat(segment.hasIndex(), is(false)); assertThat(segment.isSelfReference(), is(false)); assertThat(segment.isParentReference(), is(true)); assertThat(segment.getName().getLocalName(), is(Path.PARENT)); assertThat(segment.getName().getNamespaceUri().length(), is(0)); }
final Path relPath = pathFactory.create(relPathStr); if (relPath == null || relPath.isAbsolute() || (relPath.size() == 1 && relPath.getLastSegment().isSelfReference())) { return new Joinable() { public boolean evaluate( Object locationA, final PathFactory pathFactory = left.getContext().getExecutionContext().getValueFactories().getPathFactory(); final Path relPath = pathFactory.create(relPathStr); if (relPath == null || relPath.isAbsolute() || (relPath.size() == 1 && relPath.getLastSegment().isSelfReference())) { return new Joinable() { public boolean evaluate( Object locationA,
Path.Segment segment = iter.next(); try { if (segment.isSelfReference()) continue; if (segment.isParentReference()) { node = node.getParent(); assert node != null; // since the relative path is well-formed while (redoIter.hasNext()) { Path.Segment redoSegment = redoIter.next(); if (redoSegment.isSelfReference()) continue; if (redoSegment.isParentReference()) { redoNode = redoNode.getParent(); assert redoNode != null; // since the relative path is well-formed
for (Location child : children) { Segment childSegment = child.getPath().getLastSegment(); Name childName = childSegment.getName(); AtomicInteger sns = existingSnsByNodeName.get(childName); if (sns == null) { sns = new AtomicInteger(childSegment.getIndex()); existingSnsByNodeName.put(childName, sns); } else { if (childSegment.getIndex() > sns.get()) { sns.set(childSegment.getIndex()); Name childName = childSegment.getName(); AtomicInteger sns = existingSnsByNodeName.get(childName); if (sns != null) {
Name newChildName = newChildSegment.getName(); int snsIndex = newChildSegment.getIndex(); for (ListIterator<NodeType> iter = siblings.listIterator(oldIndex); iter.hasNext();) { NodeType sibling = iter.next(); if (sibling.getName().getName().equals(newChildName)) { NodeType oldSibling = (NodeType)sibling.clone(); sibling = (NodeType)sibling.withName(pathFactory.createSegment(newChildName, snsIndex++)); if (i < index) { if (existingSegment.getName().equals(newChildName)) { ++snsIndex; if (existingSegment.getName().equals(newChildName)) { NodeType oldSibling = (NodeType)existingSibling.clone(); existingSibling = (NodeType)existingSibling.withName(pathFactory.createSegment(newChildName, ++snsIndex));
Name newChildName = newChildSegment.getName(); int snsIndex = newChildSegment.getIndex(); UUID newChildUuid = newChild.getUuid(); for (ListIterator<NodeType> iter = siblings.listIterator(oldIndex); iter.hasNext();) { NodeType sibling = iter.next(); if (sibling.getName().getName().equals(newChildName)) { sibling = (NodeType)sibling.withName(pathFactory.createSegment(newChildName, snsIndex++)); changes.changed(sibling); if (i < index) { if (existingSegment.getName().equals(newChildName)) { ++snsIndex; if (existingSegment.getName().equals(newChildName)) { existingSibling = (NodeType)existingSibling.withName(pathFactory.createSegment(newChildName, ++snsIndex)); changes.changed(existingSibling);
int snsIndex = 1; for (Node<Payload, PropertyPayload> sns : childrenWithName) { if (sns.getSegment().getIndex() != snsIndex) {
if (child.getName().getName().equals(name)) ++snsIndex; NodeType existingSibling = existingSiblings.next(); Segment existingSegment = existingSibling.getName(); if (existingSegment.getName().equals(name)) { int existingIndex = existingSegment.getIndex(); if (snsIndex == 0) snsIndex = existingIndex; NodeType oldSibling = (NodeType)existingSibling.clone();
PathNode originalNode = original.getNode(childPath); workspace.copyNode(context, originalNode, original, root, childSegment.getName(), true);
original.cloneNode(context, originalNode, workspace, root, originalNode.getName().getName(), null, true, null);
if (child.getName().getName().equals(name)) ++snsIndex; NodeType existingSibling = existingSiblings.next(); Segment existingSegment = existingSibling.getName(); if (existingSegment.getName().equals(name)) { int existingIndex = existingSegment.getIndex(); if (snsIndex == 0) snsIndex = existingIndex; existingSibling = (NodeType)existingSibling.withName(pathFactory.createSegment(name, existingIndex + 1));
if (!this.isLoaded()) return; Path childPath = newChild.getPath(); Name childName = childPath.getLastSegment().getName(); if (this.childrenByName.isEmpty()) { if (childPath.getLastSegment().hasIndex()) { int snsIndex = 1; for (Node<Payload, PropertyPayload> sns : childrenWithName) { if (sns.getSegment().getIndex() != snsIndex) {
Path parentPath = request.under().getPath(); assertThat(parentPath, is(expectedPath.getParent())); assertThat(request.named(), is(expectedPath.getLastSegment().getName()));
Name childName = desiredName != null ? desiredName : original.getName().getName(); UUID uuidForCopy = reuseUuids ? original.getUuid() : UUID.randomUUID();
Path parentPath = propertyRequest.under().getPath(); assertThat(parentPath, is(expectedPath.getParent())); assertThat(propertyRequest.named(), is(expectedPath.getLastSegment().getName()));
nodeName = name("configuration"); } else { nodeName = node.getLocation().getPath().getLastSegment().getName();