Class URISupport

java.lang.Object
org.apache.qpid.jms.util.URISupport

public class URISupport extends Object
Provides support methods for dealing with URI values.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static URI
    applyParameters(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 URI
    applyParameters(URI uri, Map<String,String> queryParameters, String optionPrefix)
    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 boolean
    Examine the supplied string and ensure that all parends appear as matching pairs.
    static int
    Given a string and a position in that string of an open parend, find the matching close parend.
    static boolean
    Examine a URI and determine if it is a Composite type or not.
    Given a composite URI, parse the individual URI elements contained within that URI and return a CompsoteData instance that contains the parsed URI values.
    static Map<String,String>
    Given a URI parse and extract any URI query options and return them as a Key / Value mapping.
    static URI
    Removes any URI query from the given uri and return a new URI that does not contain the query portion.
    static String[]
    Given the inner portion of a composite URI, split and return each inner URI as a string element in a new String array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • URISupport

      public URISupport()
  • Method Details

    • parseComposite

      public static URISupport.CompositeData parseComposite(URI uri) throws URISyntaxException
      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

      public static boolean isCompositeURI(URI uri)
      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

      public static boolean checkParenthesis(String str)
      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

      public static int indexOfParenthesisMatch(String str, int first) throws URISyntaxException
      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

      public 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.
      Parameters:
      str - The inner URI elements of a composite URI string.
      Returns:
      an array containing each inner URI from the composite one.
    • removeQuery

      public static URI removeQuery(URI uri) throws URISyntaxException
      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

      public static Map<String,String> parseParameters(URI uri) throws URISyntaxException
      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 URISyntaxException
      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. 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 URISyntaxException
      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. 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.