public final class RSQLParser extends Object
RSQL is query language for a parametrized filtering of entries in RESTful APIs. It's a superset of 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 = "'", { all-chars - "'" }, "'";
double-quoted = '"', { all-chars - '"' }, '"';
reserved = '"' | "'" | "(" | ")" | ";" | "," | "=" | "!" | "~" | "<" | ">" | " ";
unreserved = all-chars - reserved;
all-chars = ? all unicode characters ?;
| Constructor and Description |
|---|
RSQLParser()
Creates a new instance of
RSQLParser with the default
RSQLNodesFactory that handles built-in operators. |
RSQLParser(RSQLNodesFactory nodesFactory)
Creates a new instance of
RSQLParser with the given
RSQLNodesFactory (can be used to add custom operators). |
| Modifier and Type | Method and Description |
|---|---|
Node |
parse(String query)
Parses the RSQL expression and returns AST.
|
public RSQLParser()
RSQLParser with the default
RSQLNodesFactory that handles built-in operators.public RSQLParser(RSQLNodesFactory nodesFactory)
RSQLParser with the given
RSQLNodesFactory (can be used to add custom operators).nodesFactory - The nodes factory to use (not null).public Node parse(String query) throws RSQLParserException
query - The query expression to parse.RSQLParserException - This exception wraps ParseException,
UnknownOperatorException
and TokenMgrError.IllegalArgumentException - If the given query is null.Copyright © 2011–2014. All rights reserved.