java.net
public
abstract
class
java.net.URLStreamHandler
The abstract superclass of all classes that implement Protocol Handler.
Summary
Public Constructors
Protected Methods
|
|
|
|
|
boolean |
equals(URL url1, URL url2) |
|
|
|
|
|
int |
getDefaultPort() |
|
|
|
|
|
InetAddress |
getHostAddress(URL url) |
|
|
|
|
|
int |
hashCode(URL url) |
|
|
|
|
|
boolean |
hostsEqual(URL url1, URL url2) |
|
|
|
|
|
URLConnection |
openConnection(URL u, Proxy proxy) |
abstract |
|
|
|
|
URLConnection |
openConnection(URL u) |
|
|
|
|
|
void |
parseURL(URL u, String str, int start, int end) |
|
|
|
|
|
boolean |
sameFile(URL url1, URL url2) |
|
|
|
|
|
void |
setURL(URL u, String protocol, String host, int port, String file, String ref) |
|
|
|
|
|
void |
setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String file, String query, String ref) |
|
|
|
|
|
String |
toExternalForm(URL url) |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
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
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
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 |
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.
Throws
IOException
| thrown if an IO error occurs during connection
establishment
|
protected
void
parseURL(URL u, String str, int start, int end)
Parse the
string
str 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 |
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 |
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