Package com.axelor.common
Class UriBuilder
- java.lang.Object
-
- com.axelor.common.UriBuilder
-
public class UriBuilder extends Object
Build and manipulate URLs
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UriBuilder
addPath(String path)
Add the path to the previous path if existing.UriBuilder
addQueryParam(String name, String value)
Add the given name and value as query parameters.UriBuilder
addQueryParams(String query)
Parse and add the given query into query parameters.UriBuilder
addQueryParams(Map<String,String> queryParams)
Clear existing query parameters and add multiple query parameters and valuesstatic UriBuilder
empty()
Create an empty builder instancestatic UriBuilder
from(String uri)
Create builder from the given uristatic UriBuilder
of(String scheme, String userInfo, String host, String port, String path, String queryParams, String fragment)
Create builder from the given parametersstatic UriBuilder
of(String scheme, String userInfo, String host, String port, String path, Map<String,String> queryParams, String fragment)
Create builder from the given parametersUriBuilder
setFragment(String fragment)
Set the fragmentUriBuilder
setHost(String host)
Set the hostUriBuilder
setPort(String port)
Set the portUriBuilder
setQueryParams(Map<String,String> queryParams)
Add multiple query parameters and valuesUriBuilder
setScheme(String scheme)
Set the schemeUriBuilder
setUserInfo(String userInfo)
Set the user infoURI
toUri()
Create aURI
from this instance
-
-
-
Method Detail
-
empty
public static UriBuilder 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
public static UriBuilder from(String uri)
Create builder from the given uri- Parameters:
uri
- the uri- Returns:
- the uri builder
-
setFragment
public UriBuilder setFragment(String fragment)
Set the fragment- Parameters:
fragment
- the fragment- Returns:
- the uri builder
-
addQueryParams
public UriBuilder addQueryParams(String query)
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
public UriBuilder addQueryParams(Map<String,String> queryParams)
Clear existing query parameters and add multiple query parameters and values- Parameters:
queryParams
- the params- Returns:
- the uri builder
-
setQueryParams
public UriBuilder setQueryParams(Map<String,String> queryParams)
Add multiple query parameters and values- Parameters:
queryParams
- the params- Returns:
- the uri builder
-
addQueryParam
public UriBuilder addQueryParam(String name, String value)
Add the given name and value as query parameters.- Parameters:
name
- the namevalue
- the value- Returns:
- the uri builder
-
addPath
public UriBuilder addPath(String path)
Add the path to the previous path if existing.- Parameters:
path
- the path- Returns:
- the uri builder
-
setPort
public UriBuilder setPort(String port)
Set the port- Parameters:
port
- the port- Returns:
- the uri builder
-
setHost
public UriBuilder setHost(String host)
Set the host- Parameters:
host
- the host- Returns:
- the uri builder
-
setUserInfo
public UriBuilder setUserInfo(String userInfo)
Set the user info- Parameters:
userInfo
- the user info- Returns:
- the uri builder
-
setScheme
public UriBuilder setScheme(String scheme)
Set the scheme- Parameters:
scheme
- the scheme- Returns:
- the uri builder
-
-