@Deprecated @Override public String toString() { if (segments.isEmpty()) { return "(ROOT)"; //$NON-NLS-1$ } else { return getPathString(); } }
/** * Returns all {@link DirectDataSource}s registered in this repository. * @return all {@link DirectDataSource}s * @throws IOException if failed to initialize data sources * @throws InterruptedException if interrupted */ public Collection<String> getContainerPaths() throws IOException, InterruptedException { Collection<String> results = new ArrayList<>(); LinkedList<Node> work = new LinkedList<>(); work.add(root); while (work.isEmpty() == false) { Node node = work.removeFirst(); if (node.hasContent()) { results.add(node.path.getPathString()); } work.addAll(node.children.values()); } return results; }
/** * Returns the container path of the target path. * @param path target path * @return corresponded container's path * @throws IOException if failed to detect the path * @throws IllegalArgumentException if some parameters were {@code null} */ public String getContainerPath(String path) throws IOException { if (path == null) { throw new IllegalArgumentException("path must not be null"); //$NON-NLS-1$ } NodePath nodePath = NodePath.of(path); Node node = findNode(nodePath); assert node != null; int depth = node.getDepth(); return nodePath.subPath(0, depth).getPathString(); }
/** * Returns the component path of the target path. * The component path is a relative path from the {@link #getContainerPath(String) container path}. * @param path target path * @return corresponded component path * @throws IOException if failed to detect the path * @throws IllegalArgumentException if some parameters were {@code null} */ public String getComponentPath(String path) throws IOException { if (path == null) { throw new IllegalArgumentException("path must not be null"); //$NON-NLS-1$ } NodePath nodePath = NodePath.of(path); Node node = findNode(nodePath); assert node != null; int depth = node.getDepth(); return nodePath.subPath(depth, nodePath.size()).getPathString(); }