Package com.helger.commons.url
Class URLProtocol
- java.lang.Object
-
- com.helger.commons.url.URLProtocol
-
- All Implemented Interfaces:
IURLProtocol
public class URLProtocol extends Object implements IURLProtocol
A simple implementation of theIURLProtocolinterface.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description URLProtocol(String sProtocol, boolean bAllowsForQueryParameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowsForQueryParameters()booleanequals(Object o)StringgetProtocol()Retrieve the URL protocol prefix to be used.StringgetWithProtocol(String sURL)Prefix the passed URL with this protocol.StringgetWithProtocolIfNone(String sURL)Prefix the passed URL with this protocol if the URL does not have a protocol yet.inthashCode()booleanisUsedInURL(String sURL)Tells if the passed String (URL) belongs to this protocol.StringtoString()
-
-
-
Method Detail
-
getProtocol
@Nonnull @Nonempty public String getProtocol()
Description copied from interface:IURLProtocolRetrieve the URL protocol prefix to be used. May contain "//".- Specified by:
getProtocolin interfaceIURLProtocol- Returns:
- The underlying text representation of the protocol. Never
nullnor empty.
-
isUsedInURL
public boolean isUsedInURL(@Nullable String sURL)
Description copied from interface:IURLProtocolTells if the passed String (URL) belongs to this protocol.- Specified by:
isUsedInURLin interfaceIURLProtocol- Parameters:
sURL- The URL to check. May benull.- Returns:
trueif the passed URL starts with this protocol
-
getWithProtocol
@Nullable public String getWithProtocol(@Nullable String sURL)
Description copied from interface:IURLProtocolPrefix the passed URL with this protocol.- Specified by:
getWithProtocolin interfaceIURLProtocol- Parameters:
sURL- The URL to be prefixed. May benull.- Returns:
nullif the parameter isnull. The protocol is prepended independent whether the URL already has a protocol or not.
-
getWithProtocolIfNone
@Nullable public String getWithProtocolIfNone(@Nullable String sURL)
Description copied from interface:IURLProtocolPrefix the passed URL with this protocol if the URL does not have a protocol yet.- Specified by:
getWithProtocolIfNonein interfaceIURLProtocol- Parameters:
sURL- The URL to be prefixed. May benull.- Returns:
nullif the parameter isnull. The protocol is prepended if the URL not already has a protocol.
-
allowsForQueryParameters
public boolean allowsForQueryParameters()
- Specified by:
allowsForQueryParametersin interfaceIURLProtocol- Returns:
trueif this protocol can handle HTTP query parameters (?x=y&z=1),falseif not.
-
-