|
||||||||||
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 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. |
static java.lang.String |
resolveUrl(java.lang.String baseUrl,
java.lang.String relativeUrl)
Resolves a given relative URL against a base URL. |
static java.lang.String |
resolveUrl(java.net.URL baseUrl,
java.lang.String relativeUrl)
Resolves a given relative URL against a base URL. |
static java.net.URL |
toUrlSafe(java.lang.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 java.net.URL |
toUrlUnsafe(java.lang.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 java.net.URL toUrlSafe(java.lang.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 MalformedURLException
s.
url
- the URL string to convert into a URL instance
public static java.net.URL toUrlUnsafe(java.lang.String url) throws java.net.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
java.net.MalformedURLException
- if the URL string cannot be converted to a URL instancepublic static java.net.URL getUrlWithNewProtocol(java.net.URL u, java.lang.String newProtocol) throws java.net.MalformedURLException
u
- the URL on which to base the returned URLnewProtocol
- the new protocol to use in the returned URL
java.net.MalformedURLException
- if there is a problem creating the new URLpublic static java.net.URL getUrlWithNewHost(java.net.URL u, java.lang.String newHost) throws java.net.MalformedURLException
u
- the URL on which to base the returned URLnewHost
- the new host to use in the returned URL
java.net.MalformedURLException
- if there is a problem creating the new URLpublic static java.net.URL getUrlWithNewPort(java.net.URL u, int newPort) throws java.net.MalformedURLException
u
- the URL on which to base the returned URLnewPort
- the new port to use in the returned URL
java.net.MalformedURLException
- if there is a problem creating the new URLpublic static java.net.URL getUrlWithNewPath(java.net.URL u, java.lang.String newPath) throws java.net.MalformedURLException
u
- the URL on which to base the returned URLnewPath
- the new path to use in the returned URL
java.net.MalformedURLException
- if there is a problem creating the new URLpublic static java.net.URL getUrlWithNewRef(java.net.URL u, java.lang.String newRef) throws java.net.MalformedURLException
u
- the URL on which to base the returned URLnewRef
- the new reference to use in the returned URL
java.net.MalformedURLException
- if there is a problem creating the new URLpublic static java.net.URL getUrlWithNewQuery(java.net.URL u, java.lang.String newQuery) throws java.net.MalformedURLException
u
- the URL on which to base the returned URLnewQuery
- the new query string to use in the returned URL
java.net.MalformedURLException
- if there is a problem creating the new URLpublic static java.lang.String resolveUrl(java.lang.String baseUrl, java.lang.String relativeUrl)
baseUrl
- The base URL in which to resolve the specification.relativeUrl
- The relative URL to resolve against the base URL.
public static java.lang.String resolveUrl(java.net.URL baseUrl, java.lang.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 |