/** * Resolves a name, relative to the file. If the supplied name is an absolute path, then it is resolved relative to * the root of the file system that the file belongs to. If a relative name is supplied, then it is resolved * relative to this file name. * * @param root The base FileName. * @param path The path to the file relative to the base FileName or an absolute path. * @return The constructed FileName. * @throws FileSystemException if an error occurs constructing the FileName. */ @Override public FileName resolveName(final FileName root, final String path) throws FileSystemException { return resolveName(root, path, NameScope.FILE_SYSTEM); }
/** * Resolves a name, relative to the file. If the supplied name is an absolute path, then it is resolved relative to * the root of the file system that the file belongs to. If a relative name is supplied, then it is resolved * relative to this file name. * * @param root The base FileName. * @param path The path to the file relative to the base FileName or an absolute path. * @return The constructed FileName. * @throws FileSystemException if an error occurs constructing the FileName. */ @Override public FileName resolveName(final FileName root, final String path) throws FileSystemException { return resolveName(root, path, NameScope.FILE_SYSTEM); }
/** * Resolves a name, relative to the file. If the supplied name is an absolute path, then it is resolved relative to * the root of the file system that the file belongs to. If a relative name is supplied, then it is resolved * relative to this file name. * * @param root The base FileName. * @param path The path to the file relative to the base FileName or an absolute path. * @return The constructed FileName. * @throws FileSystemException if an error occurs constructing the FileName. */ @Override public FileName resolveName(final FileName root, final String path) throws FileSystemException { return resolveName(root, path, NameScope.FILE_SYSTEM); }
/** * Resolves a name, relative to the file. If the supplied name is an * absolute path, then it is resolved relative to the root of the file * system that the file belongs to. If a relative name is supplied, then it * is resolved relative to this file name. * @param root The base FileName. * @param path The path to the file relative to the base FileName or an absolute path. * @return The constructed FileName. * @throws FileSystemException if an error occurs constructing the FileName. */ @Override public FileName resolveName(final FileName root, final String path) throws FileSystemException { return resolveName(root, path, NameScope.FILE_SYSTEM); }
/** * Asserts that a particular relative name is invalid for a particular scope. */ private void assertBadName(final FileName name, final String relName, final NameScope scope) { try { getManager().resolveName(name, relName, scope); fail("expected failure"); } catch (final FileSystemException e) { // TODO - should check error message } }
/** * Asserts that a particular relative name is invalid for a particular scope. */ private void assertBadName(final FileName name, final String relName, final NameScope scope) { try { getManager().resolveName(name, relName, scope); fail("expected failure"); } catch (final FileSystemException e) { // TODO - should check error message } }
/** * Asserts that a particular relative name is invalid for a particular * scope. */ private void assertBadName(final FileName name, final String relName, final NameScope scope) { try { getManager().resolveName(name, relName, scope); fail("expected failure"); } catch (final FileSystemException e) { // TODO - should check error message } }
/** * Checks that a file name converts to an expected relative path */ private void testRelName(final FileName baseName, final String relPath) throws Exception { final FileName expectedName = getManager().resolveName(baseName, relPath); // Convert to relative path, and check final String actualRelPath = baseName.getRelativeName(expectedName); assertEquals(relPath, actualRelPath); } }
/** * Checks that a file name converts to an expected relative path */ private void testRelName(final FileName baseName, final String relPath) throws Exception { final FileName expectedName = getManager().resolveName(baseName, relPath); // Convert to relative path, and check final String actualRelPath = baseName.getRelativeName(expectedName); assertEquals(relPath, actualRelPath); } }
/** * Checks that a relative name resolves to the expected absolute path. Tests both forward and back slashes. */ private void assertSameName(final String expectedPath, final FileName baseName, final String relName, final NameScope scope) throws Exception { // Try the supplied name FileName name = getManager().resolveName(baseName, relName, scope); assertEquals(expectedPath, name.getPath()); String temp; // Replace the separators temp = relName.replace('\\', '/'); name = getManager().resolveName(baseName, temp, scope); assertEquals(expectedPath, name.getPath()); // And again temp = relName.replace('/', '\\'); name = getManager().resolveName(baseName, temp, scope); assertEquals(expectedPath, name.getPath()); }
/** * Checks that a file name converts to an expected relative path */ private void testRelName(final FileName baseName, final String relPath) throws Exception { final FileName expectedName = getManager().resolveName(baseName, relPath); // Convert to relative path, and check final String actualRelPath = baseName.getRelativeName(expectedName); assertEquals(relPath, actualRelPath); } }
/** * Checks that a relative name resolves to the expected absolute path. Tests both forward and back slashes. */ private void assertSameName(final String expectedPath, final FileName baseName, final String relName, final NameScope scope) throws Exception { // Try the supplied name FileName name = getManager().resolveName(baseName, relName, scope); assertEquals(expectedPath, name.getPath()); String temp; // Replace the separators temp = relName.replace('\\', '/'); name = getManager().resolveName(baseName, temp, scope); assertEquals(expectedPath, name.getPath()); // And again temp = relName.replace('/', '\\'); name = getManager().resolveName(baseName, temp, scope); assertEquals(expectedPath, name.getPath()); }
return resolveName(baseFile.getName(), uri, NameScope.FILE_SYSTEM);
/** * Checks that a relative name resolves to the expected absolute path. * Tests both forward and back slashes. */ private void assertSameName(final String expectedPath, final FileName baseName, final String relName, final NameScope scope) throws Exception { // Try the supplied name FileName name = getManager().resolveName(baseName, relName, scope); assertEquals(expectedPath, name.getPath()); String temp; // Replace the separators temp = relName.replace('\\', '/'); name = getManager().resolveName(baseName, temp, scope); assertEquals(expectedPath, name.getPath()); // And again temp = relName.replace('/', '\\'); name = getManager().resolveName(baseName, temp, scope); assertEquals(expectedPath, name.getPath()); }
/** * Tests resolution of absolute names. */ public void testAbsoluteNames() throws Exception { // Test against the base folder FileName name = getReadFolder().getName(); checkAbsoluteNames(name); // Test against the root name = getReadFolder().getFileSystem().getRoot().getName(); checkAbsoluteNames(name); // Test against some unknown file name = getManager().resolveName(name, "a/b/unknown"); checkAbsoluteNames(name); }
/** * Tests resolution of absolute names. */ public void testAbsoluteNames() throws Exception { // Test against the base folder FileName name = getReadFolder().getName(); checkAbsoluteNames(name); // Test against the root name = getReadFolder().getFileSystem().getRoot().getName(); checkAbsoluteNames(name); // Test against some unknown file name = getManager().resolveName(name, "a/b/unknown"); checkAbsoluteNames(name); }
/** * Tests resolution of absolute names. */ public void testAbsoluteNames() throws Exception { // Test against the base folder FileName name = getReadFolder().getName(); checkAbsoluteNames(name); // Test against the root name = getReadFolder().getFileSystem().getRoot().getName(); checkAbsoluteNames(name); // Test against some unknown file name = getManager().resolveName(name, "a/b/unknown"); checkAbsoluteNames(name); }
/** * Tests child file names. */ public void testChildName() throws Exception { final FileName baseName = getReadFolder().getName(); final String basePath = baseName.getPath(); final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD); // Test path is absolute assertTrue("is absolute", basePath.startsWith("/")); // Test base name assertEquals("base name", "some-child", name.getBaseName()); // Test absolute path assertEquals("absolute path", basePath + "/some-child", name.getPath()); // Test parent path assertEquals("parent absolute path", basePath, name.getParent().getPath()); // Try using a compound name to find a child assertBadName(name, "a/b", NameScope.CHILD); // Check other invalid names checkDescendentNames(name, NameScope.CHILD); }
/** * Tests child file names. */ public void testChildName() throws Exception { final FileName baseName = getReadFolder().getName(); final String basePath = baseName.getPath(); final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD); // Test path is absolute assertTrue("is absolute", basePath.startsWith("/")); // Test base name assertEquals("base name", "some-child", name.getBaseName()); // Test absolute path assertEquals("absolute path", basePath + "/some-child", name.getPath()); // Test parent path assertEquals("parent absolute path", basePath, name.getParent().getPath()); // Try using a compound name to find a child assertBadName(name, "a/b", NameScope.CHILD); // Check other invalid names checkDescendentNames(name, NameScope.CHILD); }
/** * Tests child file names. */ public void testChildName() throws Exception { final FileName baseName = getReadFolder().getName(); final String basePath = baseName.getPath(); final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD); // Test path is absolute assertTrue("is absolute", basePath.startsWith("/")); // Test base name assertEquals("base name", "some-child", name.getBaseName()); // Test absolute path assertEquals("absolute path", basePath + "/some-child", name.getPath()); // Test parent path assertEquals("parent absolute path", basePath, name.getParent().getPath()); // Try using a compound name to find a child assertBadName(name, "a/b", NameScope.CHILD); // Check other invalid names checkDescendentNames(name, NameScope.CHILD); }