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 BinaryEqExpr extends Expr { 38 private static final Logger log = Log.open(BinaryEqExpr.class); 39 40 private ColumnExpr _column; 41 private byte []_matchBuffer; 42 43 BinaryEqExpr(ColumnExpr left, StringExpr right) 44 { 45 _column = left; 46 47 try { 48 _matchBuffer = right.getValue().getBytes("UTF8"); 49 } catch (Exception e) { 50 throw new RuntimeException (e); 51 } 52 } 53 54 protected Expr bind(Query query) 55 throws SQLException 56 { 57 throw new UnsupportedOperationException (); 58 } 59 60 63 public Class getType() 64 { 65 return boolean.class; 66 } 67 68 71 public long subCost(ArrayList <FromItem> fromList) 72 { 73 return _column.subCost(fromList); 74 } 75 76 79 public int evalBoolean(QueryContext context) 80 throws SQLException 81 { 82 if (_column.isNull(context)) 83 return UNKNOWN; 84 else 85 return _column.evalEqual(context, _matchBuffer) ? TRUE : FALSE; 86 } 87 88 public String evalString(QueryContext context) 89 throws SQLException 90 { 91 throw new SQLException ("can't convert string to boolean"); 92 } 93 94 public String toString() 95 { 96 return "(" + _column + " = byte[])"; 97 } 98 } 99 | Popular Tags |