FileSystemProvider fsProvider = new JackrabbitMemoryFsProvider();
// Simple file
+ Path rootPath = fsProvider.getPath(new URI("jcr+memory:/"));
+ log.debug("Got root " + rootPath);
Path testPath = fsProvider.getPath(new URI("jcr+memory:/test.txt"));
+ log.debug("Test path");
+ assertEquals("test.txt", testPath.getFileName().toString());
+ assertEquals(rootPath, testPath.getParent());
+ assertEquals(testPath.getFileName(), rootPath.relativize(testPath));
+ // relativize self should be empty path
+ Path selfRelative = testPath.relativize(testPath);
+ assertEquals("", selfRelative.toString());
+
+ log.debug("Create file " + testPath);
Files.createFile(testPath);
BasicFileAttributes bfa = Files.readAttributes(testPath, BasicFileAttributes.class);
FileTime ft = bfa.creationTime();
assertTrue(Arrays.equals(arr, read));
assertEquals(txt, new String(read));
log.debug("Read " + testPath);
- Path rootPath = fsProvider.getPath(new URI("jcr+memory:/"));
- log.debug("Got root " + rootPath);
Path testDir = rootPath.resolve("testDir");
log.debug("Resolved " + testDir);
// Copy
this.absolute = true;
this.hashCode = 0;
return;
+ } else if (path.equals("")) {// empty path
+ this.path = new String[] { "" };
+ this.absolute = false;
+ this.hashCode = "".hashCode();
+ return;
}
this.absolute = path.charAt(0) == delimChar ? true : false;
String trimmedPath = path.substring(absolute ? 1 : 0,
String p2 = other.toString();
return new JcrPath(fs, p2.substring(p1.length(), p2.length()));
}
- throw new UnsupportedOperationException();
+ throw new IllegalArgumentException(other + " cannot be realtivized against " + this);
}
@Override
if (!(obj instanceof JcrPath))
return false;
JcrPath other = (JcrPath) obj;
+
+ if (path == null) {// root
+ if (other.path == null)// root
+ return true;
+ else
+ return false;
+ } else {
+ if (other.path == null)// root
+ return false;
+ }
+ // non root
if (path.length != other.path.length)
return false;
for (int i = 0; i < path.length; i++) {