equal
deleted
inserted
replaced
233 throw new IllegalArgumentException("Invalid port number :" + |
233 throw new IllegalArgumentException("Invalid port number :" + |
234 port); |
234 port); |
235 start = i; |
235 start = i; |
236 // If the authority is defined then the path is defined by the |
236 // If the authority is defined then the path is defined by the |
237 // spec only; See RFC 2396 Section 5.2.4. |
237 // spec only; See RFC 2396 Section 5.2.4. |
238 if (authority != null && authority.length() > 0) |
238 if (authority != null && !authority.isEmpty()) |
239 path = ""; |
239 path = ""; |
240 } |
240 } |
241 |
241 |
242 if (host == null) { |
242 if (host == null) { |
243 host = ""; |
243 host = ""; |
245 |
245 |
246 // Parse the file path if any |
246 // Parse the file path if any |
247 if (start < limit) { |
247 if (start < limit) { |
248 if (spec.charAt(start) == '/') { |
248 if (spec.charAt(start) == '/') { |
249 path = spec.substring(start, limit); |
249 path = spec.substring(start, limit); |
250 } else if (path != null && path.length() > 0) { |
250 } else if (path != null && !path.isEmpty()) { |
251 isRelPath = true; |
251 isRelPath = true; |
252 int ind = path.lastIndexOf('/'); |
252 int ind = path.lastIndexOf('/'); |
253 String separator = ""; |
253 String separator = ""; |
254 if (ind == -1 && authority != null) |
254 if (ind == -1 && authority != null) |
255 separator = "/"; |
255 separator = "/"; |
481 */ |
481 */ |
482 protected String toExternalForm(URL u) { |
482 protected String toExternalForm(URL u) { |
483 String s; |
483 String s; |
484 return u.getProtocol() |
484 return u.getProtocol() |
485 + ':' |
485 + ':' |
486 + (((s = u.getAuthority()) != null && s.length() > 0) |
486 + ((s = u.getAuthority()) != null && !s.isEmpty() |
487 ? "//" + s : "") |
487 ? "//" + s : "") |
488 + (((s = u.getPath()) != null) ? s : "") |
488 + ((s = u.getPath()) != null ? s : "") |
489 + (((s = u.getQuery()) != null) ? '?' + s : "") |
489 + ((s = u.getQuery()) != null ? '?' + s : "") |
490 + (((s = u.getRef()) != null) ? '#' + s : ""); |
490 + ((s = u.getRef()) != null ? '#' + s : ""); |
491 } |
491 } |
492 |
492 |
493 /** |
493 /** |
494 * Sets the fields of the {@code URL} argument to the indicated values. |
494 * Sets the fields of the {@code URL} argument to the indicated values. |
495 * Only classes derived from URLStreamHandler are able |
495 * Only classes derived from URLStreamHandler are able |
542 * Only old URL handlers call this, so assume that the host |
542 * Only old URL handlers call this, so assume that the host |
543 * field might contain "user:passwd@host". Fix as necessary. |
543 * field might contain "user:passwd@host". Fix as necessary. |
544 */ |
544 */ |
545 String authority = null; |
545 String authority = null; |
546 String userInfo = null; |
546 String userInfo = null; |
547 if (host != null && host.length() != 0) { |
547 if (host != null && !host.isEmpty()) { |
548 authority = (port == -1) ? host : host + ":" + port; |
548 authority = (port == -1) ? host : host + ":" + port; |
549 int at = host.lastIndexOf('@'); |
549 int at = host.lastIndexOf('@'); |
550 if (at != -1) { |
550 if (at != -1) { |
551 userInfo = host.substring(0, at); |
551 userInfo = host.substring(0, at); |
552 host = host.substring(at+1); |
552 host = host.substring(at+1); |