Class URLUtils


  • public final class URLUtils
    extends java.lang.Object
    Utils 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.Charset UTF_8  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String domainToASCII​(java.lang.String domain)
      Converts a domain to its ASCII representation.
      static java.lang.String domainToUnicode​(java.lang.String asciiDomain)
      Converts a domain to its Unicode representation.
      static java.lang.String getDefaultPortForScheme​(java.lang.String scheme)
      Gets the default port for a given schema.
      static int hexToInt​(char c1, char c2)  
      static boolean isASCIIAlpha​(int c)  
      static boolean isASCIIAlphaLowercase​(int c)  
      static boolean isASCIIAlphanumeric​(int c)  
      static boolean isASCIIAlphaUppercase​(int c)  
      static boolean isASCIIDigit​(int c)  
      static boolean isASCIIHexDigit​(int c)  
      static boolean isRelativeScheme​(java.lang.String scheme)
      Returns true if the schema is a known relative schema (ftp, file, gopher, http, https, ws, wss).
      static boolean isURLCodePoint​(int c)  
      static java.lang.String percentDecode​(java.lang.String input)
      Percent-decodes a string.
      static void percentEncode​(byte b, java.lang.StringBuilder buffer)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UTF_8

        public static final java.nio.charset.Charset UTF_8
    • 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
      • 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:
        1. ftp - 21
        2. file - null
        3. gopher - 70
        4. http - 80
        5. https - 443
        6. ws - 80
        7. wss - 433
        Parameters:
        scheme -
        Returns: