[#3001] Add VisitContext.clausesLength() and queryPartsLength() to indicate the depth of the currently visited QueryPart tree

This commit is contained in:
Lukas Eder 2014-02-04 16:58:17 +01:00
parent 5d49584e96
commit c922c07b98
3 changed files with 21 additions and 1 deletions

View File

@ -110,6 +110,11 @@ public interface VisitContext {
*/
Clause[] clauses();
/**
* This is the same as calling {@link #clauses()}<code>.length</code>.
*/
int clausesLength();
/**
* The most recent {@link QueryPart} that was encountered through
* {@link Context#visit(QueryPart)}.
@ -136,6 +141,11 @@ public interface VisitContext {
*/
QueryPart[] queryParts();
/**
* This is the same as calling {@link #queryParts()}<code>.length</code>.
*/
int queryPartsLength();
/**
* The underlying {@link RenderContext} or {@link BindContext} object.
*/

View File

@ -241,6 +241,11 @@ abstract class AbstractContext<C extends Context<C>> implements Context<C> {
return visitClauses.toArray(new Clause[visitClauses.size()]);
}
@Override
public final int clausesLength() {
return visitClauses.size();
}
@Override
public final QueryPart queryPart() {
return visitParts.peekLast();
@ -257,6 +262,11 @@ abstract class AbstractContext<C extends Context<C>> implements Context<C> {
return visitParts.toArray(new QueryPart[visitParts.size()]);
}
@Override
public final int queryPartsLength() {
return visitParts.size();
}
@Override
public final Context<?> context() {
return AbstractContext.this;

View File

@ -213,7 +213,7 @@ public class LoggerListener extends DefaultExecuteListener {
@Override
public void visitEnd(VisitContext context) {
if (anyAbbreviations) {
if (context.queryParts().length == 1) {
if (context.queryPartsLength() == 1) {
context.renderContext().sql(" -- Bind values may have been abbreviated for DEBUG logging. Use TRACE logging for very large bind variables.");
}
}