Class URLProtocolRegistry


  • @ThreadSafe
    @Singleton
    public final class URLProtocolRegistry
    extends Object
    A central registry for supported URL protocols. By default, the registry will include all protocols contained in EURLProtocol, but it may be extended by custom protocols
    Author:
    Boris Gregorcic, Philip Helger
    • Method Detail

      • isInstantiated

        public static boolean isInstantiated()
      • registerProtocol

        public void registerProtocol​(@Nonnull
                                     IURLProtocol aProtocol)
        Registers a new protocol
        Parameters:
        aProtocol - The protocol to be registered. May not be null.
        Throws:
        IllegalArgumentException - If another handler for this protocol is already installed.
      • getRegisteredProtocolCount

        @Nonnegative
        public int getRegisteredProtocolCount()
      • getProtocol

        @Nullable
        public IURLProtocol getProtocol​(@Nullable
                                        String sURL)
        Try to evaluate the matching URL protocol from the passed URL
        Parameters:
        sURL - The URL to get the protocol from
        Returns:
        The corresponding URL protocol or null if unresolved
      • getProtocol

        @Nullable
        public IURLProtocol getProtocol​(@Nullable
                                        ISimpleURL aURL)
        Try to evaluate the matching URL protocol from the passed URL
        Parameters:
        aURL - The URL data
        Returns:
        The corresponding URL protocol or null if unresolved
      • hasKnownProtocol

        public boolean hasKnownProtocol​(@Nullable
                                        String sURL)
        Check if the passed URL has any known protocol
        Parameters:
        sURL - The URL to analyze
        Returns:
        true if the protocol is known, false otherwise
      • hasKnownProtocol

        public boolean hasKnownProtocol​(@Nullable
                                        ISimpleURL aURL)
        Check if the passed URL has any known protocol
        Parameters:
        aURL - The URL to analyze
        Returns:
        true if the protocol is known, false otherwise
      • getWithoutProtocol

        @Nullable
        public String getWithoutProtocol​(@Nullable
                                         String sURL)
        Return the passed URL where the protocol has been stripped (if known)
        Parameters:
        sURL - The URL to strip the protocol from. May be null.
        Returns:
        The passed URL where any known protocol has been stripped
      • reinitialize

        public void reinitialize()
        Reinitialize all protocols. Adds all EURLProtocol values and invokes all SPI implementations.