java.lang.Object
org.klomp.snark.URIUtil

public class URIUtilextends Object
URI Holder. This class assists with the decoding and encoding or HTTP URI's. It differs from the java.net.URL class as it does not provide communications ability, but it does assist with query string formatting.

UTF-8 encoding is used by default for % encoded characters. This may be overridden with the org.eclipse.jetty.util.URI.charset system property. see UrlEncoded

I2P modded from Jetty 8.1.15

  • Constructor Details

    • URIUtil

      public URIUtil()
      The encode and decode helpers below are static, so an instance carries nothing.
  • Method Details

    • encodePath

      public static String encodePath(String path)
      Encode a URI path. This is the same encoding offered by URLEncoder, except that the '/' character is not encoded.
      Parameters:
      path - The path the encode
      Returns:
      The encoded path
    • encodePath

      public static StringBuilder encodePath(StringBuilder buf, String path)
      Encode a URI path.

      Somewhat oddly, this encodes all chars >= 0x80 if buf is null, (strict RFC 2396) but only the control, space, and special chars if buf is non-null.

      Parameters:
      buf - StringBuilder to encode path into (or null)
      path - The path the encode
      Returns:
      The StringBuilder or null if no substitutions required.
    • toHex

      private static void toHex(byte b, StringBuilder buf)
      Modded from Jetty TypeUtil.
      Parameters:
      b - the byte to encode
      buf - the builder to append the %XX escape to
    • toHex

      private static void toHex(char c, StringBuilder buf)
      Append the character as one or more %XX escapes, UTF-8 encoded.
      Parameters:
      c - the character to encode
      buf - the builder to append the escapes to