dsto.dfc.net.streams.search
Class Handler

java.lang.Object
  extended by java.net.URLStreamHandler
      extended by dsto.dfc.net.streams.search.Handler

public class Handler
extends URLStreamHandler

A URLStreamHandler that acts as a proxy for a set of named URLSearchPath's. This allows use of indirect "search:" URL's which can be resolved dynamically by searching a set of base URL's (defined by a URLSearchPath. The name of the search path is selected via the host part of the URL: eg search://[search_path]/[relative_path].

Version:
$Revision$
Author:
Matthew

Method Summary
static Handler getInstance()
           
static URLSearchPath getSearchPath(String searchPathName)
          The search path registered for a given name.
 URLConnection openConnection(URL url)
           
static void registerHandler()
          Register this class as the handler for the "search:" URL protocol.
static void registerSearchPath(String searchPathName, URLSearchPath searchPath)
          Register a search path for a given name.
 
Methods inherited from class java.net.URLStreamHandler
equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, parseURL, sameFile, setURL, setURL, toExternalForm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Handler getInstance()

registerHandler

public static void registerHandler()
                            throws UnsupportedOperationException
Register this class as the handler for the "search:" URL protocol. May be called more than once.

Throws:
UnsupportedOperationException - if part of the registration fails (probably because another URL factory is already installed). This does not necessarily mean that the handler is not installed at all since two methods are used (factory and registration via the java.protocol.handler.pkgs system property).

getSearchPath

public static URLSearchPath getSearchPath(String searchPathName)
The search path registered for a given name. Null if no path is registered.


registerSearchPath

public static void registerSearchPath(String searchPathName,
                                      URLSearchPath searchPath)
Register a search path for a given name. Auto registers this class as the "search:" protocol handler if necessary.

Parameters:
searchPathName - The search path name. URL's of the form search://[name]/... will be resolved against searchPath.
searchPath - The search path to associated with searchPathName

openConnection

public URLConnection openConnection(URL url)
                             throws IOException
Specified by:
openConnection in class URLStreamHandler
Throws:
IOException


Copyright © 2008 Commonwealth of Australia