Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.http.client.utils
Class URIUtils

    java.lang.Object
      org.apache.http.client.utils.URIUtils

    @Immutable
    public class URIUtils

extends Object

A collection of utilities for `URIs`, to workaround bugs within the class or for ease-of-use features.

Since:
  4.0

Method Summary
`static URI` | `createURI(String scheme, String host, int port, String path, String query, String fragment)` Deprecated. (4.2) use `URIBuilder`.
`static HttpHost` | `extractHost(URI uri)` Extracts target host from the given `URI`.
`static URI` | `resolve(URI baseURI, String reference)` Resolves a URI reference against a base URI.
`static URI` | `resolve(URI baseURI, URI reference)` Resolves a URI reference against a base URI.
`static URI` | `rewriteURI(URI uri)` A convenience method that creates a new `URI` whose scheme, host, port, path, query are taken from the existing URI, dropping any fragment or user-information.
`static URI` | `rewriteURI(URI uri, HttpHost target)` A convenience method for `rewriteURI(URI, HttpHost, boolean)` that always keeps the fragment.
`static URI` | `rewriteURI(URI uri, HttpHost target, boolean dropFragment)` A convenience method for creating a new `URI` whose scheme, host and port are taken from the target host, but whose path, query and fragment are taken from the existing URI.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### createURI

    @Deprecated
    public static URI createURI(String scheme,
                                           String host,
                                           int port,
                                           String path,
                                           String query,
                                           String fragment)
                         throws URISyntaxException

  Deprecated. (4.2) use `URIBuilder`.

  Constructs a `URI` using all the parameters. This should be used instead of `URI.URI(String, String, String, int, String, String, String)` or any of the other URI multi-argument URI constructors.

  Parameters:
    `scheme` - Scheme name
    `host` - Host name
    `port` - Port number
    `path` - Path
    `query` - Query
    `fragment` - Fragment
  Throws:
    `URISyntaxException` - If both a scheme and a path are given but the path is relative, if the URI string constructed from the given components violates RFC 2396, or if the authority component of the string is present but cannot be parsed as a server-based authority

### rewriteURI

    public static URI rewriteURI(URI uri,
                                 HttpHost target,
                                 boolean dropFragment)
                          throws URISyntaxException

  A convenience method for creating a new `URI` whose scheme, host and port are taken from the target host, but whose path, query and fragment are taken from the existing URI. The fragment is only used if dropFragment is false. The path is set to "/" if not explicitly specified.

  Parameters:
    `uri` - Contains the path, query and fragment to use.
    `target` - Contains the scheme, host and port to use.
    `dropFragment` - True if the fragment should not be copied.
  Throws:
    `URISyntaxException` - If the resulting URI is invalid.

### rewriteURI

    public static URI rewriteURI(URI uri,
                                 HttpHost target)
                          throws URISyntaxException

  A convenience method for `rewriteURI(URI, HttpHost, boolean)` that always keeps the fragment.

  Throws:
    `URISyntaxException`

### rewriteURI

    public static URI rewriteURI(URI uri)
                          throws URISyntaxException

  A convenience method that creates a new `URI` whose scheme, host, port, path, query are taken from the existing URI, dropping any fragment or user-information. The path is set to "/" if not explicitly specified. The existing URI is returned unmodified if it has no fragment or user-information and has a path.

  Parameters:
    `uri` - original URI.
  Throws:
    `URISyntaxException` - If the resulting URI is invalid.

### resolve

    public static URI resolve(URI baseURI,
                              String reference)

  Resolves a URI reference against a base URI. Work-around for bug in java.net.URI ()

  Parameters:
    `baseURI` - the base URI
    `reference` - the URI reference
  Returns:
    the resulting URI

### resolve

    public static URI resolve(URI baseURI,
                              URI reference)

  Resolves a URI reference against a base URI. Work-around for bugs in java.net.URI (e.g. )

  Parameters:
    `baseURI` - the base URI
    `reference` - the URI reference
  Returns:
    the resulting URI

### extractHost

    public static HttpHost extractHost(URI uri)

  Extracts target host from the given `URI`.

  Parameters:
    `uri` -
  Returns:
    the target host if the URI is absolute or `null if the URI is relative or does not contain a valid host name.`
  Since:
    4.1

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2013 The Apache Software Foundation. All Rights Reserved.