java.net
Class URLStreamHandler

java.lang.Object
  |
  +--java.net.URLStreamHandler

public abstract class URLStreamHandler
extends Object

Abstract class for URL stream openers. Subclasses of this class know how to create streams for particular protocol types.


Constructor Summary
URLStreamHandler()
           
 
Method Summary
protected abstract  URLConnection openConnection(URL u)
          Opens an input stream to the object referenced by the URL.
protected  void parseURL(URL u, String spec, int start, int limit)
          This method is called to parse the string spec into URL u.
protected  void setURL(URL u, String protocol, String host, int port, String file, String ref)
          Calls the (protected) set method out of the URL given.
protected  String toExternalForm(URL u)
          Reverses the parsing of the URL.
 
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
Opens an input stream to the object referenced by the URL. This method should be overridden by a subclass.

Parameters:
u - the URL that this connects to
IOException

parseURL

protected void parseURL(URL u,
                        String spec,
                        int start,
                        int limit)
This method is called to parse the string spec into URL u. If there is any inherited context then it has already been copied into u. The parameters start and limit refer to the range of characters in spec that should be parsed. The default method uses parsing rules that match the http spec, which most URL protocol families follow. If you are writing a protocol handler that has a different syntax, override this routine.

Parameters:
u - the URL to receive the result of parsing the spec
spec - the URL string to parse
start - the character position to start parsing at. This is just past the ':' (if there is one).
limit - the character position to stop parsing at. This is the end of the string or the position of the "#" character if present (the "#" reference syntax is protocol independent).

toExternalForm

protected String toExternalForm(URL u)
Reverses the parsing of the URL. This should probably be overridden if you override parseURL().

Parameters:
u - the URL
Returns:
the textual representation of the fully qualified URL (i.e. after the context and canonicalization have been applied).

setURL

protected void setURL(URL u,
                      String protocol,
                      String host,
                      int port,
                      String file,
                      String ref)
Calls the (protected) set method out of the URL given. Only classes derived from URLStreamHandler are supposed to be able to call the set() method on a URL.

See Also:
URL.set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)