Package org.apache.qpid.jms.util
Class URISupport
java.lang.Object
org.apache.qpid.jms.util.URISupport
Provides support methods for dealing with URI values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA composite URI can be split into one or more CompositeData object which each represent the individual URIs that comprise the composite one. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic URIapplyParameters(URI uri, Map<String, String> queryParameters) Given a Key / Value mapping create and append a URI query value that represents the mapped entries, return the newly updated URI that contains the value of the given URI and the appended query value.static URIGiven a Key / Value mapping create and append a URI query value that represents the mapped entries, return the newly updated URI that contains the value of the given URI and the appended query value.static booleancheckParenthesis(String str) Examine the supplied string and ensure that all parends appear as matching pairs.static intindexOfParenthesisMatch(String str, int first) Given a string and a position in that string of an open parend, find the matching close parend.static booleanisCompositeURI(URI uri) Examine a URI and determine if it is a Composite type or not.static URISupport.CompositeDataparseComposite(URI uri) Given a composite URI, parse the individual URI elements contained within that URI and return a CompsoteData instance that contains the parsed URI values.parseParameters(URI uri) Given a URI parse and extract any URI query options and return them as a Key / Value mapping.static URIremoveQuery(URI uri) Removes any URI query from the given uri and return a new URI that does not contain the query portion.static String[]splitComponents(String str) Given the inner portion of a composite URI, split and return each inner URI as a string element in a new String array.
-
Constructor Details
-
URISupport
public URISupport()
-
-
Method Details
-
parseComposite
Given a composite URI, parse the individual URI elements contained within that URI and return a CompsoteData instance that contains the parsed URI values.- Parameters:
uri- The target URI that should be parsed.- Returns:
- a new CompsiteData instance representing the parsed composite URI.
- Throws:
URISyntaxException- if the given URI is invalid.
-
isCompositeURI
Examine a URI and determine if it is a Composite type or not.- Parameters:
uri- The URI that is to be examined.- Returns:
- true if the given URI is a Composite type.
-
checkParenthesis
Examine the supplied string and ensure that all parends appear as matching pairs.- Parameters:
str- The target string to examine.- Returns:
- true if the target string has valid parend pairings.
-
indexOfParenthesisMatch
Given a string and a position in that string of an open parend, find the matching close parend.- Parameters:
str- The string to be searched for a matching parend.first- The index in the string of the opening parend whose close value is to be searched.- Returns:
- the index in the string where the closing parend is located.
- Throws:
URISyntaxException- if the string does not contain a matching parend.
-
splitComponents
Given the inner portion of a composite URI, split and return each inner URI as a string element in a new String array.- Parameters:
str- The inner URI elements of a composite URI string.- Returns:
- an array containing each inner URI from the composite one.
-
removeQuery
Removes any URI query from the given uri and return a new URI that does not contain the query portion.- Parameters:
uri- The URI whose query value is to be removed.- Returns:
- a new URI that does not contain a query value.
- Throws:
URISyntaxException- if the given URI is invalid.
-
parseParameters
Given a URI parse and extract any URI query options and return them as a Key / Value mapping. This method handles composite URI types and will extract the URI options from the outermost composite URI.- Parameters:
uri- The URI whose query should be extracted and processed.- Returns:
- A Mapping of the URI options.
- Throws:
URISyntaxException- if the given URI is invalid.
-
applyParameters
public static URI applyParameters(URI uri, Map<String, String> queryParameters) throws URISyntaxExceptionGiven a Key / Value mapping create and append a URI query value that represents the mapped entries, return the newly updated URI that contains the value of the given URI and the appended query value. The values in the parameters map should not be URL encoded values as this method will perform an encode on them resulting in double encoded values.- Parameters:
uri- The source URI that will have the Map entries appended as a URI query value.queryParameters- The Key / Value mapping that will be transformed into a URI query string.- Returns:
- A new URI value that combines the given URI and the constructed query string.
- Throws:
URISyntaxException- if the given URI is invalid.
-
applyParameters
public static URI applyParameters(URI uri, Map<String, String> queryParameters, String optionPrefix) throws URISyntaxExceptionGiven a Key / Value mapping create and append a URI query value that represents the mapped entries, return the newly updated URI that contains the value of the given URI and the appended query value. Only values in the given options map that start with the provided prefix are appended to the provided URI, the prefix is stripped off before the insertion.This method replaces the value of any matching query string options in the original URI with the value given in the provided query parameters map.
- Parameters:
uri- The source URI that will have the Map entries appended as a URI query value.queryParameters- The Key / Value mapping that will be transformed into a URI query string.optionPrefix- A string value that when not null or empty is used to prefix each query option key.- Returns:
- A new URI value that combines the given URI and the constructed query string.
- Throws:
URISyntaxException- if the given URI is invalid.
-