1 28 29 package com.caucho.db.sql; 30 31 import com.caucho.log.Log; 32 33 import java.sql.SQLException ; 34 import java.util.ArrayList ; 35 import java.util.logging.Logger ; 36 37 class StringEqExpr extends Expr { 38 private static final Logger log = Log.open(StringEqExpr.class); 39 40 private ColumnExpr _column; 41 private Expr _right; 42 43 StringEqExpr(ColumnExpr left, Expr right) 44 { 45 _column = left; 46 _right = right; 47 } 48 49 protected Expr bind(Query query) 50 throws SQLException 51 { 52 throw new UnsupportedOperationException (); 53 } 54 55 58 public long subCost(ArrayList <FromItem> fromList) 59 { 60 return _column.subCost(fromList) + _right.subCost(fromList); 61 } 62 63 66 public Class getType() 67 { 68 return boolean.class; 69 } 70 71 74 public boolean isNull(QueryContext context) 75 throws SQLException 76 { 77 return _column.isNull(context); 78 } 79 80 83 public int evalBoolean(QueryContext context) 84 throws SQLException 85 { 86 if (_right.isNull(context)) 87 return UNKNOWN; 88 else if (_column.isNull(context)) 89 return UNKNOWN; 90 91 if (_column.evalEqual(context, _right.evalString(context))) 92 return TRUE; 93 else 94 return FALSE; 95 } 96 97 public String evalString(QueryContext context) 98 throws SQLException 99 { 100 throw new SQLException ("can't convert string to boolean"); 101 } 102 103 public String toString() 104 { 105 return "(" + _column + " = " + _right + ")"; 106 } 107 } 108 | Popular Tags |