org.jasig.cas.client.util
Class URIBuilder

java.lang.Object
  extended by org.jasig.cas.client.util.URIBuilder

public final class URIBuilder
extends Object

A utility class borrowed from apache http-client to build uris.

Since:
3.4
Author:
Misagh Moayyed

Nested Class Summary
static class URIBuilder.BasicNameValuePair
           
 
Constructor Summary
URIBuilder()
          Constructs an empty instance.
URIBuilder(boolean encode)
           
URIBuilder(String string)
          Construct an instance from the string which must be a valid URI.
URIBuilder(String string, boolean encode)
           
URIBuilder(URI uri)
          Construct an instance from the provided URI.
 
Method Summary
 URIBuilder addParameter(String param, String value)
          Adds parameter to URI query.
 URIBuilder addParameters(List<URIBuilder.BasicNameValuePair> nvps)
          Adds URI query parameters.
 URI build()
          Builds a URI instance.
 URIBuilder clearParameters()
          Clears URI query parameters.
 URIBuilder digestURI(URI uri)
           
 boolean equals(Object o)
           
 String getFragment()
           
 String getHost()
           
 String getPath()
           
 int getPort()
           
 List<URIBuilder.BasicNameValuePair> getQueryParams()
           
 String getScheme()
           
 String getUserInfo()
           
 int hashCode()
           
 boolean isAbsolute()
           
 boolean isOpaque()
           
 URIBuilder removeQuery()
          Removes URI query.
 URIBuilder setCustomQuery(String query)
          Sets custom URI query.
 URIBuilder setEncode(boolean encode)
           
 URIBuilder setEncodedFragment(String fragment)
           
 URIBuilder setEncodedPath(String path)
           
 URIBuilder setEncodedQuery(String query)
           
 URIBuilder setFragment(String fragment)
          Sets URI fragment.
 URIBuilder setHost(String host)
          Sets URI host.
 URIBuilder setParameter(String param, String value)
          Sets parameter of URI query overriding existing value if set.
 URIBuilder setParameters(List<URIBuilder.BasicNameValuePair> nvps)
          Sets URI query parameters.
 URIBuilder setParameters(String queryParameters)
           
 URIBuilder setParameters(URIBuilder.BasicNameValuePair... nvps)
          Sets URI query parameters.
 URIBuilder setPath(String path)
          Sets URI path.
 URIBuilder setPort(int port)
          Sets URI port.
 URIBuilder setScheme(String scheme)
          Sets URI scheme.
 URIBuilder setUserInfo(String userInfo)
          Sets URI user info.
 URIBuilder setUserInfo(String username, String password)
          Sets URI user info as a combination of username and password.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URIBuilder

public URIBuilder()
Constructs an empty instance.


URIBuilder

public URIBuilder(boolean encode)

URIBuilder

public URIBuilder(String string)
Construct an instance from the string which must be a valid URI.

Parameters:
string - a valid URI in string form
Throws:
RuntimeException - if the input is not a valid URI

URIBuilder

public URIBuilder(String string,
                  boolean encode)

URIBuilder

public URIBuilder(URI uri)
Construct an instance from the provided URI.

Parameters:
uri - the uri to digest
Method Detail

build

public URI build()
Builds a URI instance.


digestURI

public URIBuilder digestURI(URI uri)

setEncode

public URIBuilder setEncode(boolean encode)

setScheme

public URIBuilder setScheme(String scheme)
Sets URI scheme.


setUserInfo

public URIBuilder setUserInfo(String userInfo)
Sets URI user info. The value is expected to be unescaped and may contain non ASCII characters.


setUserInfo

public URIBuilder setUserInfo(String username,
                              String password)
Sets URI user info as a combination of username and password. These values are expected to be unescaped and may contain non ASCII characters.


setHost

public URIBuilder setHost(String host)
Sets URI host.


setPort

public URIBuilder setPort(int port)
Sets URI port.


setPath

public URIBuilder setPath(String path)
Sets URI path. The value is expected to be unescaped and may contain non ASCII characters.


setEncodedPath

public URIBuilder setEncodedPath(String path)

removeQuery

public URIBuilder removeQuery()
Removes URI query.


setParameters

public URIBuilder setParameters(List<URIBuilder.BasicNameValuePair> nvps)
Sets URI query parameters. The parameter name / values are expected to be unescaped and may contain non ASCII characters.

Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.


setParameters

public URIBuilder setParameters(String queryParameters)

addParameters

public URIBuilder addParameters(List<URIBuilder.BasicNameValuePair> nvps)
Adds URI query parameters. The parameter name / values are expected to be unescaped and may contain non ASCII characters.

Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.


setParameters

public URIBuilder setParameters(URIBuilder.BasicNameValuePair... nvps)
Sets URI query parameters. The parameter name / values are expected to be unescaped and may contain non ASCII characters.

Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.


addParameter

public URIBuilder addParameter(String param,
                               String value)
Adds parameter to URI query. The parameter name and value are expected to be unescaped and may contain non ASCII characters.

Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.


setParameter

public URIBuilder setParameter(String param,
                               String value)
Sets parameter of URI query overriding existing value if set. The parameter name and value are expected to be unescaped and may contain non ASCII characters.

Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.


clearParameters

public URIBuilder clearParameters()
Clears URI query parameters.


setCustomQuery

public URIBuilder setCustomQuery(String query)
Sets custom URI query. The value is expected to be unescaped and may contain non ASCII characters.

Please note query parameters and custom query component are mutually exclusive. This method will remove query parameters if present.


setFragment

public URIBuilder setFragment(String fragment)
Sets URI fragment. The value is expected to be unescaped and may contain non ASCII characters.


setEncodedFragment

public URIBuilder setEncodedFragment(String fragment)

setEncodedQuery

public URIBuilder setEncodedQuery(String query)

isAbsolute

public boolean isAbsolute()

isOpaque

public boolean isOpaque()

getScheme

public String getScheme()

getUserInfo

public String getUserInfo()

getHost

public String getHost()

getPort

public int getPort()

getPath

public String getPath()

getQueryParams

public List<URIBuilder.BasicNameValuePair> getQueryParams()

getFragment

public String getFragment()

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2006-2015 Jasig. All Rights Reserved.