Package io.mola.galimatias
Class URLUtils
- java.lang.Object
-
- io.mola.galimatias.URLUtils
-
public final class URLUtils extends java.lang.ObjectUtils for parsing and serializing URLs. Not to be confused with the URLUtils from the WHATWG URL spec.
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetUTF_8
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringdomainToASCII(java.lang.String domain)Converts a domain to its ASCII representation.static java.lang.StringdomainToUnicode(java.lang.String asciiDomain)Converts a domain to its Unicode representation.static java.lang.StringgetDefaultPortForScheme(java.lang.String scheme)Gets the default port for a given schema.static inthexToInt(char c1, char c2)static booleanisASCIIAlpha(int c)static booleanisASCIIAlphaLowercase(int c)static booleanisASCIIAlphanumeric(int c)static booleanisASCIIAlphaUppercase(int c)static booleanisASCIIDigit(int c)static booleanisASCIIHexDigit(int c)static booleanisRelativeScheme(java.lang.String scheme)Returns true if the schema is a known relative schema (ftp, file, gopher, http, https, ws, wss).static booleanisURLCodePoint(int c)static java.lang.StringpercentDecode(java.lang.String input)Percent-decodes a string.static voidpercentEncode(byte b, java.lang.StringBuilder buffer)
-
-
-
Method Detail
-
percentDecode
public static java.lang.String percentDecode(java.lang.String input)
Percent-decodes a string. Percent-encoded bytes are assumed to represent UTF-8 characters.- Parameters:
input-- Returns:
- See Also:
- WHATWG URL Standard: Percent-encoded bytes
-
domainToASCII
public static java.lang.String domainToASCII(java.lang.String domain) throws GalimatiasParseExceptionConverts a domain to its ASCII representation. Uses the the name to ASCII as specified in the IDNA standard.- Parameters:
domain-- Returns:
- Throws:
GalimatiasParseException- See Also:
- WHATWG URL Standard - IDNA Section
-
domainToUnicode
public static java.lang.String domainToUnicode(java.lang.String asciiDomain) throws GalimatiasParseExceptionConverts a domain to its Unicode representation. Uses the the name to Unicode as specified in the IDNA standard.- Parameters:
asciiDomain-- Returns:
- Throws:
GalimatiasParseException- See Also:
- WHATWG URL Standard - IDNA Section
-
isASCIIHexDigit
public static boolean isASCIIHexDigit(int c)
-
isASCIIDigit
public static boolean isASCIIDigit(int c)
-
isASCIIAlphaUppercase
public static boolean isASCIIAlphaUppercase(int c)
-
isASCIIAlphaLowercase
public static boolean isASCIIAlphaLowercase(int c)
-
isASCIIAlpha
public static boolean isASCIIAlpha(int c)
-
isASCIIAlphanumeric
public static boolean isASCIIAlphanumeric(int c)
-
isURLCodePoint
public static boolean isURLCodePoint(int c)
-
hexToInt
public static int hexToInt(char c1, char c2)
-
percentEncode
public static void percentEncode(byte b, java.lang.StringBuilder buffer)
-
isRelativeScheme
public static boolean isRelativeScheme(java.lang.String scheme)
Returns true if the schema is a known relative schema (ftp, file, gopher, http, https, ws, wss).- Parameters:
scheme-- Returns:
-
getDefaultPortForScheme
public static java.lang.String getDefaultPortForScheme(java.lang.String scheme)
Gets the default port for a given schema. That is:- ftp - 21
- file - null
- gopher - 70
- http - 80
- https - 443
- ws - 80
- wss - 433
- Parameters:
scheme-- Returns:
-
-