/** * Removes the preference node at the given path. * * @param path * the path * @return the node that was removed, or <code>null</code> if there was no * node at the given path */ public IPreferenceNode remove(String path) { Assert.isNotNull(path); int index = path.lastIndexOf(separator); if (index == -1) { return root.remove(path); } // Make sure that the last character in the string isn't the "." Assert.isTrue(index < path.length() - 1, "Path can not end with a dot");//$NON-NLS-1$ String parentPath = path.substring(0, index); String id = path.substring(index + 1); IPreferenceNode parentNode = find(parentPath); if (parentNode == null) { return null; } return parentNode.remove(id); }
/** * Removes the preference node at the given path. * * @param path * the path * @return the node that was removed, or <code>null</code> if there was no * node at the given path */ public IPreferenceNode remove(String path) { Assert.isNotNull(path); int index = path.lastIndexOf(separator); if (index == -1) { return root.remove(path); } // Make sure that the last character in the string isn't the "." Assert.isTrue(index < path.length() - 1, "Path can not end with a dot");//$NON-NLS-1$ String parentPath = path.substring(0, index); String id = path.substring(index + 1); IPreferenceNode parentNode = find(parentPath); if (parentNode == null) { return null; } return parentNode.remove(id); }
/** * Removes the preference node at the given path. * * @param path * the path * @return the node that was removed, or <code>null</code> if there was no * node at the given path */ public IPreferenceNode remove(String path) { Assert.isNotNull(path); int index = path.lastIndexOf(separator); if (index == -1) { return root.remove(path); } // Make sure that the last character in the string isn't the "." Assert.isTrue(index < path.length() - 1, "Path can not end with a dot");//$NON-NLS-1$ String parentPath = path.substring(0, index); String id = path.substring(index + 1); IPreferenceNode parentNode = find(parentPath); if (parentNode == null) { return null; } return parentNode.remove(id); }
/** * Removes the node from the manager, searching through all subnodes. * * @param parent * the node to search * @param nodeToRemove * the node to remove * @return whether the node was removed */ private boolean deepRemove(IPreferenceNode parent, IPreferenceNode nodeToRemove) { if (parent == nodeToRemove) { if (parent == getRoot()) { removeAll(); // we're removing the root return true; } } if (parent.remove(nodeToRemove)) { return true; } for (IPreferenceNode subNode : parent.getSubNodes()) { if (deepRemove(subNode, nodeToRemove)) { return true; } } return false; } }