Java Code Examples for sun.net.www.ParseUtil#decode()

The following examples show how to use sun.net.www.ParseUtil#decode() . 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: MailToURLConnection.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public synchronized OutputStream getOutputStream() throws IOException {
    if (os != null) {
        return os;
    } else if (is != null) {
        throw new IOException("Cannot write output after reading input.");
    }
    connect();

    String to = ParseUtil.decode(url.getPath());
    client.from(getFromAddress());
    client.to(to);

    os = client.startMessage();
    return os;
}
 
Example 2
Source File: FileURLMapper.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @returns the platform specific path corresponding to the URL, and in particular
 *  returns a UNC when the authority contains a hostname
 */

public String getPath () {
    if (file != null) {
        return file;
    }
    String host = url.getHost();
    if (host != null && !host.equals("") &&
        !"localhost".equalsIgnoreCase(host)) {
        String rest = url.getFile();
        String s = host + ParseUtil.decode (url.getFile());
        file = "\\\\"+ s.replace('/', '\\');
        return file;
    }
    String path = url.getFile().replace('/', '\\');
    file = ParseUtil.decode(path);
    return file;
}
 
Example 3
Source File: MailToURLConnection.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public synchronized OutputStream getOutputStream() throws IOException {
    if (os != null) {
        return os;
    } else if (is != null) {
        throw new IOException("Cannot write output after reading input.");
    }
    connect();

    String to = ParseUtil.decode(url.getPath());
    client.from(getFromAddress());
    client.to(to);

    os = client.startMessage();
    return os;
}
 
Example 4
Source File: FtpURLConnection.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Same as FtpURLconnection(URL) with a per connection proxy specified
 */
FtpURLConnection(URL url, Proxy p) {
    super(checkURL(url));
    instProxy = p;
    host = url.getHost();
    port = url.getPort();
    String userInfo = url.getUserInfo();

    if (userInfo != null) { // get the user and password
        int delimiter = userInfo.indexOf(':');
        if (delimiter == -1) {
            user = ParseUtil.decode(userInfo);
            password = null;
        } else {
            user = ParseUtil.decode(userInfo.substring(0, delimiter++));
            password = ParseUtil.decode(userInfo.substring(delimiter));
        }
    }
}
 
Example 5
Source File: FileURLMapper.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @returns the platform specific path corresponding to the URL, and in particular
 *  returns a UNC when the authority contains a hostname
 */

public String getPath () {
    if (file != null) {
        return file;
    }
    String host = url.getHost();
    if (host != null && !host.equals("") &&
        !"localhost".equalsIgnoreCase(host)) {
        String rest = url.getFile();
        String s = host + ParseUtil.decode (url.getFile());
        file = "\\\\"+ s.replace('/', '\\');
        return file;
    }
    String path = url.getFile().replace('/', '\\');
    file = ParseUtil.decode(path);
    return file;
}
 
Example 6
Source File: FtpURLConnection.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Same as FtpURLconnection(URL) with a per connection proxy specified
 */
FtpURLConnection(URL url, Proxy p) {
    super(checkURL(url));
    instProxy = p;
    host = url.getHost();
    port = url.getPort();
    String userInfo = url.getUserInfo();

    if (userInfo != null) { // get the user and password
        int delimiter = userInfo.indexOf(':');
        if (delimiter == -1) {
            user = ParseUtil.decode(userInfo);
            password = null;
        } else {
            user = ParseUtil.decode(userInfo.substring(0, delimiter++));
            password = ParseUtil.decode(userInfo.substring(delimiter));
        }
    }
}
 
Example 7
Source File: MailToURLConnection.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public synchronized OutputStream getOutputStream() throws IOException {
    if (os != null) {
        return os;
    } else if (is != null) {
        throw new IOException("Cannot write output after reading input.");
    }
    connect();

    String to = ParseUtil.decode(url.getPath());
    client.from(getFromAddress());
    client.to(to);

    os = client.startMessage();
    return os;
}
 
