public static boolean isSupported(String scheme) { Assertions.notNull(scheme, SCHEME_PARAM); debug(CHECKING_SUPPORT_FOR_CUSTOM_PROTOCOL, scheme); boolean result = Loader.SINGLETON.getHandler(scheme, false) != null; debug("Protocol '%s' is %s.", scheme, result ? "supported" : "not supported"); return result; }
public static <T extends URLStreamHandler> boolean addProvider(Class<T> handlerClass) { Assertions.notNull(handlerClass, "handlerClass"); if (!"Handler".equals(handlerClass.getSimpleName())) { throw new IllegalArgumentException( "Handler class '" + handlerClass.getCanonicalName() + "' is not a valid URLStreamHandler class: name does meet specification"); } String protocolPackage = handlerClass.getPackage().getName(); int pointBreak = protocolPackage.lastIndexOf('.'); String providerPackage = protocolPackage.substring(0, pointBreak); String scheme = protocolPackage.substring(pointBreak + 1); return Loader.SINGLETON.addProvider(providerPackage, scheme); }
public static URLStreamHandler getHandler(String scheme) { Assertions.notNull(scheme, SCHEME_PARAM); return Loader.SINGLETON.getHandler(scheme, true); }