com.sun.org.apache.xerces.internal.util.URI

Here are the examples of the java api class com.sun.org.apache.xerces.internal.util.URI taken from open source projects.

1. XIncludeHandler#getRelativeURI()

Project: openjdk
Source File: XIncludeHandler.java
View license
/**
     * Returns a relative URI, which when resolved against the base URI at the
     * specified depth, will create the current base URI.
     * This is accomplished by merged the literal system IDs.
     * @param depth the depth at which to start creating the relative URI
     * @return a relative URI to convert the base URI at the given depth to the current
     *         base URI
     */
public String getRelativeURI(int depth) throws MalformedURIException {
    // The literal system id at the location given by "start" is *in focus* at
    // the given depth. So we need to adjust it to the next scope, so that we
    // only process out of focus literal system ids
    int start = scopeOfBaseURI(depth) + 1;
    if (start == fBaseURIScope.size()) {
        // If that is the last system id, then we don't need a relative URI
        return "";
    }
    URI uri = new URI("file", (String) fLiteralSystemID.elementAt(start));
    for (int i = start + 1; i < fBaseURIScope.size(); i++) {
        uri = new URI(uri, (String) fLiteralSystemID.elementAt(i));
    }
    return uri.getPath();
}

2. XMLEntityManager#expandSystemIdStrictOn()

Project: openjdk
Source File: XMLEntityManager.java
View license
private static String expandSystemIdStrictOn(String systemId, String baseSystemId) throws URI.MalformedURIException {
    URI systemURI = new URI(systemId, true);
    if (systemURI.isAbsoluteURI()) {
        return systemId;
    }
    URI baseURI = null;
    if (baseSystemId == null || baseSystemId.length() == 0) {
        baseURI = getUserDir();
    } else {
        baseURI = new URI(baseSystemId, true);
        if (!baseURI.isAbsoluteURI()) {
            baseURI.absolutize(getUserDir());
        }
    }
    systemURI.absolutize(baseURI);
    return systemURI.toString();
}

3. XMLEntityManager#expandSystemIdStrictOff()

Project: openjdk
Source File: XMLEntityManager.java
View license
private static String expandSystemIdStrictOff(String systemId, String baseSystemId) throws URI.MalformedURIException {
    URI systemURI = new URI(systemId, true);
    if (systemURI.isAbsoluteURI()) {
        if (systemURI.getScheme().length() > 1) {
            return systemId;
        }
        throw new URI.MalformedURIException();
    }
    URI baseURI = null;
    if (baseSystemId == null || baseSystemId.length() == 0) {
        baseURI = getUserDir();
    } else {
        baseURI = new URI(baseSystemId, true);
        if (!baseURI.isAbsoluteURI()) {
            baseURI.absolutize(getUserDir());
        }
    }
    systemURI.absolutize(baseURI);
    return systemURI.toString();
}

4. XMLEntityManager#expandSystemId()

Project: openjdk
Source File: XMLEntityManager.java
View license
public static String expandSystemId(String systemId, String baseSystemId) {
    if (systemId == null || systemId.length() == 0) {
        return systemId;
    }
    try {
        URI uri = new URI(systemId);
        if (uri != null) {
            return systemId;
        }
    } catch (URI.MalformedURIException e) {
    }
    String id = fixURI(systemId);
    URI base = null;
    URI uri = null;
    try {
        if (baseSystemId == null || baseSystemId.length() == 0 || baseSystemId.equals(systemId)) {
            String dir = getUserDir().toString();
            base = new URI("file", "", dir, null, null);
        } else {
            try {
                base = new URI(fixURI(baseSystemId));
            } catch (URI.MalformedURIException e) {
                if (baseSystemId.indexOf(':') != -1) {
                    base = new URI("file", "", fixURI(baseSystemId), null, null);
                } else {
                    String dir = getUserDir().toString();
                    dir = dir + fixURI(baseSystemId);
                    base = new URI("file", "", dir, null, null);
                }
            }
        }
        uri = new URI(base, id);
    } catch (Exception e) {
    }
    if (uri == null) {
        return systemId;
    }
    return uri.toString();
}

5. XMLEntityManager#expandSystemId()

Project: openjdk
Source File: XMLEntityManager.java
View license
public static String expandSystemId(String systemId, String baseSystemId, boolean strict) throws URI.MalformedURIException {
    if (systemId == null) {
        return null;
    }
    if (strict) {
        try {
            new URI(systemId);
            return systemId;
        } catch (URI.MalformedURIException ex) {
        }
        URI base = null;
        if (baseSystemId == null || baseSystemId.length() == 0) {
            base = new URI("file", "", getUserDir().toString(), null, null);
        } else {
            try {
                base = new URI(baseSystemId);
            } catch (URI.MalformedURIException e) {
                String dir = getUserDir().toString();
                dir = dir + baseSystemId;
                base = new URI("file", "", dir, null, null);
            }
        }
        URI uri = new URI(base, systemId);
        return uri.toString();
    }
    try {
        return expandSystemIdStrictOff(systemId, baseSystemId);
    } catch (URI.MalformedURIException e) {
        try {
            return expandSystemIdStrictOff1(systemId, baseSystemId);
        } catch (URISyntaxException ex) {
        }
    }
    if (systemId.length() == 0) {
        return systemId;
    }
    String id = fixURI(systemId);
    URI base = null;
    URI uri = null;
    try {
        if (baseSystemId == null || baseSystemId.length() == 0 || baseSystemId.equals(systemId)) {
            base = getUserDir();
        } else {
            try {
                base = new URI(fixURI(baseSystemId).trim());
            } catch (URI.MalformedURIException e) {
                if (baseSystemId.indexOf(':') != -1) {
                    base = new URI("file", "", fixURI(baseSystemId).trim(), null, null);
                } else {
                    base = new URI(getUserDir(), fixURI(baseSystemId));
                }
            }
        }
        uri = new URI(base, id.trim());
    } catch (Exception e) {
    }
    if (uri == null) {
        return systemId;
    }
    return uri.toString();
}

