-
public class UrlUtils
-
-
Method Summary
Modifier and Type Method Description final BooleanisInternal(String url)final BooleanisNotInternal(String url)final static URLgetURLOrNull(String url)final static BooleanisValidUrl(String url)final static Stringnormalize(String url, Boolean ignoreQuery)Simple normalization TODO: move to general normalize module final static StringnormalizeOrNull(String url, Boolean ignoreQuery)final static List<String>normalizeUrls(Iterable<String> urls, Boolean ignoreQuery)final StringremoveQueryParameters(String url, String parameterNames)final StringkeepQueryParameters(String url, String parameterNames)final static URLresolveURL(URL base, String targetUrl)Resolve relative URL-s and fix a java.net.URL error in handling of URLs with pure query targets. final static Pair<String, String>splitUrlArgs(String configuredUrl)final StringmergeUrlArgs(String url, String args)final static StringgetUrlWithoutParameters(String url)final static Pair<String, String>normalizedUrlAndKey(String originalUrl, Boolean norm)final static StringreverseUrl(String url)Reverses a url's domain. final static StringreverseUrl(URL url)Reverses a url's domain. final static StringreverseUrl(Integer tenantId, String unreversedUrl)Get the reversed and tenanted format of unreversedUrl, unreversedUrl can be both tenanted or not tenanted This method might change the tenant id of the original urlZero tenant id means no tenant final static StringreverseUrlOrEmpty(String url)final static StringreverseUrlOrNull(String url)final static StringunreverseUrl(String reversedUrl)final static StringunreverseUrl(Integer tenantId, String reversedUrl)Get unreversed and tenanted url of reversedUrl, reversedUrl can be both tenanted or not tenanted, This method might change the tenant id of the original url final static StringunreverseUrlOrNull(String reversedUrl)final static StringgetStartKey(Integer tenantId, String unreversedUrl)Get start key for tenanted table final static StringgetStartKey(String unreversedUrl)Get start key for non-tenanted table final static StringgetEndKey(String unreversedUrl)Get end key for non-tenanted tables final static StringgetEndKey(Integer tenantId, String unreversedUrl)Get end key for tenanted tables final static StringdecodeKeyLowerBound(String startKey)We use unicode character \u0001 to be the lower key bound, but the client usally encode the character to be a string "\\u0001" or "\\\\u0001", so we should decode them to be the right oneNote, the character is displayed as <U></U>+0001> in some output systemNow, we consider all the three character/string \u0001, "\\u0001", "\\\\u0001" are the lower key bound final static StringdecodeKeyUpperBound(String endKey)We use unicode character \uFFFF to be the upper key bound, but the client usally encode the character to be a string "\\uFFFF" or "\\\\uFFFF", so we should decode them to be the right oneNote, the character may display as <U></U>+FFFF> in some output systemNow, we consider all the three character/string \uFFFF, "\\uFFFF", "\\\\uFFFF" are the upper key bound final static StringgetReversedHost(String reversedUrl)Given a reversed url, returns the reversed host E.g "com.foo.bar:http:8983/to/index.html?a=b" -> "com.foo. final static StringreverseHost(String hostName)final static StringunreverseHost(String reversedHostName)final static StringtoString(CharSequence utf8)Convert given Utf8 instance to String and and cleans out any offending "�" from the String. -
-
Method Detail
-
isInternal
final Boolean isInternal(String url)
-
isNotInternal
final Boolean isNotInternal(String url)
-
getURLOrNull
final static URL getURLOrNull(String url)
-
isValidUrl
final static Boolean isValidUrl(String url)
-
normalize
final static String normalize(String url, Boolean ignoreQuery)
Simple normalization TODO: move to general normalize module
-
normalizeOrNull
final static String normalizeOrNull(String url, Boolean ignoreQuery)
-
removeQueryParameters
final String removeQueryParameters(String url, String parameterNames)
-
keepQueryParameters
final String keepQueryParameters(String url, String parameterNames)
-
resolveURL
final static URL resolveURL(URL base, String targetUrl)
Resolve relative URL-s and fix a java.net.URL error in handling of URLs with pure query targets.
- Parameters:
base- base url
-
splitUrlArgs
final static Pair<String, String> splitUrlArgs(String configuredUrl)
-
mergeUrlArgs
final String mergeUrlArgs(String url, String args)
-
getUrlWithoutParameters
final static String getUrlWithoutParameters(String url)
-
normalizedUrlAndKey
final static Pair<String, String> normalizedUrlAndKey(String originalUrl, Boolean norm)
-
reverseUrl
final static String reverseUrl(String url)
Reverses a url's domain. This form is better for storing in hbase. Because scans within the same domain are faster.
E.g. "http://bar.foo.com:8983/to/index.html?a=b" becomes "com.foo.bar:8983:http/to/index.html?a=b".
- Parameters:
url- url to be reversed
-
reverseUrl
final static String reverseUrl(URL url)
Reverses a url's domain. This form is better for storing in hbase. Because scans within the same domain are faster.
E.g. "http://bar.foo.com:8983/to/index.html?a=b" becomes "com.foo.bar:http:8983/to/index.html?a=b".
- Parameters:
url- url to be reversed
-
reverseUrl
final static String reverseUrl(Integer tenantId, String unreversedUrl)
Get the reversed and tenanted format of unreversedUrl, unreversedUrl can be both tenanted or not tenanted This method might change the tenant id of the original url
Zero tenant id means no tenant
- Parameters:
unreversedUrl- the unreversed url, can be both tenanted or not tenanted
-
reverseUrlOrEmpty
final static String reverseUrlOrEmpty(String url)
-
reverseUrlOrNull
final static String reverseUrlOrNull(String url)
-
unreverseUrl
final static String unreverseUrl(String reversedUrl)
-
unreverseUrl
final static String unreverseUrl(Integer tenantId, String reversedUrl)
Get unreversed and tenanted url of reversedUrl, reversedUrl can be both tenanted or not tenanted, This method might change the tenant id of the original url
- Parameters:
tenantId- the expected tenant id of the reversedUrlreversedUrl- the reversed url, can be both tenanted or not tenanted
-
unreverseUrlOrNull
final static String unreverseUrlOrNull(String reversedUrl)
-
getStartKey
final static String getStartKey(Integer tenantId, String unreversedUrl)
Get start key for tenanted table
- Parameters:
unreversedUrl- unreversed key, which is the original url
-
getStartKey
final static String getStartKey(String unreversedUrl)
Get start key for non-tenanted table
- Parameters:
unreversedUrl- unreversed key, which is the original url
-
getEndKey
final static String getEndKey(String unreversedUrl)
Get end key for non-tenanted tables
- Parameters:
unreversedUrl- unreversed key, which is the original url
-
getEndKey
final static String getEndKey(Integer tenantId, String unreversedUrl)
Get end key for tenanted tables
- Parameters:
unreversedUrl- unreversed key, which is the original url
-
decodeKeyLowerBound
final static String decodeKeyLowerBound(String startKey)
We use unicode character \u0001 to be the lower key bound, but the client usally encode the character to be a string "\\u0001" or "\\\\u0001", so we should decode them to be the right one
Note, the character is displayed as <U></U>+0001> in some output system
Now, we consider all the three character/string \u0001, "\\u0001", "\\\\u0001" are the lower key bound
-
decodeKeyUpperBound
final static String decodeKeyUpperBound(String endKey)
We use unicode character \uFFFF to be the upper key bound, but the client usally encode the character to be a string "\\uFFFF" or "\\\\uFFFF", so we should decode them to be the right one
Note, the character may display as <U></U>+FFFF> in some output system
Now, we consider all the three character/string \uFFFF, "\\uFFFF", "\\\\uFFFF" are the upper key bound
-
getReversedHost
final static String getReversedHost(String reversedUrl)
Given a reversed url, returns the reversed host E.g "com.foo.bar:http:8983/to/index.html?a=b" -> "com.foo.bar"
- Parameters:
reversedUrl- Reversed url
-
reverseHost
final static String reverseHost(String hostName)
-
unreverseHost
final static String unreverseHost(String reversedHostName)
-
toString
final static String toString(CharSequence utf8)
Convert given Utf8 instance to String and and cleans out any offending "�" from the String.
- Parameters:
utf8- Utf8 object
-
-
-
-