加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090228082524/http://developer.android.com:80/reference/java/net/URLStreamHandler.html
public abstract class

URLStreamHandler

extends Object
java.lang.Object
   ↳ java.net.URLStreamHandler

Class Overview

The abstract superclass of all classes that implement Protocol Handler.

Summary

Public Constructors
URLStreamHandler()
Protected Methods
boolean equals(URL url1, URL url2)
Compares the two urls, and returns true if they represent the same URL.
int getDefaultPort()
Return the default port.
InetAddress getHostAddress(URL url)
Return the InetAddress for the host of the URL, or null.
int hashCode(URL url)
Returns a hash code for the URL object.
boolean hostsEqual(URL url1, URL url2)
Compares the two urls, and returns true if they have the same host components.
URLConnection openConnection(URL u, Proxy proxy)
The method is the same as openConnection(URL u) except that it uses the proxy to establish a connection to the URL.
abstract URLConnection openConnection(URL u)
Establishes a connection to the resource specified by URL.
void parseURL(URL u, String str, int start, int end)
Parse the stringstr into URL using u's context.
boolean sameFile(URL url1, URL url2)
Returns true if the urls refer to the same file.
void setURL(URL u, String protocol, String host, int port, String file, String ref)
This method is deprecated. use setURL(URL, String String, int, String, String, String, String, String)
void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String file, String query, String ref)
Sets the fields of the URL with the supplied arguments
String toExternalForm(URL url)
Returns the string equivalent of an URL using HTTP parsinf format.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public URLStreamHandler ()

Protected Methods

protected boolean equals (URL url1, URL url2)

Compares the two urls, and returns true if they represent the same URL. Two URLs are equal if they have the same file, host, port, protocol, query, and ref components.

Parameters
url1 URL the first URL to compare
url2 URL the second URL to compare
Returns
  • true if the URLs are the same false if the URLs are different
See Also

protected int getDefaultPort ()

Return the default port.

protected InetAddress getHostAddress (URL url)

Return the InetAddress for the host of the URL, or null.

protected int hashCode (URL url)

Returns a hash code for the URL object.

Returns
  • int the hashcode for hashtable indexing

protected boolean hostsEqual (URL url1, URL url2)

Compares the two urls, and returns true if they have the same host components.

Returns
  • true if the hosts of the URLs are the same false if the hosts are different

protected URLConnection openConnection (URL u, Proxy proxy)

The method is the same as openConnection(URL u) except that it uses the proxy to establish a connection to the URL. Since different protocols may have different ways of connecting, it must be overwritten by the subclass.

Parameters
u java.net.URL
proxy the proxy which is used to make the connection
Returns
  • java.net.URLConnection
Throws
IOException thrown if an IO error occurs during connection establishment
IllegalArgumentException if any argument is null or the type of proxy is wrong.
UnsupportedOperationException if the protocol handler doesn't support this method.

protected abstract URLConnection openConnection (URL u)

Establishes a connection to the resource specified by URL. Since different protocols may have unique ways of connecting, it must be overwritten by the subclass.

Parameters
u java.net.URL
Returns
  • java.net.URLConnection
Throws
IOException thrown if an IO error occurs during connection establishment

protected void parseURL (URL u, String str, int start, int end)

Parse the stringstr into URL using u's context. URL strings generally have the following format:

//www.company.com/java/file1.java#reference
The string is parsed in HTTP format. If the protocol has a different URL format this method must be overridden.

Parameters
u java.net.URL The URL to receive parsed values.
str java.lang.String The string URL spec from which u is derived
start int The index in the string from which to begin parsing
end int The index to stop parsing

protected boolean sameFile (URL url1, URL url2)

Returns true if the urls refer to the same file. Compares the protocol, host, port and file components.

Returns
  • boolean true if the same resource, false otherwise

protected void setURL (URL u, String protocol, String host, int port, String file, String ref)

This method is deprecated.use setURL(URL, String String, int, String, String, String, String, String)

Sets the fields of the URL with the supplied arguments

Parameters
u java.net.URL The non-null URL to be set
protocol java.lang.String The protocol
host java.lang.String The host name
port int The port number
file java.lang.String The file component
ref java.lang.String The reference
See Also

protected void setURL (URL u, String protocol, String host, int port, String authority, String userInfo, String file, String query, String ref)

Sets the fields of the URL with the supplied arguments

Parameters
u java.net.URL The non-null URL to be set
protocol java.lang.String The protocol
host java.lang.String The host name
port int The port number
authority java.lang.String The authority
userInfo java.lang.String The user info
file java.lang.String The file component
query java.lang.String The query
ref java.lang.String The reference
See Also

protected String toExternalForm (URL url)

Returns the string equivalent of an URL using HTTP parsinf format.

Parameters
url java.net.URL the url object to be processed
Returns
  • java.lang.String the string representation of this URL