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 Detail

      • getPart

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

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

        public boolean isTemplate()
        Returns true when this UriPart is a template with a variable
        Returns:
        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
        Parameters:
        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
        Returns:
        the resolved template
      • throwWhenNoTemplateArg

        public boolean throwWhenNoTemplateArg()
        Informs whether throw IllegalArgumentException when no object value matches the template argument
        Returns:
        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
        Parameters:
        toEncode - the given text to encode
        componentType - the component type to encode
        encode - toEncode or contextualEncode
        Returns:
        the encoded text