org.opensaml.util
Class URLBuilder

java.lang.Object
  extended by org.opensaml.util.URLBuilder

public class URLBuilder
extends Object

Utility class for building URLs. May also be used to parse a URL into its invidual components. All components will be converted UTF-8 encoding and then application/x-www-form-urlencoded when built. This class is not thread-safe.


Field Summary
private  String fragement
          URL fragment.
private  String host
          Host for the URL.
private  String password
          Password in the URL.
private  String path
          URL path.
private  int port
          URL port number.
private  List<Pair<String,String>> queryParams
          Parameters in the query string.
private  String scheme
          URL schema (http, https, etc).
private  String username
          User name in the URL.
 
Constructor Summary
URLBuilder()
          Constructor.
URLBuilder(String baseURL)
          Constructor.
 
Method Summary
 String buildQueryString()
          Builds the query string for the URL.
 String buildURL()
          Builds a URL from the given data.
 String getFragment()
          Gets the URL fragment in its decoded form.
 String getHost()
          Gets the host component of the URL.
 String getPassword()
          Gets the user's password in the URL.
 String getPath()
          Gets the path component of the URL.
 int getPort()
          Gets the port component of the URL.
 List<Pair<String,String>> getQueryParams()
          Gets the query string parameters for the URL.
 String getScheme()
          Gets the URL scheme (http, https, etc).
 String getUsername()
          Gets the user name component of the URL.
 void setFragment(String newFragment)
          Sets the URL fragment in its decoded form.
 void setHost(String newHost)
          Sets the host component of the URL.
 void setPassword(String newPassword)
          Sets the user's password in the URL.
 void setPath(String newPath)
          Sets the path component of the URL.
 void setPort(int newPort)
          Sets the port component of the URL.
 void setScheme(String newScheme)
          Sets the URL scheme (http, https, etc).
 void setUsername(String newUsername)
          Sets the user name component of the URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scheme

private String scheme
URL schema (http, https, etc).


username

private String username
User name in the URL.


password

private String password
Password in the URL.


host

private String host
Host for the URL.


port

private int port
URL port number.


path

private String path
URL path.


queryParams

private List<Pair<String,String>> queryParams
Parameters in the query string.


fragement

private String fragement
URL fragment.

Constructor Detail

URLBuilder

public URLBuilder()
Constructor.


URLBuilder

public URLBuilder(String baseURL)
Constructor.

Parameters:
baseURL - URL to parse and use as basis for creating other URLs
Throws:
IllegalArgumentException - thrown if the given base URL is not well formed
Method Detail

getFragment

public String getFragment()
Gets the URL fragment in its decoded form.

Returns:
URL fragment in its decoded form

setFragment

public void setFragment(String newFragment)
Sets the URL fragment in its decoded form.

Parameters:
newFragment - URL fragment in its decoded form

getHost

public String getHost()
Gets the host component of the URL.

Returns:
host component of the URL

setHost

public void setHost(String newHost)
Sets the host component of the URL.

Parameters:
newHost - host component of the URL

getPassword

public String getPassword()
Gets the user's password in the URL.

Returns:
user's password in the URL

setPassword

public void setPassword(String newPassword)
Sets the user's password in the URL.

Parameters:
newPassword - user's password in the URL

getPath

public String getPath()
Gets the path component of the URL.

Returns:
path component of the URL

setPath

public void setPath(String newPath)
Sets the path component of the URL.

Parameters:
newPath - path component of the URL

getPort

public int getPort()
Gets the port component of the URL.

Returns:
port component of the URL

setPort

public void setPort(int newPort)
Sets the port component of the URL.

Parameters:
newPort - port component of the URL

getQueryParams

public List<Pair<String,String>> getQueryParams()
Gets the query string parameters for the URL. Params may be added and removed through the map interface.

Returns:
query string parameters for the URL

getScheme

public String getScheme()
Gets the URL scheme (http, https, etc).

Returns:
URL scheme (http, https, etc)

setScheme

public void setScheme(String newScheme)
Sets the URL scheme (http, https, etc).

Parameters:
newScheme - URL scheme (http, https, etc)

getUsername

public String getUsername()
Gets the user name component of the URL.

Returns:
user name component of the URL

setUsername

public void setUsername(String newUsername)
Sets the user name component of the URL.

Parameters:
newUsername - user name component of the URL

buildURL

public String buildURL()
Builds a URL from the given data. The constructured URL may not be valid if sufficient information is not provided. The returned URL will be appropriately encoded using application/x-www-form-urlencoded with appropriate encoding of UTF-8 characters.

Returns:
URL built from the given data

buildQueryString

public String buildQueryString()
Builds the query string for the URL.

Returns:
query string for the URL or null if there are now query parameters


Copyright © 1999-2013. All Rights Reserved.