jsqlparser to evaluate a condition

795 Views Asked by At

The following String:

x=92 and y=29

Produces a valid output: x=92 AND y=29 and it works fine with CCJSqlParserUtil.parseCondExpression but shouldn't it throw an exception for the following?

x=92 lasd y=29

But the output is just: x=92

Furthermore which Expression I should use to implement my own visitor? i.e,

CCJSqlParser c= new CCJSqlParser(new StringReader(str));
Expression e = c.Expression(); // or SimpleExpression, etc..

So that when 'lasd' (anything other than not,or,and) is encountered I can throw an exception and not silently ignore the rest of the expression?

1

There are 1 best solutions below

0
On BEST ANSWER

Recently a patch of JSqlParser (1.2-SNAPSHOT) was published to provide the needed behaviour:

CCJSqlParserUtil.parseExpression(String expression, boolean allowPartialParse)

and

CCJSqlParserUtil.parseCondExpression(String expression, boolean allowPartialParse)

Setting allowPartialParse to false will result in the mentioned Exception.

For on the fly interpreted stuff the already existing behaviour is still needed, e.g. to provide expressions from within an text. (Syntax coloring, Context help, ...)