public abstract class java.net
URLStreamHandler


Show All Login
Java SE 6
  
Details
The abstract class URLStreamHandler is the common superclass for all stream protocol handlers. A stream protocol handler knows how to make a connection for a particular protocol type, such as http, ftp, or gopher.

In most cases, an instance of a URLStreamHandler subclass is not created directly by an application. Rather, the first time a protocol name is encountered when constructing a URL, the appropriate stream protocol handler is automatically loaded.
version1.73, 04/07/06
sinceJDK1.0
See also URL(java.lang.String, java.lang.String, int, java.lang.String)


Constructors
public URLStreamHandler()

Methods
protected boolean equals(URL u1, URL u2) Details
Provides the default equals calculation. May be overidden by handlers for other protocols that have different requirements for equals(). This method requires that none of its arguments is null. This is guaranteed by the fact that it is only called by java.net.URL class.
u1a URL object
u2a URL object
returntrue if the two urls are considered equal, ie. they refer to the same fragment in the same file.
since1.3
protected int hashCode(URL u) Details
Provides the default hash calculation. May be overidden by handlers for other protocols that have different requirements for hashCode calculation.
ua URL object
returnan int suitable for hash table indexing
since1.3
protected boolean hostsEqual(URL u1, URL u2) Details
Compares the host components of two URLs.
u1the URL of the first host to compare
u2the URL of the second host to compare
returntrue if and only if they are equal, false otherwise.
since1.3
abstract protected URLConnection openConnection(URL u) throws IOException Details
Opens a connection to the object referenced by the URL argument. This method should be overridden by a subclass.

If for the handler's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned, and for JAR a JarURLConnection will be returned.
uthe URL that this connects to.
returna URLConnection object for the URL.
ThrowsIOException: if an I/O error occurs while opening the connection.

protected URLConnection openConnection(URL u, Proxy p) throws IOException Details
Same as openConnection(URL), except that the connection will be made through the specified proxy; Protocol handlers that do not support proxying will ignore the proxy parameter and make a normal connection. Calling this method preempts the system's default ProxySelector settings.
uthe URL that this connects to.
pthe proxy through which the connection will be made. If direct connection is desired, Proxy.NO_PROXY should be specified.
returna URLConnection object for the URL.
ThrowsIOException: if an I/O error occurs while opening the connection.
ThrowsIllegalArgumentException: if either u or p is null, or p has the wrong type.
ThrowsUnsupportedOperationException: if the subclass that implements the protocol doesn't support this method.
since1.5
protected void parseURL(URL u, String spec, int start, int limit) Details
Parses the string representation of a URL into a URL object.

If there is any inherited context, then it has already been copied into the URL argument.

The parseURL method of URLStreamHandler parses the string representation as if it were an http specification. Most URL protocol families have a similar parsing. A stream protocol handler for a protocol that has a different syntax must override this routine.
uthe URL to receive the result of parsing the spec.
specthe String representing the URL that must be parsed.
startthe character index at which to begin parsing. This is just past the ':' (if there is one) that specifies the determination of the protocol name.
limitthe character position to stop parsing at. This is the end of the string or the position of the "#" character, if present. All information after the sharp sign indicates an anchor.

protected boolean sameFile(URL u1, URL u2) Details
Compare two urls to see whether they refer to the same file, i.e., having the same protocol, host, port, and path. This method requires that none of its arguments is null. This is guaranteed by the fact that it is only called indirectly by java.net.URL class.
u1a URL object
u2a URL object
returntrue if u1 and u2 refer to the same file
since1.3
protected String toExternalForm(URL u) Details
Converts a URL of a specific protocol to a String.
uthe URL.
returna string representation of the URL argument.

Properties
protected int getDefaultPort() Details
Returns the default port for a URL parsed by this handler. This method is meant to be overidden by handlers with default port numbers.
returnthe default port for a URL parsed by this handler.
since1.3
protected InetAddress getHostAddress(URL u) Details
Get the IP address of our host. An empty host field or a DNS failure will result in a null return.
ua URL object
returnan InetAddress representing the host IP address.
since1.3
protected void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) Details
Sets the fields of the URL argument to the indicated values. Only classes derived from URLStreamHandler are supposed to be able to call the set method on a URL.
uthe URL to modify.
protocolthe protocol name.
hostthe remote host value for the URL.
portthe port on the remote machine.
authoritythe authority part for the URL.
userInfothe userInfo part of the URL.
paththe path component of the URL.
querythe query part for the URL.
refthe reference.
ThrowsSecurityException: if the protocol handler of the URL is different from this one
since1.3
See also set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)
protected void
setURL(URL u, String protocol, String host, int port, String file, String ref)
Details
Sets the fields of the URL argument to the indicated values. Only classes derived from URLStreamHandler are supposed to be able to call the set method on a URL.
uthe URL to modify.
protocolthe protocol name. This value is ignored since 1.2.
hostthe remote host value for the URL.
portthe port on the remote machine.
filethe file.
refthe reference.
ThrowsSecurityException: if the protocol handler of the URL is different from this one
deprecatedUse setURL(URL, String, String, int, String, String, String, String);