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.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | |
| private String | |
| private String | |
| public static final String | |
| private static final List | |
| public static final String | |
| public static final String | |
| private Map | |
| private String | |
| public static final String | |
| private String | |
| private StringBuilder |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public UrlBuilder | |
| public UrlBuilder | |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| private void | |
| private void | |
| public String | |
| protected void | |
| protected Map | |
| protected String | |
| protected void | |
| public UrlBuilder | |
| public UrlBuilder | |
| public UrlBuilder | setQueryString(String queryString)
Setting a query string consecutively will replace all but the last one. |
| DEFAULT_ENCODING | back to summary |
|---|---|
| public static final String DEFAULT_ENCODING | |
| encoding | back to summary |
|---|---|
| private String encoding | |
| fragment | back to summary |
|---|---|
| private String fragment | |
| FRAGMENT_SEPARATOR | back to summary |
|---|---|
| public static final String FRAGMENT_SEPARATOR | |
| NULL_LIST | back to summary |
|---|---|
| private static final List<String> NULL_LIST | |
| PARAMETER_NAME_VALUE_SEPARATOR | back to summary |
|---|---|
| public static final String PARAMETER_NAME_VALUE_SEPARATOR | |
| PARAMETER_PAIR_SEPARATOR | back to summary |
|---|---|
| public static final String PARAMETER_PAIR_SEPARATOR | |
| parameters | back to summary |
|---|---|
| private Map<String, List<String>> parameters | |
| path | back to summary |
|---|---|
| private String path | |
| QUERY_STRING_SEPARATOR | back to summary |
|---|---|
| public static final String QUERY_STRING_SEPARATOR | |
| queryString | back to summary |
|---|---|
| private String queryString | |
| url | back to summary |
|---|---|
| private StringBuilder url | |
| UrlBuilder | back to summary |
|---|---|
| public UrlBuilder(String url, String encoding) | |
| UrlBuilder | back to summary |
|---|---|
| public UrlBuilder(String url) | |
| addParameters | back to summary |
|---|---|
| public UrlBuilder addParameters(String name, List<String> values) | |
| addParameters | back to summary |
|---|---|
| public UrlBuilder addParameters(Map<String, List<String>> params) | |
| addValuesToParameter | back to summary |
|---|---|
| protected void addValuesToParameter(String name, List<String> valuesRef, boolean replace) | |
| addValueToParameter | back to summary |
|---|---|
| protected void addValueToParameter(String name, String value, boolean replace) | |
| appendFragment | back to summary |
|---|---|
| protected void appendFragment() | |
| appendPath | back to summary |
|---|---|
| protected void appendPath() | |
| appendQueryString | back to summary |
|---|---|
| protected void appendQueryString() | |
| cleanFragment | back to summary |
|---|---|
| private void cleanFragment() | |
| cleanQueryString | back to summary |
|---|---|
| private void cleanQueryString() | |
| createUrl | back to summary |
|---|---|
| public String createUrl() | |
| extractSegments | back to summary |
|---|---|
| protected void extractSegments(String url) | |
| getParameters | back to summary |
|---|---|
| protected Map | |
| getPath | back to summary |
|---|---|
| protected String getPath() | |
| parseQueryString | back to summary |
|---|---|
| protected void parseQueryString() | |
| setFragment | back 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. | |
| setPath | back to summary |
|---|---|
| public UrlBuilder setPath(String path) | |
| setQueryString | back 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. | |