|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gargoylesoftware.htmlunit.util.UrlUtils
public final class UrlUtils
URL utilities class that makes it easy to create new URLs based off of old URLs without having to assemble or parse them yourself.
| 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. |
static String |
resolveUrl(String baseUrl,
String relativeUrl)
Resolves a given relative URL against a base URL. |
static String |
resolveUrl(URL baseUrl,
String relativeUrl)
Resolves a given relative URL against a base URL. |
static URL |
toUrlSafe(String url)
Constructs a URL instance based on the specified URL string, taking into account the fact that the specified URL string may represent an "about:..." URL, a "javascript:..." URL, or a data:... URL. |
static URL |
toUrlUnsafe(String url)
Constructs a URL instance based on the specified URL string, taking into account the fact that the specified URL string may represent an "about:..." URL, a "javascript:..." URL, or a data:... URL. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static URL toUrlSafe(String url)
Constructs a URL instance based on the specified URL string, taking into account the fact that the specified URL string may represent an "about:..." URL, a "javascript:..." URL, or a data:... URL.
The caller should be sure that URL strings passed to this method will parse correctly as URLs, as
this method never expects to have to handle MalformedURLExceptions.
url - the URL string to convert into a URL instance
public static URL toUrlUnsafe(String url)
throws MalformedURLException
Constructs a URL instance based on the specified URL string, taking into account the fact that the specified URL string may represent an "about:..." URL, a "javascript:..." URL, or a data:... URL.
Unlike toUrlSafe(String), the caller need not be sure that URL strings passed to this
method will parse correctly as URLs.
url - the URL string to convert into a URL instance
MalformedURLException - if the URL string cannot be converted to a URL instance
public static URL getUrlWithNewProtocol(URL u,
String newProtocol)
throws MalformedURLException
u - the URL on which to base the returned URLnewProtocol - the new protocol to use in the returned URL
MalformedURLException - if there is a problem creating the new URL
public static URL getUrlWithNewHost(URL u,
String newHost)
throws MalformedURLException
u - the URL on which to base the returned URLnewHost - the new host to use in the returned URL
MalformedURLException - if there is a problem creating the new URL
public static URL getUrlWithNewPort(URL u,
int newPort)
throws MalformedURLException
u - the URL on which to base the returned URLnewPort - the new port to use in the returned URL
MalformedURLException - if there is a problem creating the new URL
public static URL getUrlWithNewPath(URL u,
String newPath)
throws MalformedURLException
u - the URL on which to base the returned URLnewPath - the new path to use in the returned URL
MalformedURLException - if there is a problem creating the new URL
public static URL getUrlWithNewRef(URL u,
String newRef)
throws MalformedURLException
u - the URL on which to base the returned URLnewRef - the new reference to use in the returned URL
MalformedURLException - if there is a problem creating the new URL
public static URL getUrlWithNewQuery(URL u,
String newQuery)
throws MalformedURLException
u - the URL on which to base the returned URLnewQuery - the new query string to use in the returned URL
MalformedURLException - if there is a problem creating the new URL
public static String resolveUrl(String baseUrl,
String relativeUrl)
baseUrl - The base URL in which to resolve the specification.relativeUrl - The relative URL to resolve against the base URL.
public static String resolveUrl(URL baseUrl,
String relativeUrl)
baseUrl - The base URL in which to resolve the specification.relativeUrl - The relative URL to resolve against the base URL.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||