218 |
} |
} |
219 |
catch (IOException e) |
catch (IOException e) |
220 |
{ |
{ |
221 |
|
// Do nothing. |
222 |
} |
} |
223 |
} |
} |
224 |
|
|
244 |
setURL(url, url.getProtocol(), host, port, file, ref); |
setURL(url, url.getProtocol(), host, port, file, ref); |
245 |
} |
} |
246 |
|
|
247 |
|
/* |
248 |
|
* Canonicalize a filename. |
249 |
|
*/ |
250 |
private static String canonicalizeFilename(String file) |
private static String canonicalizeFilename(String file) |
251 |
{ |
{ |
252 |
// XXX - GNU Classpath has an implementation that might be more appropriate |
// XXX - GNU Classpath has an implementation that might be more appropriate |
279 |
* @param url1 The first url |
* @param url1 The first url |
280 |
* @param url2 The second url to compare with the first |
* @param url2 The second url to compare with the first |
281 |
* |
* |
282 |
|
* @return True if both URLs point to the same file, false otherwise. |
283 |
|
* |
284 |
* @specnote Now protected |
* @specnote Now protected |
285 |
*/ |
*/ |
286 |
protected boolean sameFile(URL url1, URL url2) |
protected boolean sameFile(URL url1, URL url2) |
369 |
* |
* |
370 |
* @param url1 An URL object |
* @param url1 An URL object |
371 |
* @param url2 An URL object |
* @param url2 An URL object |
372 |
|
* |
373 |
|
* @return True if both given URLs are equal, false otherwise. |
374 |
*/ |
*/ |
375 |
protected boolean equals (URL url1, URL url2) |
protected boolean equals (URL url1, URL url2) |
376 |
{ |
{ |
403 |
/** |
/** |
404 |
* Compares the host components of two URLs. |
* Compares the host components of two URLs. |
405 |
* |
* |
406 |
|
* @param url1 The first URL. |
407 |
|
* @param url2 The second URL. |
408 |
|
* |
409 |
|
* @return True if both URLs contain the same host. |
410 |
|
* |
411 |
* @exception UnknownHostException If an unknown host is found |
* @exception UnknownHostException If an unknown host is found |
412 |
*/ |
*/ |
413 |
protected boolean hostsEqual (URL url1, URL url2) |
protected boolean hostsEqual (URL url1, URL url2) |
430 |
/** |
/** |
431 |
* Get the IP address of our host. An empty host field or a DNS failure will |
* Get the IP address of our host. An empty host field or a DNS failure will |
432 |
* result in a null return. |
* result in a null return. |
433 |
|
* |
434 |
|
* @param url The URL to return the host address for. |
435 |
|
* |
436 |
|
* @return The address of the hostname in url. |
437 |
*/ |
*/ |
438 |
protected InetAddress getHostAddress (URL url) |
protected InetAddress getHostAddress (URL url) |
439 |
{ |
{ |
455 |
/** |
/** |
456 |
* Returns the default port for a URL parsed by this handler. This method is |
* Returns the default port for a URL parsed by this handler. This method is |
457 |
* meant to be overidden by handlers with default port numbers. |
* meant to be overidden by handlers with default port numbers. |
458 |
|
* |
459 |
|
* @return The default port number. |
460 |
*/ |
*/ |
461 |
protected int getDefaultPort () |
protected int getDefaultPort () |
462 |
{ |
{ |
466 |
/** |
/** |
467 |
* Provides the default hash calculation. May be overidden by handlers for |
* Provides the default hash calculation. May be overidden by handlers for |
468 |
* other protocols that have different requirements for hashCode calculation. |
* other protocols that have different requirements for hashCode calculation. |
469 |
|
* |
470 |
|
* @param url The URL to calc the hashcode for. |
471 |
|
* |
472 |
|
* @return The hashcode for the given URL. |
473 |
*/ |
*/ |
474 |
protected int hashCode (URL url) |
protected int hashCode (URL url) |
475 |
{ |
{ |
485 |
* that have a different syntax should override this method |
* that have a different syntax should override this method |
486 |
* |
* |
487 |
* @param url The URL object to convert |
* @param url The URL object to convert |
488 |
|
* |
489 |
|
* @return A string representation of the url |
490 |
*/ |
*/ |
491 |
protected String toExternalForm(URL u) |
protected String toExternalForm(URL u) |
492 |
{ |
{ |
523 |
if (user != null && !"".equals(user)) |
if (user != null && !"".equals(user)) |
524 |
sb.append(user).append('@'); |
sb.append(user).append('@'); |
525 |
sb.append(host); |
sb.append(host); |
526 |
|
|
527 |
// Append port if port was in URL spec. |
// Append port if port was in URL spec. |
528 |
if (port >= 0) |
if (port >= 0) |
529 |
sb.append(':').append(port); |
sb.append(':').append(port); |
530 |
} |
} |
531 |
|
|