org.eclipse.jetty.util

## Class URIUtil

- java.lang.Object
- - org.eclipse.jetty.util.URIUtil

- All Implemented Interfaces:
    java.lang.Cloneable

      public class URIUtil
      extends java.lang.Object
      implements java.lang.Cloneable

  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 Also:
    `UrlEncoded`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `__CHARSET`
    `static java.lang.String` | `HTTP`
    `static java.lang.String` | `HTTP_COLON`
    `static java.lang.String` | `HTTPS`
    `static java.lang.String` | `HTTPS_COLON`
    `static java.lang.String` | `SLASH`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `addPaths(java.lang.String p1, java.lang.String p2)` Add two URI path segments.
    `static java.lang.String` | `canonicalPath(java.lang.String path)` Convert a path to a cananonical form.
    `static java.lang.String` | `compactPath(java.lang.String path)` Convert a path to a compact form.
    `static java.lang.String` | `decodePath(byte[] buf, int offset, int length)`
    `static java.lang.String` | `decodePath(java.lang.String path)`
    `static java.lang.String` | `encodePath(java.lang.String path)` Encode a URI path.
    `static java.lang.StringBuilder` | `encodePath(java.lang.StringBuilder buf, java.lang.String path)` Encode a URI path.
    `static java.lang.StringBuilder` | `encodeString(java.lang.StringBuilder buf, java.lang.String path, java.lang.String encode)` Encode a URI path.
    `static boolean` | `hasScheme(java.lang.String uri)`
    `static java.lang.String` | `parentPath(java.lang.String p)` Return the parent Path.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SLASH

          public static final java.lang.String SLASH

      See Also:
        Constant Field Values

    - #### HTTP

          public static final java.lang.String HTTP

      See Also:
        Constant Field Values

    - #### HTTP_COLON

          public static final java.lang.String HTTP_COLON

      See Also:
        Constant Field Values

    - #### HTTPS

          public static final java.lang.String HTTPS

      See Also:
        Constant Field Values

    - #### HTTPS_COLON

          public static final java.lang.String HTTPS_COLON

      See Also:
        Constant Field Values

    - #### __CHARSET

          public static final java.lang.String __CHARSET

  - ### Method Detail

    - #### encodePath

          public static java.lang.String encodePath(java.lang.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 java.lang.StringBuilder encodePath(java.lang.StringBuilder buf,
                                           java.lang.String path)

      Encode a URI path.
      Parameters:
        `path` - The path the encode
        `buf` - StringBuilder to encode path into (or null)
      Returns:
        The StringBuilder or null if no substitutions required.

    - #### encodeString

          public static java.lang.StringBuilder encodeString(java.lang.StringBuilder buf,
                                             java.lang.String path,
                                             java.lang.String encode)

      Encode a URI path.
      Parameters:
        `path` - The path the encode
        `buf` - StringBuilder to encode path into (or null)
        `encode` - String of characters to encode. % is always encoded.
      Returns:
        The StringBuilder or null if no substitutions required.

    - #### decodePath

          public static java.lang.String decodePath(java.lang.String path)

    - #### decodePath

          public static java.lang.String decodePath(byte[] buf,
                                    int offset,
                                    int length)

    - #### addPaths

          public static java.lang.String addPaths(java.lang.String p1,
                                  java.lang.String p2)

      Add two URI path segments. Handles null and empty paths, path and query params (eg ?a=b or ;JSESSIONID=xxx) and avoids duplicate '/'
      Parameters:
        `p1` - URI path segment (should be encoded)
        `p2` - URI path segment (should be encoded)
      Returns:
        Legally combined path segments.

    - #### parentPath

          public static java.lang.String parentPath(java.lang.String p)

      Return the parent Path. Treat a URI like a directory path and return the parent directory.

    - #### canonicalPath

          public static java.lang.String canonicalPath(java.lang.String path)

      Convert a path to a cananonical form. All instances of "." and ".." are factored out. Null is returned if the path tries to .. above its root.
      Parameters:
        `path` -
      Returns:
        path or null.

    - #### compactPath

          public static java.lang.String compactPath(java.lang.String path)

      Convert a path to a compact form. All instances of "//" and "///" etc. are factored out to single "/"
      Parameters:
        `path` -
      Returns:
        path

    - #### hasScheme

          public static boolean hasScheme(java.lang.String uri)

      Parameters:
        `uri` - URI
      Returns:
        True if the uri has a scheme

Copyright © 2013 FuseSource, Corp.. All Rights Reserved.