< prev index next >

src/java.base/share/classes/java/net/URLStreamHandler.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

*** 233,243 **** throw new IllegalArgumentException("Invalid port number :" + port); start = i; // If the authority is defined then the path is defined by the // spec only; See RFC 2396 Section 5.2.4. ! if (authority != null && authority.length() > 0) path = ""; } if (host == null) { host = ""; --- 233,243 ---- throw new IllegalArgumentException("Invalid port number :" + port); start = i; // If the authority is defined then the path is defined by the // spec only; See RFC 2396 Section 5.2.4. ! if (authority != null && !authority.isEmpty()) path = ""; } if (host == null) { host = "";
*** 245,255 **** // Parse the file path if any if (start < limit) { if (spec.charAt(start) == '/') { path = spec.substring(start, limit); ! } else if (path != null && path.length() > 0) { isRelPath = true; int ind = path.lastIndexOf('/'); String separator = ""; if (ind == -1 && authority != null) separator = "/"; --- 245,255 ---- // Parse the file path if any if (start < limit) { if (spec.charAt(start) == '/') { path = spec.substring(start, limit); ! } else if (path != null && !path.isEmpty()) { isRelPath = true; int ind = path.lastIndexOf('/'); String separator = ""; if (ind == -1 && authority != null) separator = "/";
*** 481,495 **** */ protected String toExternalForm(URL u) { String s; return u.getProtocol() + ':' ! + (((s = u.getAuthority()) != null && s.length() > 0) ? "//" + s : "") ! + (((s = u.getPath()) != null) ? s : "") ! + (((s = u.getQuery()) != null) ? '?' + s : "") ! + (((s = u.getRef()) != null) ? '#' + s : ""); } /** * Sets the fields of the {@code URL} argument to the indicated values. * Only classes derived from URLStreamHandler are able --- 481,495 ---- */ protected String toExternalForm(URL u) { String s; return u.getProtocol() + ':' ! + ((s = u.getAuthority()) != null && !s.isEmpty() ? "//" + s : "") ! + ((s = u.getPath()) != null ? s : "") ! + ((s = u.getQuery()) != null ? '?' + s : "") ! + ((s = u.getRef()) != null ? '#' + s : ""); } /** * Sets the fields of the {@code URL} argument to the indicated values. * Only classes derived from URLStreamHandler are able
*** 542,552 **** * Only old URL handlers call this, so assume that the host * field might contain "user:passwd@host". Fix as necessary. */ String authority = null; String userInfo = null; ! if (host != null && host.length() != 0) { authority = (port == -1) ? host : host + ":" + port; int at = host.lastIndexOf('@'); if (at != -1) { userInfo = host.substring(0, at); host = host.substring(at+1); --- 542,552 ---- * Only old URL handlers call this, so assume that the host * field might contain "user:passwd@host". Fix as necessary. */ String authority = null; String userInfo = null; ! if (host != null && !host.isEmpty()) { authority = (port == -1) ? host : host + ":" + port; int at = host.lastIndexOf('@'); if (at != -1) { userInfo = host.substring(0, at); host = host.substring(at+1);
< prev index next >