Android APIs
public abstract class

URLStreamHandler

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

Class Overview

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

Summary

Public Constructors
URLStreamHandler()
Protected Methods
boolean equals(URL a, URL b)
Returns true if a and b have the same protocol, host, port, file, and reference.
int getDefaultPort()
Returns the default port of the protocol used by the handled URL.
InetAddress getHostAddress(URL url)
Returns the host address of url.
int hashCode(URL url)
Returns the hash code of url.
boolean hostsEqual(URL a, URL b)
Returns true if the hosts of a and b are equal.
URLConnection openConnection(URL u, Proxy proxy)
Establishes a new connection to the resource specified by the URL u using the given proxy.
abstract URLConnection openConnection(URL u)
Establishes a new connection to the resource specified by the URL u.
void parseURL(URL url, String spec, int start, int end)
Parses the clear text URL in str into a URL object.
boolean sameFile(URL a, URL b)
Returns true if a and b have the same protocol, host, port and file.
void setURL(URL u, String protocol, String host, int port, String file, String ref)
This method was deprecated in API level 1. Use setURL(URL, String String, int, String, String, String, String, String) instead.
void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)
Sets the fields of the URL u to the values of the supplied arguments.
String toExternalForm(URL url)
Returns the clear text representation of a given URL using HTTP format.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public URLStreamHandler ()

Added in API level 1

Protected Methods

protected boolean equals (URL a, URL b)

Added in API level 1

Returns true if a and b have the same protocol, host, port, file, and reference.

Parameters
a
b
Returns
boolean

protected int getDefaultPort ()

Added in API level 1

Returns the default port of the protocol used by the handled URL. The default implementation always returns -1.

Returns
int

protected InetAddress getHostAddress (URL url)

Added in API level 1

Returns the host address of url.

Parameters
url
Returns
InetAddress

protected int hashCode (URL url)

Added in API level 1

Returns the hash code of url.

Parameters
url
Returns
int

protected boolean hostsEqual (URL a, URL b)

Added in API level 1

Returns true if the hosts of a and b are equal.

Parameters
a
b
Returns
boolean

protected URLConnection openConnection (URL u, Proxy proxy)

Added in API level 1

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
URLConnection 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.

protected abstract URLConnection openConnection (URL u)

Added in API level 1

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
URLConnection the opened URLConnection to the specified resource.
Throws
IOException if an I/O error occurs during opening the connection.

protected void parseURL (URL url, String spec, int start, int end)

Added in API level 1

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
url the URL to fill in the parsed clear text URL parts.
spec the URL string that is to be parsed.
start the string position from where to begin parsing.
end the string position to stop parsing.

protected boolean sameFile (URL a, URL b)

Added in API level 1

Returns true if a and b have the same protocol, host, port and file.

Parameters
a
b
Returns
boolean

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

Added in API level 1

This method was deprecated in API level 1.
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.

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

Added in API level 1

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

Parameters
u
protocol
host
port
authority
userInfo
path
query
ref

protected String toExternalForm (URL url)

Added in API level 1

Returns the clear text representation of a given URL using HTTP format.

Parameters
url the URL object to be converted.
Returns
String the clear text representation of the specified URL.