@Override public Node getParent(String key) throws RepositoryException { Node p = getPredecessor(key); if (treeManager.isLeaf(p) && !treeManager.isRoot(p)) { return p.getParent(); } else { return p; } }
@Override public Node getParent(String key) throws RepositoryException { Node p = getPredecessor(key); if (treeManager.isLeaf(p) && !treeManager.isRoot(p)) { return p.getParent(); } else { return p; } }
@Override public Node getParent(String key) throws RepositoryException { Node p = getPredecessor(key); if (treeManager.isLeaf(p) && !treeManager.isRoot(p)) { return p.getParent(); } else { return p; } }
private Node getOrCreateParent(String key) throws RepositoryException { Node p = getParent(key); if (treeManager.isRoot(p)) { Node min = getMinimal(); if (min != null) { p = min; renamePath(p, key); } } return p; }
private Node getOrCreateParent(String key) throws RepositoryException { Node p = getParent(key); if (treeManager.isRoot(p)) { Node min = getMinimal(); if (min != null) { p = min; renamePath(p, key); } } return p; }
/** * Rename the path of the node with the minimal key. That is, assuming * <code>node</code> is the node with the minimal key (see * {@link #getMinimal()}), this method renames every segment of the path of * <code>node</code> up to {@link TreeManager#getRoot()} to <code>key</code> * . <em>Note: </em> If <code>node</code> is not the node with the minimal * key, the behavior of this method is not specified. */ protected final void renamePath(Node node, String key) throws RepositoryException { if (!treeManager.isRoot(node)) { Node p = node.getParent(); renamePath(p, key); Session s = node.getSession(); s.move(node.getPath(), p.getPath() + "/" + key); // If orderable, move to first child node if (p.getPrimaryNodeType().hasOrderableChildNodes()) { p.orderBefore(key, p.getNodes().nextNode().getName()); } } }
/** * Rename the path of the node with the minimal key. That is, assuming * <code>node</code> is the node with the minimal key (see * {@link #getMinimal()}), this method renames every segment of the path of * <code>node</code> up to {@link TreeManager#getRoot()} to <code>key</code> * . <em>Note: </em> If <code>node</code> is not the node with the minimal * key, the behavior of this method is not specified. */ protected final void renamePath(Node node, String key) throws RepositoryException { if (!treeManager.isRoot(node)) { Node p = node.getParent(); renamePath(p, key); Session s = node.getSession(); s.move(node.getPath(), p.getPath() + "/" + key); // If orderable, move to first child node if (p.getPrimaryNodeType().hasOrderableChildNodes()) { p.orderBefore(key, p.getNodes().nextNode().getName()); } } }
private Node getOrCreateParent(String key) throws RepositoryException { Node p = getParent(key); if (treeManager.isRoot(p)) { Node min = getMinimal(); if (min != null) { p = min; renamePath(p, key); } } return p; }
/** * Rename the path of the node with the minimal key. That is, assuming * <code>node</code> is the node with the minimal key (see * {@link #getMinimal()}), this method renames every segment of the path of * <code>node</code> up to {@link TreeManager#getRoot()} to <code>key</code> * . <em>Note: </em> If <code>node</code> is not the node with the minimal * key, the behavior of this method is not specified. */ protected final void renamePath(Node node, String key) throws RepositoryException { if (!treeManager.isRoot(node)) { Node p = node.getParent(); renamePath(p, key); Session s = node.getSession(); s.move(node.getPath(), p.getPath() + "/" + key); // If orderable, move to first child node if (p.getPrimaryNodeType().hasOrderableChildNodes()) { p.orderBefore(key, p.getNodes().nextNode().getName()); } } }
private Node getOrCreateParent(String key) throws RepositoryException { Node p = getParent(key); if (treeManager.isRoot(p)) { Node min = getMinimal(); if (min != null) { p = min.getParent(); renamePath(p, key); } } return p; }
private Node getOrCreateParent(String key) throws RepositoryException { Node p = getParent(key); if (treeManager.isRoot(p)) { Node min = getMinimal(); if (min != null) { p = min.getParent(); renamePath(p, key); } } return p; }
private Node getOrCreateParent(String key) throws RepositoryException { Node p = getParent(key); if (treeManager.isRoot(p)) { Node min = getMinimal(); if (min != null) { p = min.getParent(); renamePath(p, key); } } return p; }
public void testEmptyNodeSequence() throws RepositoryException { Comparator<String> order = Rank.<String>comparableComparator(); TreeManager treeManager = new BTreeManager(testNode, 5, 10, order, true); NodeSequence nodes = ItemSequence.createNodeSequence(treeManager, errorHandler); Iterator<Node> nodeIt = nodes.iterator(); assertTrue(nodeIt.hasNext()); assertTrue(treeManager.isRoot(nodeIt.next())); assertFalse(nodeIt.hasNext()); checkTreeProperty(testNode, 5, 10, order); checkOrder(nodes, order); assertEmpty(nodes); }