DthingApi
Protected Member Functions | List of all members
java.net.http.URLStreamHandler Class Referenceabstract

Protected Member Functions

abstract URLConnection openConnection (URL u) throws IOException
 
void parseURL (URL u, String spec, int start, int limit)
 
int getDefaultPort ()
 
boolean equals (URL u1, URL u2)
 
int hashCode (URL u)
 
boolean sameFile (URL u1, URL u2)
 
synchronized InetAddress getHostAddress (URL u)
 
boolean hostsEqual (URL u1, URL u2)
 
String toExternalForm (URL u)
 
void setURL (URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref)
 

Detailed Description

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.

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.

Author
James Gosling
Version
1.48 10/27/00
See also
java.net.URL::URL(java.lang.String, java.lang.String, int, java.lang.String)
Since
JDK1.0

Member Function Documentation

◆ equals()

boolean java.net.http.URLStreamHandler.equals ( URL  u1,
URL  u2 
)
inlineprotected

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.

Parameters
u1a URL object
u2a URL object
Returns
true if the two urls are considered equal, ie. they refer to the same fragment in the same file.

◆ getDefaultPort()

int java.net.http.URLStreamHandler.getDefaultPort ( )
inlineprotected

Returns the default port for a URL parsed by this handler. This method is meant to be overidden by handlers with default port numbers.

Returns
the default port for a URL parsed by this handler.

◆ getHostAddress()

synchronized InetAddress java.net.http.URLStreamHandler.getHostAddress ( URL  u)
inlineprotected

Get the IP address of our host. An empty host field or a DNS failure will result in a null return.

Parameters
ua URL object
Returns
an InetAddress representing the host IP address.

◆ hashCode()

int java.net.http.URLStreamHandler.hashCode ( URL  u)
inlineprotected

Provides the default hash calculation. May be overidden by handlers for other protocols that have different requirements for hashCode calculation.

Parameters
ua URL object
Returns
an int suitable for hash table indexing

◆ hostsEqual()

boolean java.net.http.URLStreamHandler.hostsEqual ( URL  u1,
URL  u2 
)
inlineprotected

Compares the host components of two URLs.

Parameters
u1the URL of the first host to compare
u2the URL of the second host to compare
Returns
true if and only if they are equal, false otherwise.

◆ openConnection()

abstract URLConnection java.net.http.URLStreamHandler.openConnection ( URL  u) throws IOException
abstractprotected

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. NOTE: java.net.HttpURLConnection is found in J2ME CDC profiles such as J2ME Foundation Profile.

Parameters
uthe URL that this connects to.
Returns
a URLConnection object for the URL.
Exceptions
IOExceptionif an I/O error occurs while opening the connection.

◆ parseURL()

void java.net.http.URLStreamHandler.parseURL ( URL  u,
String  spec,
int  start,
int  limit 
)
inlineprotected

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.

Parameters
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 "<code>#</code>" character, if present. All information after the sharp sign indicates an anchor.

◆ sameFile()

boolean java.net.http.URLStreamHandler.sameFile ( URL  u1,
URL  u2 
)
inlineprotected

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.

Parameters
u1a URL object
u2a URL object
Returns
true if u1 and u2 refer to the same file

◆ setURL()

void java.net.http.URLStreamHandler.setURL ( URL  u,
String  protocol,
String  host,
int  port,
String  authority,
String  userInfo,
String  path,
String  query,
String  ref 
)
inlineprotected

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.

Parameters
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.
Exceptions
SecurityExceptionif the protocol handler of the URL is different from this one
See also
java.net.URL::set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)

◆ toExternalForm()

String java.net.http.URLStreamHandler.toExternalForm ( URL  u)
inlineprotected

Converts a URL of a specific protocol to a String.

Parameters
uthe URL.
Returns
a string representation of the URL argument.

The documentation for this class was generated from the following file: