@Beta
public final class URISupport
extends java.lang.Object
URIs and parsing some HTTP URL information.| Modifier | Constructor and Description |
|---|---|
private |
URISupport()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
buildQuery(java.util.List<Pair<java.lang.String,java.lang.String>> parameters)
Builds an RFC-3968 encoded URL query component from a collection of parameters.
|
static java.lang.String |
doURLDecode(java.lang.String value)
Perform URL decoding on the given string.
|
static java.lang.String |
doURLEncode(java.lang.String value)
Perform URL encoding on the given string.
|
static java.net.URI |
fileURIFromAbsolutePath(java.lang.String path)
Create a file: URI from an absolute path, dealing with the Windows, non leading "/" issue.
|
static java.lang.String |
getRawQueryStringParameter(java.lang.String queryString,
java.lang.String paramName)
Get the first raw (i.e.RFC-3968 encoded) query string component with the specified parameter name.
|
static java.util.List<Pair<java.lang.String,java.lang.String>> |
parseQueryString(java.lang.String queryString)
Parses a RFC-3968 encoded query string in to a set of name/value pairs.
|
static java.net.URI |
setFragment(java.net.URI prototype,
java.lang.String fragment)
Sets the fragment of a URI.
|
static java.net.URI |
setHost(java.net.URI prototype,
java.lang.String host)
Sets the host of a URI.
|
static java.net.URI |
setPath(java.net.URI prototype,
java.lang.String path)
Sets the path of a URI.
|
static java.net.URI |
setPort(java.net.URI prototype,
int port)
Sets the port of a URI.
|
static java.net.URI |
setQuery(java.net.URI prototype,
java.util.List<Pair<java.lang.String,java.lang.String>> parameters)
Sets the query of a URI.
|
static java.net.URI |
setQuery(java.net.URI prototype,
java.lang.String query)
Sets the query of a URI.
|
static java.net.URI |
setScheme(java.net.URI prototype,
java.lang.String scheme)
Sets the scheme of a URI.
|
static java.lang.String |
trimOrNullFragment(java.lang.String fragment)
Trims an RFC-3968 encoded URL fragment component.
|
static java.lang.String |
trimOrNullPath(java.lang.String path)
Trims an RFC-3968 encoded URL path component.
|
static java.lang.String |
trimOrNullQuery(java.lang.String query)
Trims an RFC-3968 encoded URL query component.
|
public static java.net.URI setFragment(java.net.URI prototype,
java.lang.String fragment)
prototype - prototype URI that provides information other than the fragmentfragment - fragment for the new URIpublic static java.net.URI setHost(java.net.URI prototype,
java.lang.String host)
prototype - prototype URI that provides information other than the hosthost - host for the new URIpublic static java.net.URI setPath(java.net.URI prototype,
java.lang.String path)
prototype - prototype URI that provides information other than the pathpath - path for the new URIpublic static java.net.URI setPort(java.net.URI prototype,
int port)
prototype - prototype URI that provides information other than the portport - port for the new URIpublic static java.net.URI setQuery(java.net.URI prototype,
java.lang.String query)
WARNING: If the supplied query parameter names and/or values contain '%' characters
(for example because they are already Base64-encoded), then the approach of using URI
instances to work with the URI/URL may not be appropriate. Per its documentation, the
URI constructors always encode '%' characters, which can lead to cases of double-encoding.
For an alternative way of manipulating URL's see URLBuilder.
prototype - prototype URI that provides information other than the queryquery - query for the new URIpublic static java.net.URI setQuery(java.net.URI prototype,
java.util.List<Pair<java.lang.String,java.lang.String>> parameters)
WARNING: If the supplied query parameter names and/or values contain '%' characters
(for example because they are already Base64-encoded), then the approach of using URI
instances to work with the URI/URL may not be appropriate. Per its documentation, the
URI constructors always encode '%' characters, which can lead to cases of double-encoding.
For an alternative way of manipulating URL's see URLBuilder.
prototype - prototype URI that provides information other than the queryparameters - query parameters for the new URIpublic static java.net.URI setScheme(java.net.URI prototype,
java.lang.String scheme)
prototype - prototype URI that provides information other than the schemescheme - scheme for the new URIpublic static java.net.URI fileURIFromAbsolutePath(java.lang.String path)
throws java.net.URISyntaxException
C:\absolute\path
if we blindly convert that to a file URI by prepending "file://", then we end up with a URI which has "C:" as
the network segment. So if we need to have an absolute file path based URI (JAAS is the example) we call this
method which hides the hideous implementationpath - the absolute file path to convertjava.net.URISyntaxException - if the URI contructor failspublic static java.lang.String buildQuery(java.util.List<Pair<java.lang.String,java.lang.String>> parameters)
parameters - collection of parameters from which to build the URL query component, may be null or empty@Nullable
public static java.lang.String getRawQueryStringParameter(@Nullable
java.lang.String queryString,
@Nullable
java.lang.String paramName)
queryString - the URL encoded HTTP URL query stringparamName - the URL decoded name of the parameter to findpublic static java.util.List<Pair<java.lang.String,java.lang.String>> parseQueryString(java.lang.String queryString)
null.queryString - URL encoded query stringpublic static java.lang.String trimOrNullPath(java.lang.String path)
path - path to trimpublic static java.lang.String trimOrNullQuery(java.lang.String query)
query - query to trimpublic static java.lang.String trimOrNullFragment(java.lang.String fragment)
fragment - fragment to trimpublic static java.lang.String doURLDecode(java.lang.String value)
value - the string to decodepublic static java.lang.String doURLEncode(java.lang.String value)
value - the string to encode