/** * Throws an {@code IOException} if and only if the path represented by * {@code a} contains the path represented by {@code b}, where a path is * said to contain another path if and only if it is equal or an ancestor * of the other path. * <p> * Note that this method uses the absolute path of both files as if by * calling {@link File#getAbsolutePath()}. * * @param a a file. * @param b another file. */ private static void checkContains(File a, File b) throws IOException { if (Paths.contains( a.getAbsolutePath(), b.getAbsolutePath(), File.separatorChar)) throw new IOException(b + " (contained in " + a + ")"); }
/** * Returns {@code true} if and only if the path represented * by {@code a} contains the path represented by {@code b}, * where a path is said to contain another path if and only * if it's equal or an ancestor of the other path. * <p> * Note: * <ul> * <li>This method uses the absolute path name of the given files. * <li>This method does <em>not</em> access the file system. * It just tests the paths. * </ul> * * @param a the file to test for containing {@code b}. * @param b the file to test for being contained by {@code a}. * @return {@code true} if and only if the path represented * by {@code a} contains the path represented by {@code b}. * @throws NullPointerException If any parameter is {@code null}. */ public static boolean contains(File a, File b) { return Paths.contains( a.getAbsolutePath(), b.getAbsolutePath(), separatorChar); }
/** * Returns {@code true} if and only if the path represented * by this instance is a direct or indirect parent of the path * represented by the given {@code file}. * <p> * Note: * <ul> * <li>This method uses the absolute path name of the given files. * <li>This method does <em>not</em> access the file system. * It just tests the paths. * </ul> * * @param file The file object for the path to test for being a direct or * indirect child of the path of this instance. * @return {@code true} if and only if the path represented * by this instance is a direct or indirect parent of the path * represented by the given {@code file}. */ public boolean isParentOf(final File file) { final String a = this.getAbsolutePath(); final String b = file.getAbsoluteFile().getParent(); return b != null ? Paths.contains(a, b, separatorChar) : false; }
^ (innerArchive == enclArchive && null == controller); assert null == enclArchive || Paths.contains( enclArchive.getPath(), file.getParentFile().getPath(), separatorChar)