1 5 package org.h2.expression; 6 7 import java.sql.SQLException ; 8 9 import org.h2.engine.Session; 10 import org.h2.table.Column; 11 import org.h2.table.ColumnResolver; 12 import org.h2.table.TableFilter; 13 import org.h2.util.StringUtils; 14 import org.h2.value.Value; 15 16 17 20 public abstract class Expression { 21 22 private boolean addedToFilter; 23 24 public abstract Value getValue(Session session) throws SQLException ; 25 public abstract int getType(); 26 public abstract void mapColumns(ColumnResolver resolver, int level) throws SQLException ; 27 public abstract Expression optimize(Session session) throws SQLException ; 28 public abstract void setEvaluatable(TableFilter tableFilter, boolean b); 29 public abstract int getScale(); 30 public abstract long getPrecision(); 31 public abstract String getSQL(); 32 public abstract void updateAggregate(Session session) throws SQLException ; 33 public abstract boolean isEverything(ExpressionVisitor visitor); 34 public abstract int getCost(); 35 36 public final boolean isEverything(int expressionVisitorType) { 37 ExpressionVisitor visitor = ExpressionVisitor.get(expressionVisitorType); 38 return isEverything(visitor); 39 } 40 41 public boolean isConstant() { 42 return false; 43 } 44 45 public boolean isAutoIncrement() { 46 return false; 47 } 48 49 public Boolean getBooleanValue(Session session) throws SQLException { 50 return getValue(session).getBoolean(); 52 } 53 54 public void createIndexConditions(TableFilter filter) throws SQLException { 55 } 57 58 public String getColumnName() { 59 return getAlias(); 60 } 61 62 public String getSchemaName() { 63 return null; 64 } 65 66 public String getTableName() { 67 return null; 68 } 69 70 public int getNullable() { 71 return Column.NULLABLE_UNKNOWN; 72 } 73 74 public String getTableAlias() { 75 return null; 76 } 77 78 public String getAlias() { 79 return StringUtils.unEnclose(getSQL()); 80 } 81 82 public boolean isWildcard() { 83 return false; 84 } 85 86 public Expression getNonAliasExpression() { 87 return this; 88 } 89 90 public void addFilterConditions(TableFilter filter, boolean outerJoin) { 91 if(!addedToFilter && !outerJoin && isEverything(ExpressionVisitor.EVALUATABLE)) { 92 filter.addFilterCondition(this, false); 93 addedToFilter = true; 94 } 95 } 96 } 97 | Popular Tags |