Example usage for java.net URLStreamHandlerFactory createURLStreamHandler

List of usage examples for java.net URLStreamHandlerFactory createURLStreamHandler

Introduction

In this page you can find the example usage for java.net URLStreamHandlerFactory createURLStreamHandler.

Prototype

URLStreamHandler createURLStreamHandler(String protocol);

Source Link

Document

Creates a new URLStreamHandler instance with the specified protocol.

Usage

From source file:net.sf.jasperreports.engine.util.JRResourcesUtil.java

/**
 * Returns an URL stream handler for an URL specified as a <code>String</code>.
 * //  www .j av a2 s  .  co m
 * @param spec the <code>String</code> to parse as an URL
 * @param urlHandlerFact an URL stream handler factory
 * @return an URL stream handler if one was found for the protocol of the URL
 */
public static URLStreamHandler getURLHandler(String spec, URLStreamHandlerFactory urlHandlerFact) {
    URLStreamHandlerFactory urlHandlerFactory = urlHandlerFact;//getURLHandlerFactory(urlHandlerFact);

    URLStreamHandler handler = null;
    if (urlHandlerFactory != null) {
        String protocol = getURLProtocol(spec);
        if (protocol != null) {
            handler = urlHandlerFactory.createURLStreamHandler(protocol);
        }
    }
    return handler;
}

From source file:com.wuman.androidimageloader.ImageLoader.java

private URLStreamHandler getURLStreamHandler(String protocol) {
    URLStreamHandlerFactory factory = mURLStreamHandlerFactory;
    if (factory == null) {
        return null;
    }//from   w  ww  .j ava2s  .  co  m
    HashMap<String, URLStreamHandler> handlers = mStreamHandlers;
    synchronized (handlers) {
        URLStreamHandler handler = handlers.get(protocol);
        if (handler == null) {
            handler = factory.createURLStreamHandler(protocol);
            if (handler != null) {
                handlers.put(protocol, handler);
            }
        }
        return handler;
    }
}