Search in sources :

Example 1 with ParseUtil

use of sun.net.www.ParseUtil in project jdk8u_jdk by JetBrains.

the class Handler method parseURL.

@Override
@SuppressWarnings("deprecation")
protected void parseURL(URL url, String spec, int start, int limit) {
    String file = null;
    String ref = null;
    // first figure out if there is an anchor
    int refPos = spec.indexOf('#', limit);
    boolean refOnly = refPos == start;
    if (refPos > -1) {
        ref = spec.substring(refPos + 1, spec.length());
        if (refOnly) {
            file = url.getFile();
        }
    }
    // then figure out if the spec is
    // 1. absolute (jar:)
    // 2. relative (i.e. url + foo/bar/baz.ext)
    // 3. anchor-only (i.e. url + #foo), which we already did (refOnly)
    boolean absoluteSpec = false;
    if (spec.length() >= 4) {
        absoluteSpec = spec.substring(0, 4).equalsIgnoreCase("jar:");
    }
    spec = spec.substring(start, limit);
    if (absoluteSpec) {
        file = parseAbsoluteSpec(spec);
    } else if (!refOnly) {
        file = parseContextSpec(url, spec);
        // Canonize the result after the bangslash
        int bangSlash = indexOfBangSlash(file);
        String toBangSlash = file.substring(0, bangSlash);
        String afterBangSlash = file.substring(bangSlash);
        sun.net.www.ParseUtil canonizer = new ParseUtil();
        afterBangSlash = canonizer.canonizeString(afterBangSlash);
        file = toBangSlash + afterBangSlash;
    }
    setURL(url, "jar", "", -1, file, ref);
}
Also used : ParseUtil(sun.net.www.ParseUtil) java.net(java.net)

Example 2 with ParseUtil

use of sun.net.www.ParseUtil in project Bytecoder by mirkosertic.

the class Handler method parseURL.

@Override
@SuppressWarnings("deprecation")
protected void parseURL(URL url, String spec, int start, int limit) {
    String file = null;
    String ref = null;
    // first figure out if there is an anchor
    int refPos = spec.indexOf('#', limit);
    boolean refOnly = refPos == start;
    if (refPos > -1) {
        ref = spec.substring(refPos + 1, spec.length());
        if (refOnly) {
            file = url.getFile();
        }
    }
    // then figure out if the spec is
    // 1. absolute (jar:)
    // 2. relative (i.e. url + foo/bar/baz.ext)
    // 3. anchor-only (i.e. url + #foo), which we already did (refOnly)
    boolean absoluteSpec = false;
    if (spec.length() >= 4) {
        absoluteSpec = spec.substring(0, 4).equalsIgnoreCase("jar:");
    }
    spec = spec.substring(start, limit);
    if (absoluteSpec) {
        file = parseAbsoluteSpec(spec);
    } else if (!refOnly) {
        file = parseContextSpec(url, spec);
        // Canonize the result after the bangslash
        int bangSlash = indexOfBangSlash(file);
        String toBangSlash = file.substring(0, bangSlash);
        String afterBangSlash = file.substring(bangSlash);
        sun.net.www.ParseUtil canonizer = new ParseUtil();
        afterBangSlash = canonizer.canonizeString(afterBangSlash);
        file = toBangSlash + afterBangSlash;
    }
    setURL(url, "jar", "", -1, file, ref);
}
Also used : ParseUtil(sun.net.www.ParseUtil) java.net(java.net)

Aggregations

java.net (java.net)2 ParseUtil (sun.net.www.ParseUtil)2