changeset 39057:3ad96930e68b

8159745: Remove java.net.Parts Reviewed-by: alanb, chegar
author redestad
date Fri, 17 Jun 2016 16:18:37 +0200
parents d99e63b6d962
children b1ab5b47d979
files jdk/src/java.base/share/classes/java/net/URL.java
diffstat 1 files changed, 8 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/net/URL.java	Tue Jun 14 10:44:59 2016 +0200
+++ b/jdk/src/java.base/share/classes/java/net/URL.java	Fri Jun 17 16:18:37 2016 +0200
@@ -428,16 +428,18 @@
             authority = (port == -1) ? host : host + ":" + port;
         }
 
-        Parts parts = new Parts(file);
-        path = parts.getPath();
-        query = parts.getQuery();
-
-        if (query != null) {
+        int index = file.indexOf('#');
+        this.ref = index < 0 ? null : file.substring(index + 1);
+        file = index < 0 ? file : file.substring(0, index);
+        int q = file.lastIndexOf('?');
+        if (q != -1) {
+            this.query = file.substring(q + 1);
+            this.path = file.substring(0, q);
             this.file = path + "?" + query;
         } else {
+            this.path = file;
             this.file = path;
         }
-        ref = parts.getRef();
 
         // Note: we don't do validation of the URL here. Too risky to change
         // right now, but worth considering for future reference. -br
@@ -1617,35 +1619,6 @@
     }
 }
 
-class Parts {
-    String path, query, ref;
-
-    Parts(String file) {
-        int ind = file.indexOf('#');
-        ref = ind < 0 ? null: file.substring(ind + 1);
-        file = ind < 0 ? file: file.substring(0, ind);
-        int q = file.lastIndexOf('?');
-        if (q != -1) {
-            query = file.substring(q+1);
-            path = file.substring(0, q);
-        } else {
-            path = file;
-        }
-    }
-
-    String getPath() {
-        return path;
-    }
-
-    String getQuery() {
-        return query;
-    }
-
-    String getRef() {
-        return ref;
-    }
-}
-
 final class UrlDeserializedState {
     private final String protocol;
     private final String host;