Package java.net

Examples of java.net.URI.normalize()


     * 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

            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

        // make an absolute uri
        URI referenceURI = reference.toURI();

        // make an absolute uri from the reference + the target
        URI result = referenceURI.resolve(target);
        result.normalize();

        // check that the resulting uri is absolute
        if( result.isAbsolute()==false )
        {
            // if not, return null;
View Full Code Here

        URI referenceURI = reference.toURI();
        URI targetURI = target.toURI();

        // create a relative uri from two absolute uris
        URI result = referenceURI.relativize(targetURI);
        result.normalize();

        // if the resulting uri still absolute, return null
        if( result.isAbsolute() )
        {
            return null;
View Full Code Here

    path = WorkspaceController.getCurrentProject().getProjectHome().getPath();
    URL ret = new URL("file", null,  path + url.getPath());
    try {
      URI uri = ret.toURI();
      if(uri.getPath().startsWith("//")) {
        uri = uri.normalize();
        uri = new URI(uri.getScheme(), null, "///"+uri.getPath(), null);
      }
      else {
        uri = uri.normalize();
      }
View Full Code Here

      if(uri.getPath().startsWith("//")) {
        uri = uri.normalize();
        uri = new URI(uri.getScheme(), null, "///"+uri.getPath(), null);
      }
      else {
        uri = uri.normalize();
      }
      ret = uri.toURL();
    }
    catch (URISyntaxException e) {
      throw new IOException(e.getMessage());
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.