Class URLUtils
java.lang.Object
io.mola.galimatias.URLUtils
Utils for parsing and serializing URLs.
Not to be confused with the URLUtils from the WHATWG URL spec.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidbyteToHex(byte b, StringBuilder buffer) static StringdomainToASCII(String domain) Converts a domain to its ASCII representation.(package private) static StringdomainToASCII(String domain, ErrorHandler errorHandler) static StringdomainToUnicode(String asciiDomain) Converts a domain to its Unicode representation.(package private) static StringdomainToUnicode(String asciiDomain, ErrorHandler errorHandler) static StringgetDefaultPortForScheme(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(String scheme) Returns true if the schema is a known relative schema (ftp, file, gopher, http, https, ws, wss).static booleanisURLCodePoint(int c) static StringpercentDecode(String input) Percent-decodes a string.static voidpercentEncode(byte b, StringBuilder buffer) private static voidprocessIdnaInfo(ErrorHandler errorHandler, com.ibm.icu.text.IDNA.Info idnaInfo)
-
Field Details
-
UTF_8
-
idna
private static final com.ibm.icu.text.IDNA idna -
_hex
private static final char[] _hex -
RELATIVE_SCHEMES
-
-
Constructor Details
-
URLUtils
private URLUtils()
-
-
Method Details
-
percentDecode
-
domainToASCII
Converts 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:
-
domainToASCII
static String domainToASCII(String domain, ErrorHandler errorHandler) throws GalimatiasParseException - Throws:
GalimatiasParseException
-
domainToUnicode
Converts 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:
-
domainToUnicode
static String domainToUnicode(String asciiDomain, ErrorHandler errorHandler) throws GalimatiasParseException - Throws:
GalimatiasParseException
-
processIdnaInfo
private static void processIdnaInfo(ErrorHandler errorHandler, com.ibm.icu.text.IDNA.Info idnaInfo) throws GalimatiasParseException - Throws:
GalimatiasParseException
-
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) -
byteToHex
-
hexToInt
public static int hexToInt(char c1, char c2) -
percentEncode
-
isRelativeScheme
Returns true if the schema is a known relative schema (ftp, file, gopher, http, https, ws, wss).- Parameters:
scheme-- Returns:
-
getDefaultPortForScheme
-