public E remove(String path) { Node<E> n = get(path, false); if (n == null) { return null; } E previous = n.elem; n.elem = null; n.prune(); return previous; }
public String getRootPath() { return infos.getRootPath(); }
public void clear() { infos.clear(); }
/** * {@inheritDoc} */ public void dumpCoverage(Session session, ProgressTrackerListener listener, boolean skipJcrContent) throws RepositoryException { ProgressTracker tracker = new ProgressTracker(listener); // get common ancestor Tree<PathFilterSet> tree = new Tree<PathFilterSet>(); for (PathFilterSet set: nodesFilterSets) { tree.put(set.getRoot(), set); } String rootPath = tree.getRootPath(); javax.jcr.Node rootNode; if (session.nodeExists(rootPath)) { rootNode = session.getNode(rootPath); } else if (session.nodeExists("/")) { log.warn("Common ancestor {} not found. Using root node", rootPath); rootNode = session.getRootNode(); rootPath = "/"; } else { throw new PathNotFoundException("Common ancestor " + rootPath+ " not found."); } log.debug("Starting coverage dump at {} (skipJcrContent={})", rootPath, skipJcrContent); dumpCoverage(rootNode, tracker, skipJcrContent); }
public List<Info> infos() { if (!nonRecursive) { // strip all redundant entries for (Map.Entry<String, Info> e: infos.map().entrySet()) { if (e.getValue().names.isEmpty()) { infos.removeChildren(e.getKey()); } } } LinkedList<Info> dirs = new LinkedList<Info>(); dirs.addAll(infos.map().values()); return dirs; }
filterTree.put(set.getRoot(), set);
public Map<String, E> map() { Map<String, E> map = new LinkedHashMap<String, E>(); fill(map, root, ""); return map; }
Tree.Node<PathFilterSet> filterNode = filterTree.getNode(parentInfo.path); if (filterNode != null) { parentInfo.sort(filterNode.getChildren().keySet());
public void add(File file) throws VltException, IOException { File dir; if (file.isDirectory() && !nonRecursive && !dirsAsFiles) { // if recursive, treat directories as such dir = file; file = null; } else { // if non recursive, treat directories as files dir = file.getParentFile(); } String path = dir.getCanonicalPath(); Info info = infos.get(path); if (info == null) { info = new Info(new VltDirectory(ctx, dir)); infos.put(path, info); } if (file != null) { info.names.add(file.getName()); } }
private void fill(Map<String, E> map, Node<E> node, String parentPath) { String path; if (parentPath.length() != 1) { // stupid check for root path path = parentPath + separator + node.name; } else { path = parentPath + node.name; } if (node.elem != null) { map.put(path, node.elem); } for (Node<E> child: node.children.values()) { fill(map, child, path); } }
public E get(String path) { Node<E> n = get(path, false); return n == null ? null : n.elem; }
public E put(String path, E elem) { E previous; Node<E> n = get(path, true); previous = n.elem; n.elem = elem; return previous; }
public void removeChildren(String path) { Node<E> n = get(path, false); if (n != null) { n.removeChildren(); } }
public Node<E> getNode(String path) { return get(path, false); }