Package java.net

Examples of java.net.URI.normalize()


        try {
            URI uri = new URI(arg);
            if ("file".equalsIgnoreCase(uri.getScheme())) {
                if (!uri.isOpaque()) {
                    return uri.normalize().toString();
                }
                return new File("").toURI().resolve(uri.getPath()).toString();
            } else {
                return normalize(arg);
            }
View Full Code Here


            if (importLocationURI.getScheme() != null || parentLocation == null) {
                importUrl = importLocationURI.toURL();
            } else {
                String parentDir = parentLocation.substring(0, parentLocation.lastIndexOf("/"));
                URI uri = new URI(parentDir + "/" + importLocation);
                importUrl = uri.normalize().toURL();
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (importUrl != null) {
View Full Code Here

        try {
            URI uri = new URI(arg);
            if ("file".equalsIgnoreCase(uri.getScheme())) {
                if (!uri.isOpaque()) {
                    return uri.normalize().toString();
                }
                return new File("").toURI().resolve(uri.getPath()).toString();
            } else {
                return normalize(arg);
            }
View Full Code Here

        }

        final URI uri = URI.create(currentContext);
        try {
            final FullXmldbURI xmldbURI = new FullXmldbURI(getXmldbURI());
            xmldbURI.setContext(uri.normalize().getRawPath());
            return xmldbURI;

        } catch (final URISyntaxException e) {
            throw new IllegalArgumentException("Invalid URI: " + e.getMessage());
        }
View Full Code Here

        int bang = baseInjarPath.indexOf('!');
        String front = baseInjarPath.substring(0, bang + 1); // out to the !
        String back = baseInjarPath.substring(bang + 1); // after the bang
        /* we can pretend that this is a file path */
        URI trickyUri = new URI("file:" + back + "/../" + relative);
        String resolved = trickyUri.normalize().toString();
        return front + resolved.substring(5); // remove file:

    }

    public InputStream getTestCase() {
View Full Code Here

     * place to store the output from a number of map-reduce tasks.
     */
    public static String makeStoreTmpPath(String orig) {
        Path path = new Path(orig);
        URI uri = path.toUri();
        uri.normalize();

        String pathStr = uri.getPath();
        if (path.isAbsolute()) {
            return new Path("abs"+pathStr).toString();
        } else {
View Full Code Here

                "/a/..b/c", "/a/b..c/d", "", "a", "a/b", "a/b/c", "../", "",
                "..", "../g", "b/c/g", "../c/e", "../c/", };

        for (int i = 0; i < normalizeData.length; i++) {
            URI test = new URI(normalizeData[i]);
            String result = test.normalize().toString();
            assertEquals("Normalized incorrectly, ", normalizeResults[i],
                    result.toString());
        }
    }
View Full Code Here

     * @tests java.net.URI#normalize()
     */
    public void test_normalize2() throws URISyntaxException {
        URI uri1 = null, uri2 = null;
        uri1 = new URI("file:/D:/one/two/../../three");
        uri2 = uri1.normalize();

        assertEquals("Normalized to incorrect URI", "file:/D:/three", uri2
                .toString());
        assertTrue("Resolved URI is not absolute", uri2.isAbsolute());
        assertFalse("Resolved URI is opaque", uri2.isOpaque());
View Full Code Here

     */
    public void test_normalize3() throws URISyntaxException {
        // return same URI if it has a normalized path already
        URI uri1 = null, uri2 = null;
        uri1 = new URI("http://host/D:/one/two/three");
        uri2 = uri1.normalize();
        assertSame("Failed to return same URI after normalization", uri1, uri2);

        // try with empty path
        uri1 = new URI("http", "host", null, "fragment");
        uri2 = uri1.normalize();
View Full Code Here

        uri2 = uri1.normalize();
        assertSame("Failed to return same URI after normalization", uri1, uri2);

        // try with empty path
        uri1 = new URI("http", "host", null, "fragment");
        uri2 = uri1.normalize();
        assertSame("Failed to return same URI after normalization", uri1, uri2);
    }

    /**
     * @tests java.net.URI#parseServerAuthority()
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.