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 IsNullExpr extends Expr { 38 private static final Logger log = Log.open(IsNullExpr.class); 39 40 private Expr _expr; 41 private boolean _isNot; 42 43 IsNullExpr(Expr expr, boolean isNot) 44 { 45 _expr = expr; 46 _isNot = isNot; 47 } 48 49 52 protected Expr bind(Query query) 53 throws SQLException 54 { 55 _expr = _expr.bind(query); 56 57 return this; 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 _expr.subCost(fromList); 74 } 75 76 83 public int evalBoolean(QueryContext context) 84 throws SQLException 85 { 86 if (_isNot) 87 return ! _expr.isNull(context) ? TRUE : FALSE; 88 else 89 return _expr.isNull(context) ? TRUE : FALSE; 90 } 91 92 99 public String evalString(QueryContext context) 100 throws SQLException 101 { 102 return (evalBoolean(context) == TRUE) ? "1" : "0"; 103 } 104 105 110 public void evalGroup(QueryContext context) 111 throws SQLException 112 { 113 _expr.evalGroup(context); 114 } 115 116 public String toString() 117 { 118 if (_isNot) 119 return _expr + " IS NOT NULL"; 120 else 121 return _expr + " IS NULL"; 122 } 123 } 124 | Popular Tags |