Top Description Fields Constructors Methods
com.sun.faces.context

pack-priv Class UrlBuilder

extends Object
Class Inheritance
Imports
com.sun.faces.util.Util, java.io.UnsupportedEncodingException, java.net.URLEncoder, java.util.ArrayList, .Arrays, .Iterator, .LinkedHashMap, .List, .Map, javax.faces.context.FacesContext, javax.faces.lifecycle.ClientWindow, javax.faces.render.ResponseStateManager

The UrlBuilder provides a convenient way to assemble a URL. It follows the standard Builder Pattern. A seed URL is provided, which is broken into parts to allow for dynamic assembly. When the URL is to be build, a call to createUrl() assembles the parts into a relative URL. This class should be extended if the developer wishes to have it deal with absolute URLs.

Note that this class is optimized to parse the query string lazily so as to avoid unnecessary work if the seed URL differs little from the URL to be built.

Field Summary

Modifier and TypeField and Description
public static final String
private String
private String
public static final String
private static final List<String>
public static final String
public static final String
private Map<String, List<String>>
private String
public static final String
private String
private StringBuilder

Constructor Summary

AccessConstructor and Description
public
UrlBuilder(String url, String encoding)

public

Method Summary

Modifier and TypeMethod and Description
public UrlBuilder
public UrlBuilder
protected void
addValuesToParameter(String name, List<String> valuesRef, boolean replace)

protected void
addValueToParameter(String name, String value, boolean replace)

protected void
protected void
protected void
private void
private void
public String
protected void
protected Map<String, List<String>>
protected String
protected void
public UrlBuilder
setFragment(String fragment)

The fragment is appended at the end of the url after a hash mark.

public UrlBuilder
public UrlBuilder
setQueryString(String queryString)

Setting a query string consecutively will replace all but the last one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_ENCODINGback to summary
public static final String DEFAULT_ENCODING
encodingback to summary
private String encoding
fragmentback to summary
private String fragment
FRAGMENT_SEPARATORback to summary
public static final String FRAGMENT_SEPARATOR
NULL_LISTback to summary
private static final List<String> NULL_LIST
PARAMETER_NAME_VALUE_SEPARATORback to summary
public static final String PARAMETER_NAME_VALUE_SEPARATOR
PARAMETER_PAIR_SEPARATORback to summary
public static final String PARAMETER_PAIR_SEPARATOR
parametersback to summary
private Map<String, List<String>> parameters
pathback to summary
private String path
QUERY_STRING_SEPARATORback to summary
public static final String QUERY_STRING_SEPARATOR
queryStringback to summary
private String queryString
urlback to summary
private StringBuilder url

Constructor Detail

UrlBuilderback to summary
public UrlBuilder(String url, String encoding)
UrlBuilderback to summary
public UrlBuilder(String url)

Method Detail

addParametersback to summary
public UrlBuilder addParameters(String name, List<String> values)
addParametersback to summary
public UrlBuilder addParameters(Map<String, List<String>> params)
addValuesToParameterback to summary
protected void addValuesToParameter(String name, List<String> valuesRef, boolean replace)
addValueToParameterback to summary
protected void addValueToParameter(String name, String value, boolean replace)
appendFragmentback to summary
protected void appendFragment()
appendPathback to summary
protected void appendPath()
appendQueryStringback to summary
protected void appendQueryString()
cleanFragmentback to summary
private void cleanFragment()
cleanQueryStringback to summary
private void cleanQueryString()
createUrlback to summary
public String createUrl()
extractSegmentsback to summary
protected void extractSegments(String url)
getParametersback to summary
protected Map<String, List<String>> getParameters()
getPathback to summary
protected String getPath()
parseQueryStringback to summary
protected void parseQueryString()
setFragmentback to summary
public UrlBuilder setFragment(String fragment)

The fragment is appended at the end of the url after a hash mark. It represents the fragement of the document that should be brought into focus when the document is rendered. Setting the fragment replaces the previous value.

setPathback to summary
public UrlBuilder setPath(String path)
setQueryStringback to summary
public UrlBuilder setQueryString(String queryString)

Setting a query string consecutively will replace all but the last one. Otherwise, the name/value pairs in the query string contribute to the parameters already established.