Skip to content

How can I parse and evaluate WHERE expression? #1494

Answered by manticore-projects
pal548 asked this question in Q&A
Discussion options

You must be logged in to vote

Greetings! There are two different methods to walk through the AST down to the leaves

  1. Access the Properties of the Statement explicitly using if ( object instanceof Class )
  2. Using the Visitor Interfaces

The code below illustrates both ways:

package com.manticore.jsqlformatter;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.ExpressionVisitorAdapter;
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlpa…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@pal548
Comment options

Comment options

You must be logged in to vote
3 replies
@pal548
Comment options

@manticore-projects
Comment options

@pal548
Comment options

Answer selected by manticore-projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants