*/
public Path relativeTo( Path startingPath ) {
CheckArg.isNotNull(startingPath, "to");
if (!this.isAbsolute()) {
String msg = GraphI18n.pathIsNotAbsolute.text(this);
throw new InvalidPathException(msg);
}
if (startingPath.isRoot()) {
// We just want a relative path containing the same segments ...
return relativeToRoot();
}
if (!startingPath.isAbsolute()) {
String msg = GraphI18n.pathIsNotAbsolute.text(startingPath);
throw new InvalidPathException(msg);
}
// Count the number of segments up to the common ancestor (relative path is what remains) ...
int lengthOfCommonAncestor = 0;
Iterator<Segment> thisIter = this.getNormalizedPath().iterator();