Example 8
Source File: JavaRuntimeURLConnection.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
JavaRuntimeURLConnection(URL url) throws IOException {
    super(url);
    String path = url.getPath();
    if (path.isEmpty() || path.charAt(0) != '/')
        throw new MalformedURLException(url + " missing path or /");
    if (path.length() == 1) {
        this.module = null;
        this.name = null;
    } else {
        int pos = path.indexOf('/', 1);
        if (pos == -1) {
            this.module = path.substring(1);
            this.name = null;
        } else {
            this.module = path.substring(1, pos);
            this.name = ParseUtil.decode(path.substring(pos+1));
        }
    }
}
 
Example 9
Source File: FtpURLConnection.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Same as FtpURLconnection(URL) with a per connection proxy specified
 */
FtpURLConnection(URL url, Proxy p) {
    super(url);
    instProxy = p;
    host = url.getHost();
    port = url.getPort();
    String userInfo = url.getUserInfo();

    if (userInfo != null) { // get the user and password
        int delimiter = userInfo.indexOf(':');
        if (delimiter == -1) {
            user = ParseUtil.decode(userInfo);
            password = null;
        } else {
            user = ParseUtil.decode(userInfo.substring(0, delimiter++));
            password = ParseUtil.decode(userInfo.substring(delimiter));
        }
    }
}
 
Example 10
Source File: FileURLMapper.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @returns the platform specific path corresponding to the URL
 *  so long as the URL does not contain a hostname in the authority field.
 */

public String getPath () {
    if (path != null) {
        return path;
    }
    String host = url.getHost();
    if (host == null || "".equals(host) || "localhost".equalsIgnoreCase (host)) {
        path = url.getFile();
        path = ParseUtil.decode (path);
    }
    return path;
}
 
Example 11
Source File: URLClassPath.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
FileLoader(URL url) throws IOException {
    super(url);
    if (!"file".equals(url.getProtocol())) {
        throw new IllegalArgumentException("url");
    }
    String path = url.getFile().replace('/', File.separatorChar);
    path = ParseUtil.decode(path);
    dir = (new File(path)).getCanonicalFile();
}
 
Example 12
Source File: JarURLConnection.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void parseSpecs(URL url) throws MalformedURLException {
    String spec = url.getFile();

    int separator = spec.indexOf("!/");
    /*
     * REMIND: we don't handle nested JAR URLs
     */
    if (separator == -1) {
        throw new MalformedURLException("no !/ found in url spec:" + spec);
    }

    jarFileURL = new URL(spec.substring(0, separator++));
    /*
     * The url argument may have had a runtime fragment appended, so
     * we need to add a runtime fragment to the jarFileURL to enable
     * runtime versioning when the underlying jar file is opened.
     */
    if ("runtime".equals(url.getRef())) {
        jarFileURL = new URL(jarFileURL, "#runtime");
    }
    entryName = null;

    /* if ! is the last letter of the innerURL, entryName is null */
    if (++separator != spec.length()) {
        entryName = spec.substring(separator, spec.length());
        entryName = ParseUtil.decode (entryName);
    }
}
 
Example 13
Source File: FileURLMapper.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @returns the platform specific path corresponding to the URL
 *  so long as the URL does not contain a hostname in the authority field.
 */

public String getPath () {
    if (path != null) {
        return path;
    }
    String host = url.getHost();
    if (host == null || "".equals(host) || "localhost".equalsIgnoreCase (host)) {
        path = url.getFile();
        path = ParseUtil.decode (path);
    }
    return path;
}
 
Example 14
Source File: URLClassPath.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
FileLoader(URL url) throws IOException {
    super(url);
    if (!"file".equals(url.getProtocol())) {
        throw new IllegalArgumentException("url");
    }
    String path = url.getFile().replace('/', File.separatorChar);
    path = ParseUtil.decode(path);
    dir = (new File(path)).getCanonicalFile();
}
 
