/** * @param path path * @return path components */ public static String[] componentsFromPath(final Path path) { return componentsFromPathString(path.getPath()); }
/** * Append one path to another * * @param prefix prefix * @param subpath sub path * * @return sub path appended to the prefix */ public static Path appendPath(Path prefix, String subpath) { return asPath(appendPath(prefix.getPath(), subpath)); }
public static Path parentPath(Path path) { return asPath(parentPathString(path.getPath())); }
private boolean isLocalRoot(Path path) { return PathUtil.isRoot(PathUtil.removePrefix(rootPath.getPath(), path.getPath())); }
/** * @param delegate delegate tree * @param rootPath root path for the subtree * @param fullPath true if the root path should not be removed when accessing the delegate */ public SubPathTree(Tree<T> delegate, String rootPath, boolean fullPath) { this(delegate, PathUtil.asPath(rootPath), fullPath); }
/** * convert internal path to external * * @param intpath * * @return */ private String translatePathExternal(String intpath) { if (fullPath) { return intpath; } else { return PathUtil.appendPath(rootPath.getPath(), intpath); } }
private String translatePathInternal(String extpath) { if (fullPath) { return extpath; } else { return PathUtil.removePrefix(rootPath.getPath(), extpath); } }
@Override public boolean isDirectory() { return delegate.isDirectory(); } }
/** * create a path from an array of components * @param components path components strings * @return a path */ public static Path pathFromComponents(String[] components) { if (null == components || components.length == 0) { return null; } return new PathImpl(pathStringFromComponents(components)); }
@Override public boolean matchesContent(T content) { boolean a1 = a.matchesContent(content); if (a1 && !and || !a1 && and) { return a1; } return b.matchesContent(content); } };
public static String pathName(String path) { String[] split = componentsFromPathString(path); if (split.length > 0) { return split[split.length - 1]; } return null; }
@Override public InputStream getInputStream() throws IOException { if (null != stream) { return stream; } else if (null != lazyStream) { return lazyStream.getInputStream(); } return null; } }
@Override public long writeContent(OutputStream outputStream) throws IOException { return stream.writeContent(outputStream); } }
/** * create a path from an array of components * @param components path components strings * @return a path string */ public static String pathStringFromComponents(String[] components) { if (null == components || components.length == 0) { return null; } return cleanPath(join(components, SEPARATOR)); }
@Override public Resource<T> updateResource(Path path, T content) { throw StorageException.updateException(path, "Empty: no resource for path: " + path); } }