public final class UrlUtils extends Object
Modifier and Type | Method and Description |
---|---|
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.
|
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 MalformedURLException
s.
url
- the URL string to convert into a URL instancepublic 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 instanceMalformedURLException
- if the URL string cannot be converted to a URL instancepublic 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 URLMalformedURLException
- if there is a problem creating the new URLpublic 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 URLMalformedURLException
- if there is a problem creating the new URLpublic 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 URLMalformedURLException
- if there is a problem creating the new URLpublic 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 URLMalformedURLException
- if there is a problem creating the new URLpublic 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 URLMalformedURLException
- if there is a problem creating the new URLpublic 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 URLMalformedURLException
- if there is a problem creating the new URLpublic 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.Copyright © 2002–2014 Gargoyle Software Inc.. All rights reserved.