Package com.axelor.common
Class UriBuilder
java.lang.Object
com.axelor.common.UriBuilder
Build and manipulate URLs
-
Constructor Summary
ConstructorsConstructorDescriptionUriBuilder(UriBuilder other) Create a deep copy of the givenUriBuilderinstance -
Method Summary
Modifier and TypeMethodDescriptionAdd the path to the previous path if existing.addQueryParam(String name, String value) Add the given name and value as query parameters.addQueryParams(String query) Parse and add the given query into query parameters.addQueryParams(Map<String, String> queryParams) Clear existing query parameters and add multiple query parameters and valuesClone the currentUriBuilderinstancestatic UriBuilderempty()Create an empty builder instancestatic UriBuilderCreate builder from the given urimerge(UriBuilder other) Merges the attributes of the givenUriBuilderinstance into the currentUriBuilderinstance.static UriBuilderof(String scheme, String userInfo, String host, String port, String path, String queryParams, String fragment) Create builder from the given parametersstatic UriBuilderof(String scheme, String userInfo, String host, String port, String path, Map<String, String> queryParams, String fragment) Create builder from the given parameterssetFragment(String fragment) Set the fragmentSet the hostSet the portsetQueryParams(Map<String, String> queryParams) Add multiple query parameters and valuesSet the schemesetUserInfo(String userInfo) Set the user infotoUri()Create aURIfrom this instance
-
Constructor Details
-
UriBuilder
Create a deep copy of the givenUriBuilderinstance- Parameters:
other- theUriBuilderinstance to copy from
-
-
Method Details
-
empty
Create an empty builder instance- Returns:
- the uri builder
-
of
public static UriBuilder of(String scheme, String userInfo, String host, String port, String path, Map<String, String> queryParams, String fragment) Create builder from the given parameters- Parameters:
scheme- the schemeuserInfo- the user infohost- the hostport- the portpath- the pathqueryParams- the query paramsfragment- the fragment- Returns:
- the uri builder
-
of
public static UriBuilder of(String scheme, String userInfo, String host, String port, String path, String queryParams, String fragment) Create builder from the given parameters- Parameters:
scheme- the schemeuserInfo- the user infohost- the hostport- the portpath- the pathqueryParams- the query paramsfragment- the fragment- Returns:
- the uri builder
-
from
Create builder from the given uri- Parameters:
uri- the uri- Returns:
- the uri builder
-
merge
Merges the attributes of the givenUriBuilderinstance into the currentUriBuilderinstance. This method updates the currentUriBuilderinstance with the non-null and non-default values from the given UriBuilder instance.- Parameters:
other- theUriBuilderinstance to copy from- Returns:
- this
UriBuilder
-
cloneBuilder
Clone the currentUriBuilderinstance- Returns:
- a new
UriBuilderinstance that is a copy of this builder
-
setFragment
Set the fragment- Parameters:
fragment- the fragment- Returns:
- the uri builder
-
addQueryParams
Parse and add the given query into query parameters.Parameters are separated with
'&'and their values, if any, with'='.- Parameters:
query- the query- Returns:
- the uri builder
-
addQueryParams
Clear existing query parameters and add multiple query parameters and values- Parameters:
queryParams- the params- Returns:
- the uri builder
-
setQueryParams
Add multiple query parameters and values- Parameters:
queryParams- the params- Returns:
- the uri builder
-
addQueryParam
Add the given name and value as query parameters.- Parameters:
name- the namevalue- the value- Returns:
- the uri builder
-
addPath
Add the path to the previous path if existing.- Parameters:
path- the path- Returns:
- the uri builder
-
setPort
Set the port- Parameters:
port- the port- Returns:
- the uri builder
-
setHost
Set the host- Parameters:
host- the host- Returns:
- the uri builder
-
setUserInfo
Set the user info- Parameters:
userInfo- the user info- Returns:
- the uri builder
-
setScheme
Set the scheme- Parameters:
scheme- the scheme- Returns:
- the uri builder
-
toUri
Create aURIfrom this instance- Returns:
- the uri
-