org.foray.common.url
Class UniversalProtocolRegistration

java.lang.Object
  extended by org.foray.common.url.UniversalProtocolRegistration
All Implemented Interfaces:
ProtocolRegistrationStrategy

public class UniversalProtocolRegistration
extends Object
implements ProtocolRegistrationStrategy

Registers URL protocols in a universal manner, attempting first to register using a URLStreamHandlerFactory, then using the Java properties method as a fallback.

See Also:
which registers using only the {@link URLStreamHandlerFactory} scheme., which registers using only the Java properties scheme.

Method Summary
 URLStreamHandler getURLStreamHandler(String protocol)
          Finds the registered URLStreamHandler for a given protocol.
 void registerProtocolHandler(String protocol, URLStreamHandler handler)
          Registers a URLStreamHandler for the given protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerProtocolHandler

public void registerProtocolHandler(String protocol,
                                    URLStreamHandler handler)
Description copied from interface: ProtocolRegistrationStrategy
Registers a URLStreamHandler for the given protocol. When implemented, this method should be synchronized. If a handler already exists for the given protocol, this method does nothing.

Specified by:
registerProtocolHandler in interface ProtocolRegistrationStrategy
Parameters:
protocol - The protocol to be registered.
handler - The URLStreamHandler instance which should be used for URLs whose protocol is protocol.

getURLStreamHandler

public URLStreamHandler getURLStreamHandler(String protocol)
Description copied from interface: ProtocolRegistrationStrategy
Finds the registered URLStreamHandler for a given protocol.

Specified by:
getURLStreamHandler in interface ProtocolRegistrationStrategy
Parameters:
protocol - The protocol for which a URLStreamHandler is desired.
Returns:
The URLStreamHandler registered with this registration scheme, or null if the protocol has not been registered.


Copyright © 2017. All rights reserved.