Example 15
Source File: URLClassPath.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
JarLoader(URL url, URLStreamHandler jarHandler,
          HashMap<String, Loader> loaderMap,
          AccessControlContext acc)
    throws IOException
{
    super(new URL("jar", "", -1, url + "!/", jarHandler));
    csu = url;
    handler = jarHandler;
    lmap = loaderMap;
    this.acc = acc;

    if (!isOptimizable(url)) {
        ensureOpen();
    } else {
         String fileName = url.getFile();
        if (fileName != null) {
            fileName = ParseUtil.decode(fileName);
            File f = new File(fileName);
            metaIndex = MetaIndex.forJar(f);
            // If the meta index is found but the file is not
            // installed, set metaIndex to null. A typical
            // senario is charsets.jar which won't be installed
            // when the user is running in certain locale environment.
            // The side effect of null metaIndex will cause
            // ensureOpen get called so that IOException is thrown.
            if (metaIndex != null && !f.exists()) {
                metaIndex = null;
            }
        }

        // metaIndex is null when either there is no such jar file
        // entry recorded in meta-index file or such jar file is
        // missing in JRE. See bug 6340399.
        if (metaIndex == null) {
            ensureOpen();
        }
    }
}
 
Example 16
Source File: URLClassPath.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
JarLoader(URL url, URLStreamHandler jarHandler,
          HashMap<String, Loader> loaderMap,
          AccessControlContext acc)
    throws IOException
{
    super(new URL("jar", "", -1, url + "!/", jarHandler));
    csu = url;
    handler = jarHandler;
    lmap = loaderMap;
    this.acc = acc;

    if (!isOptimizable(url)) {
        ensureOpen();
    } else {
         String fileName = url.getFile();
        if (fileName != null) {
            fileName = ParseUtil.decode(fileName);
            File f = new File(fileName);
            metaIndex = MetaIndex.forJar(f);
            // If the meta index is found but the file is not
            // installed, set metaIndex to null. A typical
            // senario is charsets.jar which won't be installed
            // when the user is running in certain locale environment.
            // The side effect of null metaIndex will cause
            // ensureOpen get called so that IOException is thrown.
            if (metaIndex != null && !f.exists()) {
                metaIndex = null;
            }
        }

        // metaIndex is null when either there is no such jar file
        // entry recorded in meta-index file or such jar file is
        // missing in JRE. See bug 6340399.
        if (metaIndex == null) {
            ensureOpen();
        }
    }
}
 
Example 17
Source File: URLJarFile.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private URLJarFile(URL url, URLJarFileCloseController closeController) throws IOException {
    super(ParseUtil.decode(url.getFile()));
    this.closeController = closeController;
}
 
Example 18
Source File: FtpURLConnection.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void decodePath(String path) {
    int i = path.indexOf(";type=");
    if (i >= 0) {
        String s1 = path.substring(i + 6, path.length());
        if ("i".equalsIgnoreCase(s1)) {
            type = BIN;
        }
        if ("a".equalsIgnoreCase(s1)) {
            type = ASCII;
        }
        if ("d".equalsIgnoreCase(s1)) {
            type = DIR;
        }
        path = path.substring(0, i);
    }
    if (path != null && path.length() > 1 &&
            path.charAt(0) == '/') {
        path = path.substring(1);
    }
    if (path == null || path.length() == 0) {
        path = "./";
    }
    if (!path.endsWith("/")) {
        i = path.lastIndexOf('/');
        if (i > 0) {
            filename = path.substring(i + 1, path.length());
            filename = ParseUtil.decode(filename);
            pathname = path.substring(0, i);
        } else {
            filename = ParseUtil.decode(path);
            pathname = null;
        }
    } else {
        pathname = path.substring(0, path.length() - 1);
        filename = null;
    }
    if (pathname != null) {
        fullpath = pathname + "/" + (filename != null ? filename : "");
    } else {
        fullpath = filename;
    }
}
 
Example 19
Source File: URLJarFile.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private URLJarFile(URL url, URLJarFileCloseController closeController) throws IOException {
    super(ParseUtil.decode(url.getFile()));
    this.closeController = closeController;
}
 
Example 20
Source File: URLJarFile.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private URLJarFile(URL url, URLJarFileCloseController closeController, Runtime.Version version)
        throws IOException {
    super(new File(ParseUtil.decode(url.getFile())), true, ZipFile.OPEN_READ, version);
    this.closeController = closeController;
}