com.gargoylesoftware.htmlunit.util
Class UrlUtils

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

public final class UrlUtils
extends 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: 2132 $
Author:
Daniel Gredler

Method Summary
static URL getUrlWithNewHost(URL u, String newHost)
          Creates and returns a new URL identical to the specified URL, except using the specified host.
static URL getUrlWithNewPath(URL u, String newPath)
          Creates and returns a new URL identical to the specified URL, except using the specified path.
static URL getUrlWithNewPort(URL u, int newPort)
          Creates and returns a new URL identical to the specified URL, except using the specified port.
static URL getUrlWithNewProtocol(URL u, String newProtocol)
          Creates and returns a new URL identical to the specified URL, except using the specified protocol.
static URL getUrlWithNewQuery(URL u, String newQuery)
          Creates and returns a new URL identical to the specified URL, except using the specified query string.
static URL getUrlWithNewRef(URL u, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUrlWithNewProtocol

public static URL getUrlWithNewProtocol(URL u,
                                        String newProtocol)
                                 throws 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:
MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewHost

public static URL getUrlWithNewHost(URL u,
                                    String newHost)
                             throws 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:
MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewPort

public static URL getUrlWithNewPort(URL u,
                                    int newPort)
                             throws 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:
MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewPath

public static URL getUrlWithNewPath(URL u,
                                    String newPath)
                             throws 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:
MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewRef

public static URL getUrlWithNewRef(URL u,
                                   String newRef)
                            throws 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:
MalformedURLException - If there is a problem creating the new URL.

getUrlWithNewQuery

public static URL getUrlWithNewQuery(URL u,
                                     String newQuery)
                              throws 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:
MalformedURLException - If there is a problem creating the new URL.


Copyright © 2002-2010 Gargoyle Software Inc.. All Rights Reserved.