com.atlassian.confluence.web
Class UrlBuilder

java.lang.Object
  extended by com.atlassian.confluence.web.UrlBuilder

public final class UrlBuilder
extends Object

A builder which can construct URLs by adding parameters. Not thread-safe.

Since:
3.0

Constructor Summary
UrlBuilder(String baseUrl, String encoding)
          Constructs a builder with the given base URL, which should already be URL-encoded.
 
Method Summary
 UrlBuilder add(String name, int value)
          Adds a parameter to the URL.
 UrlBuilder add(String name, long value)
          Adds a parameter to the URL.
 UrlBuilder add(String name, String value)
          Adds a parameter to the URL.
 UrlBuilder addAll(Map<String,Object> params)
          Add multiple parameters to the URL from a map.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UrlBuilder

public UrlBuilder(String baseUrl,
                  String encoding)
Constructs a builder with the given base URL, which should already be URL-encoded.

Parameters:
baseUrl - Base URL to which a query string is appended
encoding - Encoding to use, e.g. UTF-8
Method Detail

add

public UrlBuilder add(String name,
                      String value)
               throws IllegalArgumentException
Adds a parameter to the URL.

Parameters:
name - the name of the parameter
value - the value of the parameter
Returns:
this object
Throws:
IllegalArgumentException - if either the name or value is null

add

public UrlBuilder add(String name,
                      long value)
               throws IllegalArgumentException
Adds a parameter to the URL.

Parameters:
name - Parameter name (part before =)
value - Parameter value (part after =)
Returns:
This object
Throws:
IllegalArgumentException - When things are null
See Also:
add(String, String)

add

public UrlBuilder add(String name,
                      int value)
               throws IllegalArgumentException
Adds a parameter to the URL.

Parameters:
name - Parameter name (part before =)
value - Parameter value (part after =)
Returns:
This object
Throws:
IllegalArgumentException - When things are null
See Also:
add(String, String)

addAll

public UrlBuilder addAll(Map<String,Object> params)
Add multiple parameters to the URL from a map.

Parameters:
params - A map of parameters to add to the URL
Returns:
This URL builder instance

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2011 Atlassian. All Rights Reserved.