Package com.helger.commons.url
Class URLProtocolRegistry
- java.lang.Object
-
- com.helger.commons.url.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 inEURLProtocol, but it may be extended by custom protocols- Author:
- Boris Gregorcic, Philip Helger
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ICommonsCollection<IURLProtocol>getAllProtocols()static URLProtocolRegistrygetInstance()IURLProtocolgetProtocol(ISimpleURL aURL)Try to evaluate the matching URL protocol from the passed URLIURLProtocolgetProtocol(String sURL)Try to evaluate the matching URL protocol from the passed URLintgetRegisteredProtocolCount()StringgetWithoutProtocol(String sURL)Return the passed URL where the protocol has been stripped (if known)booleanhasKnownProtocol(ISimpleURL aURL)Check if the passed URL has any known protocolbooleanhasKnownProtocol(String sURL)Check if the passed URL has any known protocolstatic booleanisInstantiated()voidregisterProtocol(IURLProtocol aProtocol)Registers a new protocolvoidreinitialize()Reinitialize all protocols.
-
-
-
Method Detail
-
isInstantiated
public static boolean isInstantiated()
-
getInstance
@Nonnull public static URLProtocolRegistry getInstance()
-
registerProtocol
public void registerProtocol(@Nonnull IURLProtocol aProtocol)
Registers a new protocol- Parameters:
aProtocol- The protocol to be registered. May not benull.- Throws:
IllegalArgumentException- If another handler for this protocol is already installed.
-
getAllProtocols
@Nonnull @ReturnsMutableCopy public ICommonsCollection<IURLProtocol> getAllProtocols()
- Returns:
- All registered protocols
-
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
nullif 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
nullif unresolved
-
hasKnownProtocol
public boolean hasKnownProtocol(@Nullable String sURL)
Check if the passed URL has any known protocol- Parameters:
sURL- The URL to analyze- Returns:
trueif the protocol is known,falseotherwise
-
hasKnownProtocol
public boolean hasKnownProtocol(@Nullable ISimpleURL aURL)
Check if the passed URL has any known protocol- Parameters:
aURL- The URL to analyze- Returns:
trueif the protocol is known,falseotherwise
-
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 benull.- Returns:
- The passed URL where any known protocol has been stripped
-
reinitialize
public void reinitialize()
Reinitialize all protocols. Adds allEURLProtocolvalues and invokes all SPI implementations.
-
-