Java Code Examples for com.sun.org.apache.xerces.internal.util.URI#getSchemeSpecificPart()

The following examples show how to use com.sun.org.apache.xerces.internal.util.URI#getSchemeSpecificPart() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XIncludeHandler.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 2
Source File: XIncludeHandler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 3
Source File: XIncludeHandler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 4
Source File: XIncludeHandler.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 5
Source File: XIncludeHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 6
Source File: XIncludeHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 7
Source File: XIncludeHandler.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.length() == 0) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 8
Source File: XIncludeHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 9
Source File: XIncludeHandler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 10
Source File: XIncludeHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}
 
Example 11
Source File: XIncludeHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a URI, relative to the include parent's base URI, of the current
 * [base URI].  For instance, if the current [base URI] was "dir1/dir2/file.xml"
 * and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
 * @return the relative URI
 */
protected String getRelativeBaseURI() throws MalformedURIException {
    int includeParentDepth = getIncludeParentDepth();
    String relativeURI = this.getRelativeURI(includeParentDepth);
    if (isRootDocument()) {
        return relativeURI;
    }
    else {
        if (relativeURI.equals("")) {
            relativeURI = fCurrentBaseURI.getLiteralSystemId();
        }

        if (includeParentDepth == 0) {
            if (fParentRelativeURI == null) {
                fParentRelativeURI =
                    fParentXIncludeHandler.getRelativeBaseURI();
            }
            if (fParentRelativeURI.equals("")) {
                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 (!Objects.equals(baseScheme, literalScheme)) {
                return relativeURI;
            }

            /** Check whether the authority components are equal. */
            final String baseAuthority = base.getAuthority();
            final String literalAuthority = uri.getAuthority();
            if (!Objects.equals(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) {
                final StringBuilder buffer = new StringBuilder();
                if (literalPath != null) {
                    buffer.append(literalPath);
                }
                if (literalQuery != null) {
                    buffer.append('?');
                    buffer.append(literalQuery);
                }
                if (literalFragment != null) {
                    buffer.append('#');
                    buffer.append(literalFragment);
                }
                return buffer.toString();
            }
            return literalPath;
        }
        else {
            return relativeURI;
        }
    }
}