Class SearchExpressionParser
$-search language (design §5.1). Engines call it; a BeanQuery
itself carries only the raw strings.
Grammar
A column's expression is one of:
- A pattern — a bare token (case-insensitive substring / prefix / exact per the column type),
optionally with
*wildcards, or a value such as$100whose leading$is not a known operator invocation. Patterns areliteralnodes. This also covers a relative-duration token such as-24hor+7d([+-]<n>(ms|s|m|h|d)) or a signed ISO-8601 duration such as-PT24H: the parser applies no special grammar to it, since it is already an ordinary pattern; a TIMESTAMP or duration column's typed conversion (not this parser) is what resolves it relative to request time. - An operator —
$name(arg,...)where$nameis in the suppliedSearchOperatorSet. Leaf-operator arguments are literals; combinator ($and/$or/$not) arguments are themselves expressions. Columns combine withand;$or/$and/$notcombine within one column.
Literal dollar
$$ is a literal $ everywhere. A token that starts with $$ is always a pattern (never an
operator), and every $$ inside a literal decodes to a single $. So $$eq(x) is the literal
text $eq(x), while $eq(x) is the operator.
Quoting
A quoted literal argument (design §5.1) may contain its own delimiter by doubling it — "" inside a
double-quoted value, or '' inside a single-quoted value, decodes to one literal quote character of that
same kind. So $eq("a""b") is the literal text a"b. This doubling decode is independent of, and
composes with, the $$ → $ decoding above.
Errors
An unknown $name(...), a malformed expression (unclosed/unbalanced parentheses, junk after the close paren,
a stray comma, a wrong argument count), or an empty expression throws BeanQuerySyntaxException. There is no
"incomplete draft" state on the server: a request-facing adapter catches the exception and surfaces the message.
Example:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic SearchExpressionparse(String raw, SearchOperatorSet operators) Parses a raw column-search expression.
-
Method Details
-
parse
Parses a raw column-search expression.- Parameters:
raw- The raw expression string (a pattern or$name(...)). Must not benull or blank.operators- The operator set that defines which$-names are recognized. Must not benull .- Returns:
- The parsed expression, never
null . - Throws:
BeanQuerySyntaxException- If the expression is empty, names an unknown operator, or is malformed.
-