}
if (fParentRelativeURI.length() == 0) {
return relativeURI;
}
URI base = new URI(fParentRelativeURI, true);
URI uri = new URI(base, relativeURI);
/** Check whether the scheme components are equal. */
final String baseScheme = base.getScheme();
final String literalScheme = uri.getScheme();
if (!isEqual(baseScheme, literalScheme)) {
return relativeURI;
}
/** Check whether the authority components are equal. */
final String baseAuthority = base.getAuthority();
final String literalAuthority = uri.getAuthority();
if (!isEqual(baseAuthority, literalAuthority)) {
return uri.getSchemeSpecificPart();
}
/**
* The scheme and authority components are equal,
* return the path and the possible query and/or
* fragment which follow.
*/
final String literalPath = uri.getPath();
final String literalQuery = uri.getQueryString();
final String literalFragment = uri.getFragment();
if (literalQuery != null || literalFragment != null) {
StringBuffer buffer = new StringBuffer();
if (literalPath != null) {
buffer.append(literalPath);
}