Package rife.engine

Class UrlBuilder

java.lang.Object
rife.engine.UrlBuilder

public class UrlBuilder extends Object
UrlBuilder helps creating valid URLs that automatically adapt based on the current execution Context and target Route.

Using this class will ensure that the right state is always passed on, and that the correct URL path is always used.

UrlBuilder is not intended to be instantiated directly, but rather through Context.urlFor(Route).

Since:
1.0
  • Constructor Details

    • UrlBuilder

      public UrlBuilder(Context context, Route route)
    • UrlBuilder

      public UrlBuilder(String rootUrl, Route route)
  • Method Details

    • pathInfo

      public UrlBuilder pathInfo(String pathInfo)
      Sets a particular pathinfo for this URL, it will automatically be encoded.

      If no pathinfo is manually set, the destination route has pathinfo mapping configured, and the parameters are available to construct that pathinfo, then RIFE2 will automatically create a correct pathinfo.

      Parameters:
      pathInfo - the explicit pathinfo to use
      Returns:
      this UrlBuilder instance
      Since:
      1.0
    • param

      public UrlBuilder param(String name, Object value)
      Sets an outgoing parameter to a particular value.

      This will override any automatic outgoing parameters that are being published by the Context.

      Parameters:
      name - the name of the parameter
      value - the value of the parameter
      Returns:
      this UrlBuilder instance
      Since:
      1.6.0
    • param

      public UrlBuilder param(String name, String value)
      Sets an outgoing parameter to a particular value.

      This will override any automatic outgoing parameters that are being published by the Context.

      Parameters:
      name - the name of the parameter
      value - the value of the parameter
      Returns:
      this UrlBuilder instance
      Since:
      1.0
    • param

      public UrlBuilder param(String name, String[] value)
      Sets an outgoing parameter to a particular value array.

      This will override any automatic outgoing parameters that are being published by the Context.

      Parameters:
      name - the name of the parameter
      value - the value of the parameter
      Returns:
      this UrlBuilder instance
      Since:
      1.0
    • params

      public UrlBuilder params(Map<String,String[]> parameters)
      Sets a parameters for all the entries in the provided parameter map.

      This will override any automatic outgoing parameters that are being published by the Context.

      Parameters:
      parameters - the map of parameters that will be set
      Returns:
      this UrlBuilder instance
      Since:
      1.0
    • fragment

      public UrlBuilder fragment(String fragment)
      Sets a particular fragment for this URL, it will be appended at the end, separated by a #.
      Parameters:
      fragment - the fragment to use
      Returns:
      this UrlBuilder instance
      Since:
      1.0
    • generateSegments

      public UrlBuilder.Segments generateSegments()
      Generates the segments for the current state of the UrlBuilder.
      Returns:
      the segments of the URL that's being built
      Since:
      1.0
    • toString

      public String toString()
      Generates the string version for the current state of the UrlBuilder.
      Overrides:
      toString in class Object
      Returns:
      the string of the URL that's being built
      Since:
      1.0