import javax.jcr.RepositoryException;
import javax.jcr.Session;
+/** A {@link Path} which contains a reference to a JCR {@link Node}. */
public class JcrPath implements Path {
private final static String delimStr = "/";
private final static char delimChar = '/';
if (other.startsWith(this)) {
String p1 = toString();
String p2 = other.toString();
- return new JcrPath(fs, p2.substring(p1.length(), p2.length()));
+ String relative = p2.substring(p1.length(), p2.length());
+ if (relative.charAt(0) == '/')
+ relative = relative.substring(1);
+ return new JcrPath(fs, relative);
}
- throw new IllegalArgumentException(other + " cannot be realtivized against " + this);
+ throw new IllegalArgumentException(other + " cannot be relativized against " + this);
}
@Override
public URI toUri() {
try {
- return new URI("jcr", toString(), null);
+ return new URI(fs.provider().getScheme(), toString(), null);
} catch (URISyntaxException e) {
throw new JcrFsException("Cannot create URI for " + toString(), e);
}