org.d2rq.db
Class SelectStatementBuilder
java.lang.Object
org.d2rq.db.op.OpVisitor.Default
org.d2rq.db.SelectStatementBuilder
- All Implemented Interfaces:
- OpVisitor
public class SelectStatementBuilder
- extends OpVisitor.Default
Turns a DatabaseOp
into a SQL SELECT statement.
Works by doing a depth-first traversal of the query tree, collecting
information in a SimpleQuery
object. Such an object can contain
a non-nested SQL query. Once nesting is necessary, the current
SimpleQuery
is put on a stack, a new one is allocated and
information collected in it, and then it is "flattened" by turning
it into a raw SQL string that becomes a FROM clause in the upper
instance.
The list of SELECT clauses is not built while working the tree, but
computed in the end from the DatabaseOp
's column list.
- Author:
- Richard Cyganiak (richard@cyganiak.de)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SelectStatementBuilder
public SelectStatementBuilder(DatabaseOp input,
Vendor vendor)
getSQL
public String getSQL()
getColumnSpecs
public List<ProjectionSpec> getColumnSpecs()
visit
public void visit(TableOp table)
- Specified by:
visit
in interface OpVisitor
- Overrides:
visit
in class OpVisitor.Default
visit
public void visit(SQLOp table)
- Specified by:
visit
in interface OpVisitor
- Overrides:
visit
in class OpVisitor.Default
visitOpTrue
public void visitOpTrue()
- Specified by:
visitOpTrue
in interface OpVisitor
- Overrides:
visitOpTrue
in class OpVisitor.Default
visitLeave
public void visitLeave(ProjectOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default
visitLeave
public void visitLeave(LimitOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default
visitLeave
public void visitLeave(DistinctOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default
visitLeave
public void visitLeave(SelectOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default
visitLeave
public void visitLeave(OrderOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default
visitLeave
public void visitLeave(EmptyOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default
visitEnter
public boolean visitEnter(AliasOp table)
- Specified by:
visitEnter
in interface OpVisitor
- Overrides:
visitEnter
in class OpVisitor.Default
visitLeave
public void visitLeave(AliasOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default
visitLeave
public void visitLeave(InnerJoinOp table)
- Specified by:
visitLeave
in interface OpVisitor
- Overrides:
visitLeave
in class OpVisitor.Default