Class QueryFilterParser<F>

  • Type Parameters:
    F - The type of field description used in parsed QueryFilter objects.

    public abstract class QueryFilterParser<F>
    extends Object
    A query string has the following string representation:
     Expr           = OrExpr
     OrExpr         = AndExpr ( 'or' AndExpr ) *
     AndExpr        = NotExpr ( 'and' NotExpr ) *
     NotExpr        = '!' PrimaryExpr | PrimaryExpr
     PrimaryExpr    = '(' Expr ')' | ComparisonExpr | PresenceExpr | LiteralExpr | ComplexExpr
     ComplexExpr    = Pointer '[' Expr ']'
     ComparisonExpr = Pointer OpName Value
     PresenceExpr   = Pointer 'pr'
     LiteralExpr    = 'true' | 'false'
     Pointer        = Case-sensitive field specification
     OpName         = 'eq' |  # equal to
                      'co' |  # contains
                      'sw' |  # starts with
                      'lt' |  # less than
                      'le' |  # less than or equal to
                      'gt' |  # greater than
                      'ge' |  # greater than or equal to
                      STRING  # extended operator
     Value          = NUMBER | BOOLEAN | '"' UTF8STRING '"' | ''' UTF8STRING '''
     STRING         = ASCII string not containing white-space
     UTF8STRING     = UTF-8 string possibly containing white-space
     
    Note that white space, parentheses, and exclamation characters need URL when passed via HTTP query strings.

    ASCII and UTF-8 strings will treat the backslash character as an escape character. For an example, this will allow for the inclusion of quotes or single-quotes within a string that is surrounded by the same type of quotes: "tes\"t". The backslash character itself will also need to be escaped if it is to be included in the string.

    In addition to single valued properties (number, boolean, and string), query filters can be applied to multi-valued properties. When operating on properties that are an array or list type the operation should be evaluated on each element in the array, passing if any of the elements in the array or list pass the operation.

    • Constructor Detail

      • QueryFilterParser

        public QueryFilterParser()
    • Method Detail

      • parseField

        protected abstract F parseField​(String fieldDescription)
        Parses the field description from the current filter token into the type of field description the QueryFilter uses.
        Parameters:
        fieldDescription - The token from parsing the query string.
        Returns:
        The field description.
      • valueOf

        public QueryFilter<F> valueOf​(String string)
        Parses the provided string representation of a query filter as a QueryFilter.
        Parameters:
        string - The string representation of a query filter .
        Returns:
        The parsed QueryFilter.
        Throws:
        IllegalArgumentException - If string is not a valid string representation of a query filter.