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 ConcatExpr extends Expr { 38 private static final Logger log = Log.open(ConcatExpr.class); 39 40 private Expr _left; 41 private Expr _right; 42 43 ConcatExpr(Expr left, Expr right) 44 { 45 _left = left; 46 _right = right; 47 } 48 49 protected Expr bind(Query query) 50 throws SQLException 51 { 52 _left = _left.bind(query); 53 _right = _right.bind(query); 54 55 return this; 56 } 57 58 61 public Class getType() 62 { 63 return String .class; 64 } 65 66 69 public long subCost(ArrayList <FromItem> fromList) 70 { 71 return _left.subCost(fromList) + _right.subCost(fromList); 72 } 73 74 77 public String evalString(QueryContext context) 78 throws SQLException 79 { 80 String leftValue = _left.evalString(context); 81 String rightValue = _right.evalString(context); 82 83 if (leftValue == null) 84 return rightValue; 85 86 if (rightValue == null) 87 return leftValue; 88 89 return leftValue + rightValue; 90 } 91 92 97 public void evalGroup(QueryContext context) 98 throws SQLException 99 { 100 _left.evalGroup(context); 101 _right.evalGroup(context); 102 } 103 104 public String toString() 105 { 106 return "(" + _left + " || " + _right + ")"; 107 } 108 } 109 | Popular Tags |