Package java.net

Examples of java.net.URI.normalize()


     */
    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

      return normalize("http://"+address);
    }

    try {
      URI uri = new URI(address);
      return uri.normalize().toString();
    } catch (Exception e) {
      return address;
    }

  }
View Full Code Here

  private String normalize(String address)  {
    try {
      URL url  = new URL(address);
      String path = url.getPath();
      URI uri = new URI(encoder.encode(normalizePath(path)));
      String newPath = uri.normalize().toString();
      int index = address.indexOf(path);
      return address.substring(0, index) + newPath + address.substring(index+path.length());
      //      return address.replaceAll(path, newPath);
    } catch (MalformedURLException e) {
      LogService.getInstance().setMessage("APPLICATION", e, address);
View Full Code Here

      return normalize("http://"+address);
    }

    try {
      URI uri = new URI(address);
      return uri.normalize().toString();
    } catch (Exception e) {
      return address;
    }

  }
View Full Code Here

  private String normalize(String address)  {
    try {
      URL url  = new URL(address);
      String path = url.getPath();
      URI uri = new URI(encoder.encode(normalizePath(path)));
      String newPath = uri.normalize().toString();
      int index = address.indexOf(path);
      return address.substring(0, index) + newPath + address.substring(index+path.length());
//      return address.replaceAll(path, newPath);
    } catch (MalformedURLException e) {
      LogService.getInstance().setMessage("APPLICATION", e, address);
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.