You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/04/11 13:33:49 UTC
svn commit: r393189 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/net/URL.java test/java/tests/api/java/net/URLTest.java
Author: gharley
Date: Tue Apr 11 04:33:44 2006
New Revision: 393189
URL: http://svn.apache.org/viewcvs?rev=393189&view=rev
Log:
HARMONY 297 : Adding 5.0 method "toURI()" of java.net.URL class
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java?rev=393189&r1=393188&r2=393189&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java Tue Apr 11 04:33:44 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -624,6 +624,17 @@
*/
public URLConnection openConnection() throws IOException {
return strmHandler.openConnection(this);
+ }
+
+ /**
+ * Creates a URI related with this URL
+ *
+ * @return a URI related to this URL
+ * @throws URISyntaxException
+ * if this URL cannot format into URI
+ */
+ public URI toURI() throws URISyntaxException {
+ return new URI(toExternalForm());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java?rev=393189&r1=393188&r2=393189&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java Tue Apr 11 04:33:44 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
@@ -1049,6 +1050,15 @@
;
}
+
+ /**
+ * @tests java.net.URL#toURL()
+ */
+ public void test_toURI() throws Exception {
+ u = new URL("http://www.apache.org");
+ URI uri = u.toURI();
+ assertTrue(u.equals(uri.toURL()));
+ }
/**
* Sets up the fixture, for example, open a network connection. This method