public boolean include(Node node) { try { return treeManager.isLeaf(node); } catch (RepositoryException e) { return false; } } };
public boolean include(Node node) { try { return treeManager.isLeaf(node); } catch (RepositoryException e) { return false; } } };
public boolean include(Node node) { try { return treeManager.isLeaf(node); } catch (RepositoryException e) { return false; } } };
/** * Returns the node amongst the child nodes of <code>node</code> whose key * is minimal wrt. {@link TreeManager#getOrder()}. Returns <code>null</code> * id either <code>node</code> has no child nodes or <code>node</code> is a * leaf (see {@link TreeManager#isLeaf(Node)}). */ protected final Node getMinimal(Node node) throws RepositoryException { if (!node.hasNodes() || treeManager.isLeaf(node)) { return null; } // Search for minimal key in the nodes children // todo performance: for ordered nodes use binary search NodeIterator childNodes = node.getNodes(); Node p = childNodes.nextNode(); String minKey = p.getName(); while (childNodes.hasNext()) { Node n = childNodes.nextNode(); if (order.compare(n.getName(), minKey) < 0) { p = n; minKey = p.getName(); } } return p; }
/** * Returns the node amongst the child nodes of <code>node</code> whose key * is minimal wrt. {@link TreeManager#getOrder()}. Returns <code>null</code> * id either <code>node</code> has no child nodes or <code>node</code> is a * leaf (see {@link TreeManager#isLeaf(Node)}). */ protected final Node getMinimal(Node node) throws RepositoryException { if (!node.hasNodes() || treeManager.isLeaf(node)) { return null; } // Search for minimal key in the nodes children // todo performance: for ordered nodes use binary search NodeIterator childNodes = node.getNodes(); Node p = childNodes.nextNode(); String minKey = p.getName(); while (childNodes.hasNext()) { Node n = childNodes.nextNode(); if (order.compare(n.getName(), minKey) < 0) { p = n; minKey = p.getName(); } } return p; }
/** * Returns the node amongst the child nodes of <code>node</code> whose key * is minimal wrt. {@link TreeManager#getOrder()}. Returns <code>null</code> * id either <code>node</code> has no child nodes or <code>node</code> is a * leaf (see {@link TreeManager#isLeaf(Node)}). */ protected final Node getMinimal(Node node) throws RepositoryException { if (!node.hasNodes() || treeManager.isLeaf(node)) { return null; } // Search for minimal key in the nodes children // todo performance: for ordered nodes use binary search NodeIterator childNodes = node.getNodes(); Node p = childNodes.nextNode(); String minKey = p.getName(); while (childNodes.hasNext()) { Node n = childNodes.nextNode(); if (order.compare(n.getName(), minKey) < 0) { p = n; minKey = p.getName(); } } return p; }
if (!node.hasNodes() || treeManager.isLeaf(node)) { return null;
/** * Returns the direct predecessor of <code>key</code> amongst * <code>node</code>'s child nodes wrt. to {@link TreeManager#getOrder()}. * Returns <code>null</code> if either <code>node</code> has no child nodes * or <code>node</code> is a leaf (see {@link TreeManager#isLeaf(Node)}) or * <code>key</code> is smaller than all the keys of all child nodes of * <code>node</code>. */ protected final Node getPredecessor(Node node, String key) throws RepositoryException { if (!node.hasNodes() || treeManager.isLeaf(node)) { return null; } // Shortcut for exact match try { return node.getNode(key); } catch (PathNotFoundException ignore) { } // Search for direct predecessor of key in the nodes children // todo performance: for ordered nodes use binary search NodeIterator childNodes = node.getNodes(); Node p = null; while (childNodes.hasNext()) { Node n = childNodes.nextNode(); String childKey = n.getName(); if (order.compare(key, childKey) > 0 && (p == null || order.compare(childKey, p.getName()) > 0)) { p = n; } } return p; }
/** * Returns the direct predecessor of <code>key</code> amongst * <code>node</code>'s child nodes wrt. to {@link TreeManager#getOrder()}. * Returns <code>null</code> if either <code>node</code> has no child nodes * or <code>node</code> is a leaf (see {@link TreeManager#isLeaf(Node)}) or * <code>key</code> is smaller than all the keys of all child nodes of * <code>node</code>. */ protected final Node getPredecessor(Node node, String key) throws RepositoryException { if (!node.hasNodes() || treeManager.isLeaf(node)) { return null; } // Shortcut for exact match try { return node.getNode(key); } catch (PathNotFoundException ignore) { } // Search for direct predecessor of key in the nodes children // todo performance: for ordered nodes use binary search NodeIterator childNodes = node.getNodes(); Node p = null; while (childNodes.hasNext()) { Node n = childNodes.nextNode(); String childKey = n.getName(); if (order.compare(key, childKey) > 0 && (p == null || order.compare(childKey, p.getName()) > 0)) { p = n; } } return p; }
/** * Returns the direct predecessor of <code>key</code> amongst * <code>node</code>'s child nodes wrt. to {@link TreeManager#getOrder()}. * Returns <code>null</code> if either <code>node</code> has no child nodes * or <code>node</code> is a leaf (see {@link TreeManager#isLeaf(Node)}) or * <code>key</code> is smaller than all the keys of all child nodes of * <code>node</code>. */ protected final Node getPredecessor(Node node, String key) throws RepositoryException { if (!node.hasNodes() || treeManager.isLeaf(node)) { return null; } // Shortcut for exact match try { return node.getNode(key); } catch (PathNotFoundException ignore) { } // Search for direct predecessor of key in the nodes children // todo performance: for ordered nodes use binary search NodeIterator childNodes = node.getNodes(); Node p = null; while (childNodes.hasNext()) { Node n = childNodes.nextNode(); String childKey = n.getName(); if (order.compare(key, childKey) > 0 && (p == null || order.compare(childKey, p.getName()) > 0)) { p = n; } } return p; }
if (!node.hasNodes() || treeManager.isLeaf(node)) { return null;
if (!node.hasNodes() || treeManager.isLeaf(node)) { return null;
@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; } }