Build 1.0_r1(from source)

java.net
Class URLStreamHandler

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

public abstract class URLStreamHandler
extends Object

The abstract superclass of all classes that implement Protocol Handler.


Constructor Summary
URLStreamHandler()
           
 
Method Summary
protected  boolean equals(URL url1, URL url2)
          Compares the two urls, and returns true if they represent the same URL.
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.
protected  boolean hostsEqual(URL url1, URL url2)
          Compares the two urls, and returns true if they have the same host components.
protected abstract  URLConnection openConnection(URL u)
          Establishes a connection to the resource specified by URL.
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.
protected  void parseURL(URL u, String str, int start, int end)
          Parse the stringstr into URL using u's context.
protected  boolean sameFile(URL url1, URL url2)
          Returns true if the urls 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)
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
protected  String toExternalForm(URL url)
          Returns the string equivalent of an URL using HTTP parsinf 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 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

openConnection

protected URLConnection openConnection(URL u,
                                       Proxy proxy)
                                throws IOException
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.

parseURL

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
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)

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:
Set

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 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:
Set

toExternalForm

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
See Also:
parseURL(java.net.URL, java.lang.String, int, int), URL.toExternalForm()

equals

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:
hashCode(java.net.URL)

getDefaultPort

protected int getDefaultPort()
Return the default port.


getHostAddress

protected InetAddress getHostAddress(URL url)
Return the InetAddress for the host of the URL, or null.


hashCode

protected int hashCode(URL url)
Returns a hash code for the URL object.

Returns:
int the hashcode for hashtable indexing

hostsEqual

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

sameFile

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

Build 1.0_r1(from source)

Please submit a feedback, bug or feature