提交 7387be71 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

add toString() for debugging purposes

上级 54efc692
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, and the
* EPL 1.0 (http://h2database.com/html/license.html). Initial Developer: H2
* Group
*/
package org.h2.index;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
......@@ -110,7 +111,8 @@ public class IndexCondition {
*/
public static IndexCondition getInList(ExpressionColumn column,
List<Expression> list) {
IndexCondition cond = new IndexCondition(Comparison.IN_LIST, column, null);
IndexCondition cond = new IndexCondition(Comparison.IN_LIST, column,
null);
cond.expressionList = list;
return cond;
}
......@@ -124,7 +126,8 @@ public class IndexCondition {
* @return the index condition
*/
public static IndexCondition getInQuery(ExpressionColumn column, Query query) {
IndexCondition cond = new IndexCondition(Comparison.IN_QUERY, column, null);
IndexCondition cond = new IndexCondition(Comparison.IN_QUERY, column,
null);
cond.expressionQuery = query;
return cond;
}
......@@ -186,7 +189,7 @@ public class IndexCondition {
}
StatementBuilder buff = new StatementBuilder();
buff.append(column.getSQL());
switch(compareType) {
switch (compareType) {
case Comparison.EQUAL:
buff.append(" = ");
break;
......@@ -222,7 +225,7 @@ public class IndexCondition {
buff.append(" && ");
break;
default:
DbException.throwInternalError("type="+compareType);
DbException.throwInternalError("type=" + compareType);
}
if (expression != null) {
buff.append(expression.getSQL());
......@@ -335,8 +338,7 @@ public class IndexCondition {
/**
* Check if this index condition is of the type equality.
*
* @param constantExpression if the inner node
* is a constant expression
* @param constantExpression if the inner node is a constant expression
* @return true if this is a equality condition
*/
public boolean isEquality(boolean constantExpression) {
......@@ -369,7 +371,8 @@ public class IndexCondition {
*/
public boolean isEvaluatable() {
if (expression != null) {
return expression.isEverything(ExpressionVisitor.EVALUATABLE_VISITOR);
return expression
.isEverything(ExpressionVisitor.EVALUATABLE_VISITOR);
}
if (expressionList != null) {
for (Expression e : expressionList) {
......@@ -379,7 +382,43 @@ public class IndexCondition {
}
return true;
}
return expressionQuery.isEverything(ExpressionVisitor.EVALUATABLE_VISITOR);
return expressionQuery
.isEverything(ExpressionVisitor.EVALUATABLE_VISITOR);
}
/**
* for display in the debugger
*/
public String toString() {
return "column=" + column + ", compareType="
+ compareTypeToString(compareType) + ", expression="
+ expression + ", expressionList=" + expressionList.toString()
+ ", expressionQuery=" + expressionQuery;
}
private static String compareTypeToString(int i) {
StatementBuilder s = new StatementBuilder();
if ((i & EQUALITY) == EQUALITY) {
s.appendExceptFirst("&");
s.append("EQUALITY");
}
if ((i & START) == START) {
s.appendExceptFirst("&");
s.append("START");
}
if ((i & END) == END) {
s.appendExceptFirst("&");
s.append("END");
}
if ((i & ALWAYS_FALSE) == ALWAYS_FALSE) {
s.appendExceptFirst("&");
s.append("ALWAYS_FALSE");
}
if ((i & SPATIAL_INTERSECTS) == SPATIAL_INTERSECTS) {
s.appendExceptFirst("&");
s.append("SPATIAL_INTERSECTS");
}
return s.toString();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论