com.gargoylesoftware.htmlunit.util
Class UrlUtils

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.util.UrlUtils

public final class UrlUtils
extends java.lang.Object

URL utilities class that makes it easy to create new URLs based off of old URLs without having to assemble or parse them yourself.

Version:
$Revision: 1.3 $
Author:
Daniel Gredler

Method Summary
static java.net.URL getUrlWithNewHost(java.net.URL u, java.lang.String newHost)
 Creates and returns a new URL identical to the specified URL, except using the specified host.
static java.net.URL getUrlWithNewPath(java.net.URL u, java.lang.String newPath)
 Creates and returns a new URL identical to the specified URL, except using the specified path.
static java.net.URL getUrlWithNewPort(java.net.URL u, int newPort)
 Creates and returns a new URL identical to the specified URL, except using the specified port.
static java.net.URL getUrlWithNewProtocol(java.net.URL u, java.lang.String newProtocol)
 Creates and returns a new URL identical to the specified URL, except using the specified protocol.
static java.net.URL getUrlWithNewQuery(java.net.URL u, java.lang.String newQuery)
 Creates and returns a new URL identical to the specified URL, except using the specified query string.
static java.net.URL getUrlWithNewRef(java.net.URL u, java.lang.String newRef)
 Creates and returns a new URL identical to the specified URL, except using the specified reference.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUrlWithNewHost

public static java.net.URL getUrlWithNewHost(java.net.URL u,
                                             java.lang.String newHost)
                                      throws java.net.MalformedURLException
Creates and returns a new URL identical to the specified URL, except using the specified host.

Parameters:
u - The URL on which to base the returned URL.
newHost - The new host to use in the returned URL.
Returns:
A new URL identical to the specified URL, except using the specified host.
Throws:
java.net.MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewPath

public static java.net.URL getUrlWithNewPath(java.net.URL u,
                                             java.lang.String newPath)
                                      throws java.net.MalformedURLException
Creates and returns a new URL identical to the specified URL, except using the specified path.

Parameters:
u - The URL on which to base the returned URL.
newPath - The new path to use in the returned URL.
Returns:
A new URL identical to the specified URL, except using the specified path.
Throws:
java.net.MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewPort

public static java.net.URL getUrlWithNewPort(java.net.URL u,
                                             int newPort)
                                      throws java.net.MalformedURLException
Creates and returns a new URL identical to the specified URL, except using the specified port.

Parameters:
u - The URL on which to base the returned URL.
newPort - The new port to use in the returned URL.
Returns:
A new URL identical to the specified URL, except using the specified port.
Throws:
java.net.MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewProtocol

public static java.net.URL getUrlWithNewProtocol(java.net.URL u,
                                                 java.lang.String newProtocol)
                                          throws java.net.MalformedURLException
Creates and returns a new URL identical to the specified URL, except using the specified protocol.

Parameters:
u - The URL on which to base the returned URL.
newProtocol - The new protocol to use in the returned URL.
Returns:
A new URL identical to the specified URL, except using the specified protocol.
Throws:
java.net.MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewQuery

public static java.net.URL getUrlWithNewQuery(java.net.URL u,
                                              java.lang.String newQuery)
                                       throws java.net.MalformedURLException
Creates and returns a new URL identical to the specified URL, except using the specified query string.

Parameters:
u - The URL on which to base the returned URL.
newQuery - The new query string to use in the returned URL.
Returns:
A new URL identical to the specified URL, except using the specified query string.
Throws:
java.net.MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewRef

public static java.net.URL getUrlWithNewRef(java.net.URL u,
                                            java.lang.String newRef)
                                     throws java.net.MalformedURLException
Creates and returns a new URL identical to the specified URL, except using the specified reference.

Parameters:
u - The URL on which to base the returned URL.
newRef - The new reference to use in the returned URL.
Returns:
A new URL identical to the specified URL, except using the specified reference.
Throws:
java.net.MalformedURLException - If there is a problem creating the new URL.


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.