org.littleshoot.util
Class UriUtils

java.lang.Object
  extended by org.littleshoot.util.UriUtils

public class UriUtils
extends Object

URI manipulation utilities and helpers class.


Method Summary
static String appendParam(String url, String name, String value)
           
static String newUrl(String baseUrl, Collection<Pair<String,String>> params)
          Creates a new URL string from the specified base URL and parameters.
static String newUrl(String baseUrl, Map<String,String> paramMap)
          Creates a new URL string from the specified base URL and parameters.
static String newWwwUrlEncodedUrl(String baseUrl, Collection<Pair<String,String>> params)
          Creates a new URL string from the specified base URL and parameters encoded in non-form encoding, www-urlencoded.
static String newWwwUrlEncodedUrl(String baseUrl, Map<String,String> paramMap)
          Creates a new URL string from the specified base URL and parameters encoded in non-form encoding, www-urlencoded.
static Pair<String,String> pair(String name, boolean value)
          Returns a pair of strings created from a string name and a boolean value.
static Pair<String,String> pair(String name, long value)
          Returns a pair of strings created from a string name and a long value.
static Pair<String,String> pair(String s1, String s2)
          Returns a pair of strings created from two strings.
static Pair<String,String> pair(String name, URI value)
          Returns a pair of strings created from a string name and a URI value.
static String stripHost(String uri)
          Strips the host from a URI string.
static String urlFormDecode(String s)
          Returns a string that has been decoded.
static String urlFormEncode(String s)
          Returns a string that has been encoded for use in a URL.
static String urlNonFormEncode(String s)
          Returns a string that has been encoded for use in a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

urlNonFormEncode

public static String urlNonFormEncode(String s)
Returns a string that has been encoded for use in a URL.

Parameters:
s - The string to encode.
Returns:
The given string encoded for use in a URL.

urlFormEncode

public static String urlFormEncode(String s)
Returns a string that has been encoded for use in a URL.

Parameters:
s - The string to encode.
Returns:
The given string encoded for use in a URL.

urlFormDecode

public static String urlFormDecode(String s)
Returns a string that has been decoded.

Parameters:
s - The string to decode.
Returns:
The string to decode.

appendParam

public static String appendParam(String url,
                                 String name,
                                 String value)

newUrl

public static String newUrl(String baseUrl,
                            Collection<Pair<String,String>> params)
Creates a new URL string from the specified base URL and parameters.

Parameters:
baseUrl - The base URL excluding parameters.
params - The parameters.
Returns:
The full URL string.

newUrl

public static String newUrl(String baseUrl,
                            Map<String,String> paramMap)
Creates a new URL string from the specified base URL and parameters.

Parameters:
baseUrl - The base URL excluding parameters.
paramMap - The parameters.
Returns:
The full URL string.

newWwwUrlEncodedUrl

public static String newWwwUrlEncodedUrl(String baseUrl,
                                         Collection<Pair<String,String>> params)
Creates a new URL string from the specified base URL and parameters encoded in non-form encoding, www-urlencoded.

Parameters:
baseUrl - The base URL excluding parameters.
params - The parameters.
Returns:
The full URL string.

newWwwUrlEncodedUrl

public static String newWwwUrlEncodedUrl(String baseUrl,
                                         Map<String,String> paramMap)
Creates a new URL string from the specified base URL and parameters encoded in non-form encoding, www-urlencoded.

Parameters:
baseUrl - The base URL excluding parameters.
paramMap - The parameters.
Returns:
The full URL string.

pair

public static Pair<String,String> pair(String s1,
                                       String s2)
Returns a pair of strings created from two strings.

Parameters:
s1 - The first string.
s2 - The second string.
Returns:
A pair of strings created from the two given strings.

pair

public static Pair<String,String> pair(String name,
                                       long value)
Returns a pair of strings created from a string name and a long value.

Parameters:
name - The string name.
value - The long value.
Returns:
A pair of strings.

pair

public static Pair<String,String> pair(String name,
                                       boolean value)
Returns a pair of strings created from a string name and a boolean value.

Parameters:
name - The string name.
value - The boolean value.
Returns:
A pair of strings.

pair

public static Pair<String,String> pair(String name,
                                       URI value)
Returns a pair of strings created from a string name and a URI value.

Parameters:
name - The string name.
value - The URI value.
Returns:
A pair of strings.

stripHost

public static String stripHost(String uri)
Strips the host from a URI string. This will turn "http://host.com/path" into "/path".

Parameters:
uri - The URI to transform.
Returns:
A string with the URI stripped.


Copyright © 2011-2013 LittleShoot. All Rights Reserved.