Modifier | Constructor and Description |
---|---|
private |
URISupport()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static String |
buildQuery(List<Pair<String,String>> parameters)
Builds an RFC-3968 encoded URL query component from a collection of parameters.
|
static String |
doURLDecode(String value)
Perform URL decoding on the given string.
|
static String |
doURLEncode(String value)
Perform URL encoding on the given string.
|
static URI |
fileURIFromAbsolutePath(String path)
Create a file: URI from an absolute path, dealing with the Windows, non leading "/" issue.
|
static String |
getRawQueryStringParameter(String queryString,
String paramName)
Get the first raw (i.e.RFC-3968 encoded) query string component with the specified parameter name.
|
static List<Pair<String,String>> |
parseQueryString(String queryString)
Parses a RFC-3968 encoded query string in to a set of name/value pairs.
|
static URI |
setFragment(URI prototype,
String fragment)
Sets the fragment of a URI.
|
static URI |
setHost(URI prototype,
String host)
Sets the host of a URI.
|
static URI |
setPath(URI prototype,
String path)
Sets the path of a URI.
|
static URI |
setPort(URI prototype,
int port)
Sets the port of a URI.
|
static URI |
setQuery(URI prototype,
List<Pair<String,String>> parameters)
Sets the query of a URI.
|
static URI |
setQuery(URI prototype,
String query)
Sets the query of a URI.
|
static URI |
setScheme(URI prototype,
String scheme)
Sets the scheme of a URI.
|
static String |
trimOrNullFragment(String fragment)
Trims an RFC-3968 encoded URL fragment component.
|
static String |
trimOrNullPath(String path)
Trims an RFC-3968 encoded URL path component.
|
static String |
trimOrNullQuery(String query)
Trims an RFC-3968 encoded URL query component.
|
public static URI setFragment(URI prototype, String fragment)
prototype
- prototype URI that provides information other than the fragmentfragment
- fragment for the new URIpublic static URI setHost(URI prototype, String host)
prototype
- prototype URI that provides information other than the hosthost
- host for the new URIpublic static URI setPath(URI prototype, String path)
prototype
- prototype URI that provides information other than the pathpath
- path for the new URIpublic static URI setPort(URI prototype, int port)
prototype
- prototype URI that provides information other than the portport
- port for the new URIpublic static URI setQuery(URI prototype, 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 URI setQuery(URI prototype, List<Pair<String,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 URI setScheme(URI prototype, String scheme)
prototype
- prototype URI that provides information other than the schemescheme
- scheme for the new URIpublic static URI fileURIFromAbsolutePath(String path) throws 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 convertURISyntaxException
- if the URI contructor failspublic static String buildQuery(List<Pair<String,String>> parameters)
parameters
- collection of parameters from which to build the URL query component, may be null or empty@Nullable public static String getRawQueryStringParameter(@Nullable String queryString, @Nullable String paramName)
queryString
- the URL encoded HTTP URL query stringparamName
- the URL decoded name of the parameter to findpublic static List<Pair<String,String>> parseQueryString(String queryString)
null
.queryString
- URL encoded query stringpublic static String trimOrNullPath(String path)
path
- path to trimpublic static String trimOrNullQuery(String query)
query
- query to trimpublic static String trimOrNullFragment(String fragment)
fragment
- fragment to trimpublic static String doURLDecode(String value)
value
- the string to decodeCopyright © 1999–2016. All rights reserved.