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 UriBuilderaddPath(String path)Add the path to the previous path if existing.UriBuilderaddQueryParam(String name, String value)Add the given name and value as query parameters.UriBuilderaddQueryParams(String query)Parse and add the given query into query parameters.UriBuilderaddQueryParams(Map<String,String> queryParams)Clear existing query parameters and add multiple query parameters and valuesstatic UriBuilderempty()Create an empty builder instancestatic UriBuilderfrom(String uri)Create builder from the given uristatic 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 parametersUriBuildersetFragment(String fragment)Set the fragmentUriBuildersetHost(String host)Set the hostUriBuildersetPort(String port)Set the portUriBuildersetQueryParams(Map<String,String> queryParams)Add multiple query parameters and valuesUriBuildersetScheme(String scheme)Set the schemeUriBuildersetUserInfo(String userInfo)Set the user infoURItoUri()Create aURIfrom 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
-
-