Class UriPart


public class UriPart extends Object

This class represents a part of the uri as parsed by the UriTemplateParser.

The UriTemplate parser can produce multiple UriParts, each representing a part of the Uri. One part can represent either a static uri part without a template or a template with a single variable. The template with multiple variables generates multiple UriParts, each for a single variable.

  • Method Details

    • getPart

      public String getPart()
      Return the string value representing this UriPart. It can either be static content or a template.
      string value representing this UriPart
    • getGroup

      public String getGroup()
      Return the matching group of the template represented by this UriPart
      the matching group
    • isTemplate

      public boolean isTemplate()
      Returns true when this UriPart is a template with a variable
      true when a template
    • resolve

      public String resolve(Object value, UriComponent.Type componentType, boolean encode)
      Returns the resolved template variable when the value object is passed
      value - the value object to be used to resolve the template variable
      componentType - the component type that can be used to determine the encoding os special characters
      encode - the hint whether to encode or not
      the resolved template
    • throwWhenNoTemplateArg

      public boolean throwWhenNoTemplateArg()
      Informs whether throw IllegalArgumentException when no object value matches the template argument
      true when when no object value matches the template argument and IllegalArgumentException is to be thrown
    • percentEncode

      public static String percentEncode(String toEncode, UriComponent.Type componentType, boolean encode)
      Percent encode the given text
      toEncode - the given text to encode
      componentType - the component type to encode
      encode - toEncode or contextualEncode
      the encoded text