Class KiwiUrls2
These utilities could be considered for kiwi's KiwiUrls class.
Or, they could just stay here forever. One can never really know these things...
-
Method Summary
Modifier and TypeMethodDescriptionstatic URLauthorityOnlyUrlFrom(URL url) Strip any path or query parameters from the given URL, returning only the authority ( host[:port] ).static URLhostOnlyUrlFrom(URL url) Strip any path or query parameters from the given URL, returning only host[:port] (the authority part).uniqueAuthorityOnlyUrls(Collection<URL> urls) Given a collection of URLs, return a set containing URLs with only the authority ( host[:port] ).Given a collection of URLs, return a list containing unique URLs with only the authority ( host[:port] ).uniqueHostOnlyUrls(Collection<URL> urls) Given a collection of URLs, return a set containing URLs with only the host[:port] (the authority part).
-
Method Details
-
uniqueHostOnlyUrls
Given a collection of URLs, return a set containing URLs with only the host[:port] (the authority part).This is an alias of
uniqueAuthorityOnlyUrls(Collection).Note: This method may perform DNS lookups when adding URL objects to the resulting Set. This is because "URL's equals() and hashCode() methods can perform a DNS lookup to resolve the host name" according to IntelliJ's "may contain URL objects" inspection. If you need to avoid this, use the
uniqueAuthorityOnlyUrlsAsList(Collection)method to get a List of unique URLs. However, note that any subsequent conversion to a Set will potentially incur the same DNS lookups.- Parameters:
urls- the URLs to process- Returns:
- a set containing unique URLs containing only the host[:port] (the authority part) from the original URLs
- See Also:
-
uniqueAuthorityOnlyUrls
Given a collection of URLs, return a set containing URLs with only the authority ( host[:port] ).Note: This method may perform DNS lookups when adding URL objects to the resulting Set. This is because "URL's equals() and hashCode() methods can perform a DNS lookup to resolve the host name" according to IntelliJ's "may contain URL objects" inspection. If you need to avoid this, use the
uniqueAuthorityOnlyUrlsAsList(Collection)method to get a List of unique URLs. However, note that any subsequent conversion to a Set will potentially incur the same DNS lookups.- Parameters:
urls- the URLs to process- Returns:
- a set containing unique URLs containing only the authority part ( host[:port] ) from the original URLs
- See Also:
-
uniqueAuthorityOnlyUrlsAsList
Given a collection of URLs, return a list containing unique URLs with only the authority ( host[:port] ).Note: This method avoids DNS lookups performed by URL equals() and hashCode() methods that may occur when adding URL objects to sets and maps. Note also that any subsequent conversion to a Set will potentially incur the same DNS lookups, so it is best to work directly with the list of URLs returned by this method.
- Parameters:
urls- the URLs to process- Returns:
- a list containing unique URLs containing only the authority part ( host[:port] ) from the original URLs
-
hostOnlyUrlFrom
Strip any path or query parameters from the given URL, returning only host[:port] (the authority part).This is an alias of
authorityOnlyUrlFrom(URL).- Parameters:
url- the URL to process- Returns:
- a URL containing only the host[:port] (the authority part) of the original URL
- See Also:
-
authorityOnlyUrlFrom
Strip any path or query parameters from the given URL, returning only the authority ( host[:port] ).- Parameters:
url- the URL to process- Returns:
- a URL containing only the authority part of the original URL
-