Build 1.1_r1 (from source)

java.net
Class URLStreamHandler

java.lang.Object
  extended by java.net.URLStreamHandler

public abstract class URLStreamHandler
extends Object

The abstract class URLStreamHandler is the base for all classes which can handle the communication with a URL object over a particular protocol type.

Since:
Android 1.0

Constructor Summary
URLStreamHandler()
           
 
Method Summary
protected  boolean equals(URL url1, URL url2)
          Compares two URL objects whether they represent the same URL.
protected  int getDefaultPort()
          Returns the default port of the protocol used by the handled URL.
protected  InetAddress getHostAddress(URL url)
          Returns the host address of the given URL.
protected  int hashCode(URL url)
          Returns the hashcode value for the given URL object.
protected  boolean hostsEqual(URL url1, URL url2)
          Compares two URL objects whether they refer to the same host.
protected abstract  URLConnection openConnection(URL u)
          Establishes a new connection to the resource specified by the URL u.
protected  URLConnection openConnection(URL u, Proxy proxy)
          Establishes a new connection to the resource specified by the URL u using the given proxy.
protected  void parseURL(URL u, String str, int start, int end)
          Parses the clear text URL in str into a URL object.
protected  boolean sameFile(URL url1, URL url2)
          Compares two URL objects whether they refer to the same file.
protected  void setURL(URL u, String protocol, String host, int port, String file, String ref)
          Deprecated. use setURL(URL, String String, int, String, String, String, String, String) instead.
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 u to the values of the supplied arguments.
protected  String toExternalForm(URL url)
          Returns the clear text representation of a given URL using HTTP format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLStreamHandler

public URLStreamHandler()
Method Detail

openConnection

protected abstract URLConnection openConnection(URL u)
                                         throws IOException
Establishes a new connection to the resource specified by the URL u. Since different protocols also have unique ways of connecting, it must be overwritten by the subclass.

Parameters:
u - the URL to the resource where a connection has to be opened.
Returns:
the opened URLConnection to the specified resource.
Throws:
IOException - if an I/O error occurs during opening the connection.
Since:
Android 1.0

openConnection

protected URLConnection openConnection(URL u,
                                       Proxy proxy)
                                throws IOException
Establishes a new connection to the resource specified by the URL u using the given proxy. Since different protocols also have unique ways of connecting, it must be overwritten by the subclass.

Parameters:
u - the URL to the resource where a connection has to be opened.
proxy - the proxy that is used to make the connection.
Returns:
the opened URLConnection to the specified resource.
Throws:
IOException - if an I/O error occurs during opening the connection.
IllegalArgumentException - if any argument is null or the type of proxy is wrong.
UnsupportedOperationException - if the protocol handler doesn't support this method.
Since:
Android 1.0

parseURL

protected void parseURL(URL u,
                        String str,
                        int start,
                        int end)
Parses the clear text URL in str into a URL object. URL strings generally have the following format:

http://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 - the URL to fill in the parsed clear text URL parts.
str - the URL string that is to be parsed.
start - the string position from where to begin parsing.
end - the string position to stop parsing.
Since:
Android 1.0
See Also:
toExternalForm(java.net.URL), URL

setURL

@Deprecated
protected void setURL(URL u,
                                 String protocol,
                                 String host,
                                 int port,
                                 String file,
                                 String ref)
Deprecated. use setURL(URL, String String, int, String, String, String, String, String) instead.

Sets the fields of the URL u to the values of the supplied arguments.

Parameters:
u - the non-null URL object to be set.
protocol - the protocol.
host - the host name.
port - the port number.
file - the file component.
ref - the reference.
Since:
Android 1.0

setURL

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 u to the values of the supplied arguments.

Parameters:
u - the non-null URL object to be set.
protocol - the protocol.
host - the host name.
port - the port number.
authority - the authority.
userInfo - the user info.
file - the file component.
query - the query.
ref - the reference.
Since:
Android 1.0

toExternalForm

protected String toExternalForm(URL url)
Returns the clear text representation of a given URL using HTTP format.

Parameters:
url - the URL object to be converted.
Returns:
the clear text representation of the specified URL.
Since:
Android 1.0
See Also:
parseURL(java.net.URL, java.lang.String, int, int), URL.toExternalForm()

equals

protected boolean equals(URL url1,
                         URL url2)
Compares two URL objects whether they represent the same URL. Two URLs are equal if they have the same file, host, port, protocol, query, and reference components.

Parameters:
url1 - the first URL to compare.
url2 - the second URL to compare.
Returns:
true if the URLs are the same, false otherwise.
Since:
Android 1.0
See Also:
hashCode(java.net.URL)

getDefaultPort

protected int getDefaultPort()
Returns the default port of the protocol used by the handled URL. The current implementation returns always -1.

Returns:
the appropriate default port number of the protocol.
Since:
Android 1.0

getHostAddress

protected InetAddress getHostAddress(URL url)
Returns the host address of the given URL.

Parameters:
url - the URL object where to read the host address from.
Returns:
the host address of the specified URL.
Since:
Android 1.0

hashCode

protected int hashCode(URL url)
Returns the hashcode value for the given URL object.

Parameters:
url - the URL to determine the hashcode.
Returns:
the hashcode of the given URL.
Since:
Android 1.0

hostsEqual

protected boolean hostsEqual(URL url1,
                             URL url2)
Compares two URL objects whether they refer to the same host.

Parameters:
url1 - the first URL to be compared.
url2 - the second URL to be compared.
Returns:
true if both URLs refer to the same host, false otherwise.
Since:
Android 1.0

sameFile

protected boolean sameFile(URL url1,
                           URL url2)
Compares two URL objects whether they refer to the same file. In the comparison included are the URL components protocol, host, port and file.

Parameters:
url1 - the first URL to be compared.
url2 - the second URL to be compared.
Returns:
true if both URLs refer to the same file, false otherwise.
Since:
Android 1.0

Build 1.1_r1 (from source)

Please submit a feedback, bug or feature