Class UriBuilder

java.lang.Object
com.axelor.common.UriBuilder

public class UriBuilder extends Object
Build and manipulate URLs
  • Constructor Details

    • UriBuilder

      public UriBuilder(UriBuilder other)
      Create a deep copy of the given UriBuilder instance
      Parameters:
      other - the UriBuilder instance to copy from
  • Method Details

    • 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 scheme
      userInfo - the user info
      host - the host
      port - the port
      path - the path
      queryParams - the query params
      fragment - 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 scheme
      userInfo - the user info
      host - the host
      port - the port
      path - the path
      queryParams - the query params
      fragment - 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
    • merge

      public UriBuilder merge(UriBuilder other)
      Merges the attributes of the given UriBuilder instance into the current UriBuilder instance. This method updates the current UriBuilder instance with the non-null and non-default values from the given UriBuilder instance.
      Parameters:
      other - the UriBuilder instance to copy from
      Returns:
      this UriBuilder
    • cloneBuilder

      public UriBuilder cloneBuilder()
      Clone the current UriBuilder instance
      Returns:
      a new UriBuilder instance that is a copy of this 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 name
      value - 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
    • toUri

      public URI toUri()
      Create a URI from this instance
      Returns:
      the uri