Class Expression

  • All Implemented Interfaces:
    Serializable

    public class Expression
    extends UriTemplateComponent

    An Expression represents the text between '{' and '}', including the enclosing braces, as defined in Section 2 of RFC6570.

     http://www.example.com/foo{?query,number}
                                \___________/
                                      ^
                                      |
                                      |
                                The expression
     

    This class models this representation and adds helper functions for replacement and reverse matching.

    Since:
    2.0
    Version:
    $Revision: 1.1 $
    Author:
    Ryan J. McDonough
    See Also:
    Serialized Form
    • Method Detail

      • simple

        public static Expression.Builder simple​(VarSpec... varSpec)
        Creates a new Expression.Builder to create a simple expression according to section 3.2.2. Calling:
         String exp = Expression.simple(var("var")).build().toString();
         

        Will return the following expression:

         {var}
         
        Returns:
      • reserved

        public static Expression.Builder reserved​(VarSpec... varSpec)
        Creates a new Expression.Builder to create an expression that will use reserved expansion according to section 3.2.3. Calling:
         String exp = Expression.reserved().var("var").build().toString();
         

        Will return the following expression:

         {+var}
         
        Returns:
      • fragment

        public static Expression.Builder fragment​(VarSpec... varSpec)
        Creates a new Expression.Builder to create an expression with a fragment operator according to section 3.2.4. Calling:
         String exp = Expression.fragment().var("var").build().toString();
         

        Will return the following expression:

         {#var}
         
        Returns:
      • label

        public static Expression.Builder label​(VarSpec... varSpec)
        Creates a new Expression.Builder to create an expression using label expansion according to section 3.2.5. Calling:
         String exp = Expression.label(var("var")).build().toString();
         

        Will return the following expression:

         {.var}
         
        Returns:
      • path

        public static Expression.Builder path​(VarSpec... varSpec)
        Creates a new Expression.Builder to create an expression using path expansion according to section 3.2.6. Calling:
         String exp = Expression.path().var("var").build().toString();
         

        Will return the following expression:

         {/var}
         
        Returns:
      • matrix

        public static Expression.Builder matrix​(VarSpec... varSpec)
        Creates a new Expression.Builder to create an expression using path-style parameter (a.k.a. matrix parameter) expansion according to section 3.2.7. Calling:
         String exp = Expression.matrix().var("var").build().toString();
         

        Will return the following expression:

         {;var}
         
        Returns:
        the builder
      • query

        public static Expression.Builder query​(VarSpec... varSpec)
        Creates a new Expression.Builder to create an expression using form-style query string expansion according to section 3.2.8. Calling:
         String exp = Expression.query().var("var").build().toString();
         

        Will return the following expression:

         {?var}
         
        Returns:
      • continuation

        public static Expression.Builder continuation​(VarSpec... varSpec)
        Creates a new Expression.Builder to create an expression using form-style query continuation expansion according to section 3.2.9. Calling:
         String exp = Expression.continuation().var("var").build().toString();
         

        Will return the following expression:

         {&var}
         
        Returns:
      • getMatchPattern

        public Pattern getMatchPattern()
        Returns a string that contains a regular expression that matches the URI template expression.
        Specified by:
        getMatchPattern in class UriTemplateComponent
        Returns:
        the match pattern
      • getReplacementPattern

        public String getReplacementPattern()
        Get the replacementToken.
        Returns:
        the replacementToken.
      • getOperator

        public Operator getOperator()
        Get the Operator value for this expression.
        Returns:
        the operator value.
      • getVarSpecs

        public List<VarSpec> getVarSpecs()
        Get the varSpecs.
        Returns:
        the varSpecs.
      • getValue

        public String getValue()
        Returns the value of this component
        Specified by:
        getValue in class UriTemplateComponent
        Returns:
        the string value of this component.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object