public final class URISupport extends Object
Modifier and Type | Field and Description |
---|---|
static char[] |
RAW_TOKEN_END |
static String |
RAW_TOKEN_PREFIX |
static char[] |
RAW_TOKEN_START |
Modifier and Type | Method and Description |
---|---|
static String |
appendParametersToURI(String originalURI,
Map<String,Object> newParameters)
Appends the given parameters to the given URI.
|
static String |
createQueryString(Collection<String> sortedKeys,
Map<String,Object> options,
boolean encode) |
static String |
createQueryString(Map<String,Object> options)
Assembles a query from the given map.
|
static String |
createQueryString(Map<String,Object> options,
boolean encode)
Assembles a query from the given map.
|
static URI |
createRemainingURI(URI originalURI,
Map<String,Object> params)
Creates a URI from the original URI and the remaining parameters
Used by various Camel components
|
static URI |
createURIWithQuery(URI uri,
String query)
Creates a URI with the given query
|
static Map<String,Object> |
extractProperties(Map<String,Object> properties,
String optionPrefix) |
static String |
extractQuery(String uri)
Extracts the query part of the given uri
|
static String |
extractRemainderPath(URI u,
boolean useRaw)
Extracts the scheme specific path from the URI that is used as the remainder option when creating endpoints.
|
static boolean |
isRaw(int index,
List<Pair<Integer>> pairs)
Tests if the index is within any pair of the start and end indexes which represent the start and end positions of
a RAW token.
|
static String |
joinPaths(String... paths) |
static String |
normalizeUri(String uri)
Normalizes the uri by reordering the parameters so they are sorted and thus we can use the uris for endpoint
matching.
|
static Map<String,Object> |
parseParameters(URI uri)
Parses the query parameters of the uri (eg the query part).
|
static Map<String,Object> |
parseQuery(String uri)
Parses the query part of the uri (eg the parameters).
|
static Map<String,Object> |
parseQuery(String uri,
boolean useRaw)
Parses the query part of the uri (eg the parameters).
|
static Map<String,Object> |
parseQuery(String uri,
boolean useRaw,
boolean lenient)
Parses the query part of the uri (eg the parameters).
|
static String |
pathAndQueryOf(URI uri) |
static String |
prepareQuery(URI uri) |
static void |
resolveRawParameterValues(Map<String,Object> parameters)
Traverses the given parameters, and resolve any parameter values which uses the RAW token syntax:
key=RAW(value).
|
static String |
sanitizePath(String path)
Removes detected sensitive information (such as passwords) from the path part of an URI (that is, the
part without the query parameters or component prefix) and returns the result.
|
static String |
sanitizeUri(String uri)
Removes detected sensitive information (such as passwords) from the URI and returns the result.
|
static List<Pair<Integer>> |
scanRaw(String str)
Scans RAW tokens in the string and returns the list of pair indexes which tell where a RAW token starts and ends
in the string.
|
static String |
stripPrefix(String value,
String prefix)
Strips the prefix from the value.
|
static String |
stripSuffix(String value,
String suffix)
Strips the suffix from the value.
|
public static final String RAW_TOKEN_PREFIX
public static final char[] RAW_TOKEN_START
public static final char[] RAW_TOKEN_END
public static String sanitizeUri(String uri)
uri
- The uri to sanitize.and #USERINFO_PASSWORD for the matched pattern
public static String sanitizePath(String path)
path
- the URI path to sanitizepublic static String extractRemainderPath(URI u, boolean useRaw)
u
- the URIuseRaw
- whether to force using raw valuespublic static String extractQuery(String uri)
uri
- the uripublic static Map<String,Object> parseQuery(String uri) throws URISyntaxException
uri
- the uriURISyntaxException
- is thrown if uri has invalid syntax.RAW_TOKEN_PREFIX
,
RAW_TOKEN_START
,
RAW_TOKEN_END
public static Map<String,Object> parseQuery(String uri, boolean useRaw) throws URISyntaxException
uri
- the uriuseRaw
- whether to force using raw valuesURISyntaxException
- is thrown if uri has invalid syntax.RAW_TOKEN_PREFIX
,
RAW_TOKEN_START
,
RAW_TOKEN_END
public static Map<String,Object> parseQuery(String uri, boolean useRaw, boolean lenient) throws URISyntaxException
uri
- the uriuseRaw
- whether to force using raw valueslenient
- whether to parse lenient and ignore trailing & markers which has no key or value which
can happen when using HTTP componentsURISyntaxException
- is thrown if uri has invalid syntax.RAW_TOKEN_PREFIX
,
RAW_TOKEN_START
,
RAW_TOKEN_END
public static List<Pair<Integer>> scanRaw(String str)
isRaw(int, List)
and the returned value is supposed to be used as the
parameter of that method.str
- the string to scan RAW tokensisRaw(int, List)
,
RAW_TOKEN_PREFIX
,
RAW_TOKEN_START
,
RAW_TOKEN_END
public static boolean isRaw(int index, List<Pair<Integer>> pairs)
scanRaw(String)
and is supposed to consume the returned value of that
method as the second parameter pairs.index
- the index to be testedpairs
- the list of pair indexes which represent the start and end positions of a RAW tokenscanRaw(String)
,
RAW_TOKEN_PREFIX
,
RAW_TOKEN_START
,
RAW_TOKEN_END
public static Map<String,Object> parseParameters(URI uri) throws URISyntaxException
uri
- the uriURISyntaxException
- is thrown if uri has invalid syntax.public static String prepareQuery(URI uri)
public static void resolveRawParameterValues(Map<String,Object> parameters)
parameters
- the uri parametersparseQuery(String)
,
RAW_TOKEN_PREFIX
,
RAW_TOKEN_START
,
RAW_TOKEN_END
public static URI createURIWithQuery(URI uri, String query) throws URISyntaxException
uri
- the uriquery
- the query to append to the uriURISyntaxException
- is thrown if uri has invalid syntax.public static String stripPrefix(String value, String prefix)
value
- the valueprefix
- the prefix to remove from valuepublic static String stripSuffix(String value, String suffix)
value
- the valuesuffix
- the suffix to remove from valuepublic static String createQueryString(Map<String,Object> options) throws URISyntaxException
options
- the map with the options (eg key/value pairs)URISyntaxException
- is thrown if uri has invalid syntax.public static String createQueryString(Map<String,Object> options, boolean encode) throws URISyntaxException
options
- the map with the options (eg key/value pairs)encode
- whether to URL encode the query stringURISyntaxException
- is thrown if uri has invalid syntax.public static String createQueryString(Collection<String> sortedKeys, Map<String,Object> options, boolean encode) throws URISyntaxException
URISyntaxException
public static URI createRemainingURI(URI originalURI, Map<String,Object> params) throws URISyntaxException
URISyntaxException
public static String appendParametersToURI(String originalURI, Map<String,Object> newParameters) throws URISyntaxException, UnsupportedEncodingException
originalURI
, it will be
replaced by its value in newParameters
.originalURI
- the original URInewParameters
- the parameters to addURISyntaxException
- is thrown if the uri syntax is invalidUnsupportedEncodingException
- is thrown if encoding errorpublic static String normalizeUri(String uri) throws URISyntaxException, UnsupportedEncodingException
uri
- the uriURISyntaxException
- in thrown if the uri syntax is invalidUnsupportedEncodingException
- is thrown if encoding errorRAW_TOKEN_PREFIX
,
RAW_TOKEN_START
,
RAW_TOKEN_END
public static Map<String,Object> extractProperties(Map<String,Object> properties, String optionPrefix)
public static String pathAndQueryOf(URI uri)
Apache Camel