@Immutable
public final class RSQLParser
extends java.lang.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(NodesFactory nodesFactory)
Creates a new instance of
RSQLParser with given node factory. |
RSQLParser(java.util.Set<ComparisonOperator> operators)
Creates a new instance of
RSQLParser that supports only the specified comparison
operators. |
| Modifier and Type | Method and Description |
|---|---|
Node |
parse(java.lang.String query)
Parses the RSQL expression and returns AST.
|
public RSQLParser()
RSQLParser with the default set of comparison operators.public RSQLParser(java.util.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 RSQLParser(NodesFactory nodesFactory)
RSQLParser with given node factory.nodesFactory - A node factory to use. Must not be null.public Node parse(java.lang.String query) throws RSQLParserException
query - The query expression to parse.RSQLParserException - If some exception occurred during parsing, i.e. the
query is syntactically invalid.java.lang.IllegalArgumentException - If the query is null.