@Immutable public final class RSQLParser extends Object
RSQL is a query language for parametrized filtering of entries in RESTful APIs. It's a superset of the FIQL (Feed Item Query Language), so it can be used for parsing FIQL as well.
Grammar in EBNF notation:
input = or, EOF;
or = and, { ( "," | " or " ) , and };
and = constraint, { ( ";" | " and " ), constraint };
constraint = ( group | comparison );
group = "(", or, ")";
comparison = selector, comparator, arguments;
selector = unreserved-str;
comparator = comp-fiql | comp-alt;
comp-fiql = ( ( "=", { ALPHA } ) | "!" ), "=";
comp-alt = ( ">" | "<" ), [ "=" ];
arguments = ( "(", value, { "," , value }, ")" ) | value;
value = unreserved-str | double-quoted | single-quoted;
unreserved-str = unreserved, { unreserved }
single-quoted = "'", { ( escaped | all-chars - ( "'" | "\" ) ) }, "'";
double-quoted = '"', { ( escaped | all-chars - ( '"' | "\" ) ) }, '"';
reserved = '"' | "'" | "(" | ")" | ";" | "," | "=" | "!" | "~" | "<" | ">" | " ";
unreserved = all-chars - reserved;
escaped = "\", all-chars;
all-chars = ? all unicode characters ?;
| Constructor and Description |
|---|
RSQLParser()
Creates a new instance of
RSQLParser with the default set of comparison operators. |
RSQLParser(Set<ComparisonOperator> operators)
Creates a new instance of
RSQLParser that supports only the specified comparison
operators. |
| Modifier and Type | Method and Description |
|---|---|
Node |
parse(String query)
Parses the RSQL expression and returns AST.
|
public RSQLParser()
RSQLParser with the default set of comparison operators.public RSQLParser(Set<ComparisonOperator> operators)
RSQLParser that supports only the specified comparison
operators.operators - A set of supported comparison operators. Must not be null or empty.public Node parse(String query) throws RSQLParserException
query - The query expression to parse.RSQLParserException - If some exception occurred during parsing, i.e. the
query is syntactically invalid.IllegalArgumentException - If the query is null.Copyright © 2011–2016. All rights reserved.