6. XMLEntityStorage#expandSystemId()

Project: openjdk
Source File: XMLEntityStorage.java
View license
public static String expandSystemId(String systemId, String baseSystemId) {
    if (systemId == null || systemId.length() == 0) {
        return systemId;
    }
    try {
        new URI(systemId);
        return systemId;
    } catch (URI.MalformedURIException e) {
    }
    String id = fixURI(systemId);
    URI base = null;
    URI uri = null;
    try {
        if (baseSystemId == null || baseSystemId.length() == 0 || baseSystemId.equals(systemId)) {
            String dir = getUserDir();
            base = new URI("file", "", dir, null, null);
        } else {
            try {
                base = new URI(fixURI(baseSystemId));
            } catch (URI.MalformedURIException e) {
                if (baseSystemId.indexOf(':') != -1) {
                    base = new URI("file", "", fixURI(baseSystemId), null, null);
                } else {
                    String dir = getUserDir();
                    dir = dir + fixURI(baseSystemId);
                    base = new URI("file", "", dir, null, null);
                }
            }
        }
        uri = new URI(base, id);
    } catch (Exception e) {
    }
    if (uri == null) {
        return systemId;
    }
    return uri.toString();
}

7. XMLEntityManager#getUserDir()

Project: openjdk
Source File: XMLEntityManager.java
View license
private static synchronized URI getUserDir() throws URI.MalformedURIException {
    String userDir = "";
    try {
        userDir = SecuritySupport.getSystemProperty("user.dir");
    } catch (SecurityException se) {
    }
    if (userDir.length() == 0)
        return new URI("file", "", "", null, null);
    if (gUserDirURI != null && userDir.equals(gUserDir)) {
        return gUserDirURI;
    }
    gUserDir = userDir;
    char separator = java.io.File.separatorChar;
    userDir = userDir.replace(separator, '/');
    int len = userDir.length(), ch;
    StringBuilder buffer = new StringBuilder(len * 3);
    if (len >= 2 && userDir.charAt(1) == ':') {
        ch = Character.toUpperCase(userDir.charAt(0));
        if (ch >= 'A' && ch <= 'Z') {
            buffer.append('/');
        }
    }
    int i = 0;
    for (; i < len; i++) {
        ch = userDir.charAt(i);
        if (ch >= 128)
            break;
        if (gNeedEscaping[ch]) {
            buffer.append('%');
            buffer.append(gAfterEscaping1[ch]);
            buffer.append(gAfterEscaping2[ch]);
        } else {
            buffer.append((char) ch);
        }
    }
    if (i < len) {
        byte[] bytes = null;
        byte b;
        try {
            bytes = userDir.substring(i).getBytes("UTF-8");
        } catch (java.io.UnsupportedEncodingException e) {
            return new URI("file", "", userDir, null, null);
        }
        len = bytes.length;
        for (i = 0; i < len; i++) {
            b = bytes[i];
            if (b < 0) {
                ch = b + 256;
                buffer.append('%');
                buffer.append(gHexChs[ch >> 4]);
                buffer.append(gHexChs[ch & 0xf]);
            } else if (gNeedEscaping[b]) {
                buffer.append('%');
                buffer.append(gAfterEscaping1[b]);
                buffer.append(gAfterEscaping2[b]);
            } else {
                buffer.append((char) b);
            }
        }
    }
    if (!userDir.endsWith("/"))
        buffer.append('/');
    gUserDirURI = new URI("file", "", buffer.toString(), null, null);
    return gUserDirURI;
}

8. XMLEntityManager#expandSystemIdStrictOff1()

Project: openjdk
Source File: XMLEntityManager.java
View license
private static String expandSystemIdStrictOff1(String systemId, String baseSystemId) throws URISyntaxException, URI.MalformedURIException {
    java.net.URI systemURI = new java.net.URI(systemId);
    if (systemURI.isAbsolute()) {
        if (systemURI.getScheme().length() > 1) {
            return systemId;
        }
        throw new URISyntaxException(systemId, "the scheme's length is only one character");
    }
    URI baseURI = null;
    if (baseSystemId == null || baseSystemId.length() == 0) {
        baseURI = getUserDir();
    } else {
        baseURI = new URI(baseSystemId, true);
        if (!baseURI.isAbsoluteURI()) {
            // assume "base" is also a relative uri
            baseURI.absolutize(getUserDir());
        }
    }
    // absolutize the system identifier using the base URI
    //        systemURI.absolutize(baseURI);
    systemURI = (new java.net.URI(baseURI.toString())).resolve(systemURI);
    // return the string rep of the new uri (an absolute one)
    return systemURI.toString();
// if any exception is thrown, it'll get thrown to the caller.
}